user32.dll ¤Î IntersectRect ´Ø¿ô¤ò»ÈÍѤ¹¤ë¤È²Äǽ¤Ç¤¹¡£
²¼¤Ï¥¹¥¯¥ê¥×¥È¡£
#include "user32.as"
rc = 10,10,100,100
rc2= 50,50,120,120
dim rt,4
drawrc rc
color 255
drawrc rc2
IntersectRect varptr(rt),varptr(rc),varptr(rc2)
if(stat){
color ,255
drawrc rt
dialog "ÀÜ¿¨¤·¤Æ¤¤¤ë"
}
stop
#deffunc drawrc array rc_
boxf rc_,rc_.1,rc_.2,rc_.3
return
¥¹¥¯¥ê¥×¥È¤Ï¿ʬ¤³¤ó¤Ê´¶¤¸¤À¤È»×¤¤¤Þ¤¹¡£
Æó¤Ä¤Î»Í³Ñ·Á¤ÎĺÅÀ¤ò¤½¤ì¤¾¤ìÄ´¤Ù¤Æ¡¢°ì¤Ä¤Ç¤â¤â¤¦ÊÒÊý¤Î»Í³Ñ·Á¤ÎÆ⦤ËÆþ¤Ã¤Æ¤¤¤ë¾ì¹ç¡¢½Å¤Ê¤Ã¤Æ¤¤¤ë¤ÈȽÃǤ·¤Æ¤¤¤Þ¤¹¡£
#module
#define global ctype ptinrc(%1,%2,%3,%4,%5,%6)\
((%3<=%1) and (%4<=%2) and (%5>=%1) and (%6>=%2))
#const ISL_ 1<<0
#const IST_ 1<<1
#const ISR_ 1<<2
#const ISB_ 1<<3
#const ISL_2_ 1<<4
#const IST_2_ 1<<5
#const ISR_2_ 1<<6
#const ISB_2_ 1<<7
#const MASKL_ 0b00010001
#const MASKT_ 0b00100010
#const MASKR_ 0b01000100
#const MASKB_ 0b10001000
#define ctype push(%1)\
r%1_=%1_:i_|=IS%1_
#define ctype push2(%1)\
r%1_=%1_2_:i_|=IS%1_2_
#define ctype setrtvar(%1,%2) \
if(ptinrc(%1_,%2_,l_2_,t_2_,r_2_,b_2_)){push(%1):push(%2)}
#define ctype setrtvar2(%1,%2) \
if(ptinrc(%1_2_,%2_2_,l_,t_,r_,b_)){push2(%1):push2(%2)}
#define ctype check(%1,%2) \
if(i_&MASK%1_)==0{if(i_&IS%2_2_){push(%1)}else{push2(%1)}}
// »Í³Ñ·ÁƱ»Î¤¬ÀÜ¿¨¤·¤Æ¤¤¤ë¤«¤òȽÄꤷ¤Æ¡£
// ÀÜ¿¨¤·¤Æ¤¤¤ë»Í³Ñ·Á¤òÊÖ¤¹¡£
#deffunc rect_Intersect \
int l_ , int t_ , int r_ , int b_ , \
int l_2_ , int t_2_ , int r_2_ , int b_2_ , \
var rl_ , var rt_ , var rr_ , var rb_ , \
local i_
setrtvar(l,t)
setrtvar(r,t)
setrtvar(r,b)
setrtvar(l,b)
setrtvar2(l,t)
setrtvar2(r,t)
setrtvar2(r,b)
setrtvar2(l,b)
if(i_){
check(l,r)
else:check(t,b)
else:check(r,l)
else:check(b,t)
}
return i_
#global
px=200:py=200
title "¥Þ¥¦¥¹¤ò°ÜÆ°¤µ¤»¤Æ»Í³Ñ·ÁƱ»Î¤òÀÜ¿¨¤µ¤»¤Æ¤ß¤Æ²¼¤µ¤¤¡£"
repeat
redraw 0
color 255,255,255
boxf
bx = mousex
by = mousey
color 255,255
boxf bx,by,bx+100-1,by+100-1
color 255
boxf px,py,px+50-1,py+50-1
rect_Intersect px,py,px+50,py+50,bx,by,bx+100,by+100 , rl , rt , rr , rb
if(stat){
color ,255,255
boxf rl , rt , rr , rb
}
redraw 1
await 30
loop
°ÊÁ°½ÐÍè¤ë¤À¤±Â®ÅÙ¤ò¾å¤²¤è¤¦¤È¤·¤¿¤½¤ì¤Ê¤Î¤Ç¡¢¥¹¥¯¥ê¥×¥È¤Ï¤³¤ó¤Ê´¶¤¸¤Ç¤¹¤¬¡£
°ì±þÆ°¤¯¤Î¤Ç¥¢¥Ã¥×¤·¤Þ¤¹¡£