|
| ̤²ò·è |
| ²ò·è |
| Ää»ß |
| ºï½üÍ×ÀÁ |
|
2009/11/30(Mon) 20:16:38|NO.29079
HSP¤Ç¡¢Àþʬ¡Êx1,y1 - x2,y2¡Ë¤ÈĹÊý·Á¡¦¥Ü¥Ã¥¯¥¹(x1,y1,x2,y2)¤Î¸òº¹È½Äê¤ò¤È¤ë¤Ë¤Ï¤É¤Î¤è¤¦¤Ë¤·¤¿¤éÎɤ¤¤Ç¤·¤ç¤¦¤«¡©
¸òÅÀ¤òµá¤á¤ëɬÍפϤʤ¯¡¢¤È¤Ë¤«¤¯Â®ÅٽŻë¤Ç¤¢¤ë¤â¤Î¤òÁÛÄꤷ¤Æ¤¤¤Þ¤¹¡£
¼«Ê¬¤Ç¤âgoogle¤ò¶î»È¤·¤Æ¿§¡¹¥Á¥ã¥ì¥ó¥¸¤·¤Æ¤ß¤¿¤Î¤Ç¤¹¤¬¡¢Îɤ¤ÊýË¡¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó¤Ç¤·¤¿¡¦¡¦¡¦
Ãηäò¤ª»ý¤Á¤ÎÊý¤¬¤¤¤é¤Ã¤·¤ã¤¤¤Þ¤·¤¿¤é¡¢¤ªÎϤòÂߤ·¤Æ¤¤¤¿¤À¤¤¿¤¤¤Ç¤¹¡£
|
|
2009/11/30(Mon) 21:57:02|NO.29080
¤Þ¤º¼ÁÌ䤹¤ë¤È¤¤Ï¡¢Îɤ¯¹Í¤¨¤Æ²¼¤µ¤¤¡£
>>HSP¤Ç¡¢Àþʬ¡Êx1,y1 - x2,y2¡Ë¤ÈĹÊý·Á¡¦¥Ü¥Ã¥¯¥¹(x1,y1,x2,y2)¤Î¸òº¹È½Äê¤ò¡¦¡¦¡¦
>>¸òÅÀ¤òµá¤á¤ëɬÍפϤʤ¯¡¢¤È¤Ë¤«¤¯Â®ÅٽŻë¤Ç¤¢¤ë¤â¤Î¤òÁÛÄꤷ¤Æ¤¤¤Þ¤¹¡£
¡¡¢ª¡É¸òº¹È½Äê¡É¡É¸òÅÀ¡É¡¢ÍפϡɽŤʤê¤òȽÄꤷ¤¿¤¤¡É¤Î¤Ç¤·¤ç¤¦¤«¡©
>>¼«Ê¬¤Ç¤âgoogle¤ò¶î»È¤·¤Æ¿§¡¹¥Á¥ã¥ì¥ó¥¸¤·¤Æ¤ß¤¿¤Î¤Ç¤¹¤¬¡¢Îɤ¤ÊýË¡¤¬¡¦¡¦¡¦
¡¡¢ª¤Þ¤º¡¢¤É¤¦¶î»È¡Êõ¤·¤Æ¡©¡Ë¤·¤Æ¥À¥á¤À¤Ã¤¿¤Î¤«¡¢Ê¬¤«¤ê¤Þ¤»¤ó¡£
¤É¤¦¤¤¤¦¥¹¥¯¥ê¥×¥È¤¬¥À¥á¤Ç¡¢¤É¤¦¤·¤¿¤¤¤Î¤«¥Ï¥Ã¥¥ê¤µ¤»¤¿¤Û¤¦¤¬¡¢²óÅú¤âÆÀ¤é¤ì¤ä¤¹¤¤
¤Ç¤·¤ç¤¦¡£
|
|
2009/11/30(Mon) 23:40:13|NO.29084
ºÂɸ·×»»¤È¤«¥á¥ó¥É¤Ê¤Î¤Ç¡¢Åɤê¤Ä¤Ö¤·¤ÈºÂɸ¤Î¥«¥é¡¼¼èÆÀ¤Ç¤É¤¦¤Ç¤·¤ç¤¦¤«
x_1=10 ; ÀþʬºÂɸ
y_1=20
x_2=300
y_2=300
x1=100 ; ¥Ü¥Ã¥¯¥¹ºÂɸ
y1=100
x2=200
y2=200
;¡¤ÈĹÊý·Á¡¦¥Ü¥Ã¥¯¥¹(x1,y1,x2,y2)¤ò¤¿¤È¤¨¤ÐRGB(0,0,0)boxf¤ÇÉÁ²è¤·¤Æ¡¢
;Àþʬ¤Î»Ï½ªÅÀx_1,y_1¡¢x_2,y_2¤Î£²ÅÀ¤¬RGB(0,0,0)¤Ê¤é¸ò¤ï¤Ã¤Æ¤ë
color 0,0,0 ; ¥Ü¥Ã¥¯¥¹¿§
boxf x1,y1,x2,y2 ; ¥Ü¥Ã¥¯¥¹
pget x_1,y_1 : if ginfo_r == 0 : dialog "¥¢¥¿¥ê¡ª" : stop
pget x_2,y_2 : if ginfo_r == 0 : dialog "¥¢¥¿¥ê¡ª" : stop
;¢Àþʬ¡Êx_1,y_1 - x_2,y_2¡Ë¤ò¤¿¤È¤¨¤ÐRGB(0,0,255)¤ÇÉÁ²è¤·¤Æ¤«¤é¡¢
;x1,y1¤«¤éÊĺÉÎΰè¤òǤ°Õ¤Î¥Ö¥é¥·¿§¤ÇÅɤê¤Ä¤Ö¤·¤Æ¡¢;x1,y2¡¢x2,y1¡¢x2,y2¤Î£³ÅÀ¤òpgetÌ¿Îá¤Ç¼èÆÀ¤·¡¢¤Ò¤È¤Ä¤Ç¤âÅɤê¤Ä¤Ö¤·¿§¡Ê¥Ö¥é¥·¿§¡Ë¤Ç¤Ê¤±¤ì¤Ð¸ò¤ï¤Ã¤Æ¤ë¡£
#uselib "gdi32.dll"
#func GetPixel "GetPixel" sptr,sptr,sptr
; HDC hdc, ¥Ç¥Ð¥¤¥¹¥³¥ó¥Æ¥¥¹¥È¤Î¥Ï¥ó¥É¥ë
; int nXPos, ¥Ô¥¯¥»¥ë¤Î x ºÂɸ
; int nYPos ¥Ô¥¯¥»¥ë¤Î y ºÂɸ
#func CreateSolidBrush "CreateSolidBrush" sptr
; COLORREF crColor ¥Ö¥é¥·¤Î¿§¤òɽ¤¹ÃÍ
#func SelectObject "SelectObject" sptr,sptr
; HDC hdc, ¥Ç¥Ð¥¤¥¹¥³¥ó¥Æ¥¥¹¥È¤Î¥Ï¥ó¥É¥ë
; HGDIOBJ hgdiobj ¥ª¥Ö¥¸¥§¥¯¥È¤Î¥Ï¥ó¥É¥ë
#func ExtFloodFill "ExtFloodFill" sptr,sptr,sptr,sptr,sptr
; HDC hdc, ¥Ç¥Ð¥¤¥¹¥³¥ó¥Æ¥¥¹¥È¤Î¥Ï¥ó¥É¥ë
; int nXStart, ³«»ÏÅÀ¤Î x ºÂɸ
; int nYStart, ³«»ÏÅÀ¤Î y ºÂɸ
; COLORREF crColor Åɤê¤Ä¤Ö¤·¤Î¿§
; UINT fuFillType Åɤê¤Ä¤Ö¤·¤Î¼ïÎà
;#const FLOODFILLBORDER $00000000
#const FLOODFILLSURFACE $00000001
#func DeleteObject "DeleteObject" int
; HGDIOBJ hObject ¥°¥é¥Õ¥£¥Ã¥¯¥ª¥Ö¥¸¥§¥¯¥È¤Î¥Ï¥ó¥É¥ë
#uselib "user32.dll"
#func ReleaseDC "ReleaseDC" sptr,sptr
; HWND hWnd, ¥¦¥£¥ó¥É¥¦¤Î¥Ï¥ó¥É¥ë
; HDC hDC ¥Ç¥Ð¥¤¥¹¥³¥ó¥Æ¥¥¹¥È¤Î¥Ï¥ó¥É¥ë
#func InvalidateRect "InvalidateRect" int,int,int
; HWND hWnd, ¥¦¥£¥ó¥É¥¦¤Î¥Ï¥ó¥É¥ë
; CONST RECT *lpRect, ĹÊý·Á¤ÎºÂɸ
; BOOL bErase ¾Ãµî¤¹¤ë¤«¤É¤¦¤«¤Î¾õÂÖ
color 0,0,255 ; Àþʬ¿§
line x_1,y_1,x_2,y_2 ; Àþʬ
color 255,0,0 ; ¥Ö¥é¥·¿§ ; ¥Ö¥é¥·¿§
GetPixel hdc,x1,y1 : colref=stat
;BMSCR¹½Â¤ÂΤ˥»¥Ã¥È¤µ¤ì¤Æ¤¤¤ë¿§¤ò»È¤¤¥Ö¥é¥·¤òºîÀ®
mref bmscr,67
CreateSolidBrush bmscr(40) : ahBrush=stat
SelectObject hdc,ahBrush : ahOldBrush=stat
;ÊĺÉÎΰè¤ËÉÁ²è¤µ¤ì¤Æ¤¤¤ë¿§¤È¿·µ¬¤ËÅɤ뿧¤È¤òÈæ³Ó¤·¤Æ°ã¤¦¤Ê¤é¤Ð¿·µ¬¤Î¿§¤òÅɤë
ExtFloodFill hdc,x1,y1,colref,0 : ret=stat
if ret!1 {
ExtFloodFill hdc,x1,y1,colref,FLOODFILLSURFACE
}
SelectObject hdc,ahOldBrush
DeleteObject ahBrush
ReleaseDC hwnd,hdc
InvalidateRect hwnd,0,1 ; ºÆÉÁ²è
color 0,0,0
pget x1,y2 : if ginfo_r != 255 : dialog "¥¢¥¿¥ê¡ª" : stop
pget x2,y1 : if ginfo_r != 255 : dialog "¥¢¥¿¥ê¡ª" : stop
pget x2,y2 : if ginfo_r != 255 : dialog "¥¢¥¿¥ê¡ª" : stop
| |
|
2009/12/1(Tue) 09:45:14|NO.29093
|
|
2009/12/2(Wed) 21:09:43|NO.29114
¤¹¤Ç¤ËÎɤ¤²óÅú¤¬½Ð¤Æ¤¤¤ë¤ß¤¿¤¤¤Ç¤¹¤¬¡¢¤»¤Ã¤«¤¯ºî¤Ã¤¿¤Î¤ÇºÜ¤»¤Þ¤¹¤Í¡£
; ------------------------------------------------------------------------------
; Àþʬ ¤È ¶ë·Á ¤Î¸òº¹È½Äê
; programmed by shinkun.
; 2009/12/1
#module
; --------------------------------------------------------------------------
; _IsCross(x,y,x1,y1,x2,y2)
; Àþʬ¤¬¶ë·Á¤ÎÂгÑÀþ¤Î¤Ò¤È¤Ä¤È¸òº¹¤·¤Æ¤¤¤ë¤«¤É¤¦¤«¤òÊÖ¤¹¡£
; °ú¿ô
; x, y - Àþʬ¤ÎüÅÀ¤Î¤Ò¤È¤Ä¤ò¸¶ÅÀ£Ï¤È¤·¤¿»þ¤Î¡¢¤â¤¦°ìÊý¤ÎüÅÀ¤ÎºÂɸ
; x1, y1 - Àþʬ¤ÎüÅÀ¤Î¤Ò¤È¤Ä¤ò¸¶ÅÀ£Ï¤È¤·¤¿»þ¤Î¡¢¶ë·Á¤ÎÂгÑÀþ¤ÎÅÀ¡¤ÎºÂɸ
; x2, y2 - Àþʬ¤ÎüÅÀ¤Î¤Ò¤È¤Ä¤ò¸¶ÅÀ£Ï¤È¤·¤¿»þ¤Î¡¢¶ë·Á¤ÎÂгÑÀþ¤ÎÅÀ¢¤ÎºÂɸ
; Ìá¤êÃÍ
; 1 - Àþʬ¤ÈÂгÑÀþ¤Ï¸òº¹¤·¤Æ¤¤¤ë
; 0 - Àþʬ¤ÈÂгÑÀþ¤Ï¸òº¹¤·¤Æ¤¤¤Ê¤¤
; ÊäÂ
; ¤³¤Î´Ø¿ô¤Ç¤Ï¡¢Àþʬ¤ÎüÅÀ¤Î¤Ò¤È¤Ä¤ò¸¶ÅÀ¤È¤¹¤ëºÂɸ·Ï¤Ç¹Í¤¨¤ë¡£
#defcfunc _IsCross int x, int y, int x1, int y1, int x2, int y2, local a, local b
; Àþʬ¤È¶ë·Á¤ÎÂгÑÀþ¤¬¸òº¹¤·¤Æ¤¤¤ë¤«¤É¤¦¤«¤ÎȽÄê
b = x1 * y2 - x2 * y1 ; ʬÊì¤Î·×»»
if (b == 0): return 0
a = double(x * y2 - x2 * y) / b
b = double(x * y1 - x1 * y) / -b
return (a >= 0.0) && (b >= 0.0) && (a + b >= 1.0)
; ¤³¤Î·×»»¤Î¸µ¤È¤Ê¤ë¹Í¤¨Êý¤Ï¼¡¤ÎÄ̤ꡣ
; ¡Àþʬ¤ÎüÅÀ¤ò¤½¤ì¤¾¤ì£Á¤È£Â¤È¤¹¤ë¡£¤Þ¤¿¡¢¶ë·Á¤Î£²¤Ä¤¢¤ëÂгÑÀþ¤ÎÆâ
; ¤Ò¤È¤Ä¤òÁª¤Ó¡¢¤½¤ÎüÅÀ¤ò£Ã¤È£Ä¤È¤¹¤ë¡£
; ¢¥Ù¥¯¥È¥ë£Á£Ã¡¢£Á£Ä¤ò»È¤Ã¤Æ¡¢¥Ù¥¯¥È¥ë£Á£Â¤òɽ¤¹ÊýÄø¼°
; £Á£Â¡á¦Á£Á£Ã¡Ü¦Â£Á£Ä ¡Ê¦Á,¦Â¤Ï¼Â¿ô¡Ë
; ¤ò¹Í¤¨¤ë¡£¤¹¤ë¤È¡¢¦Á¡æ0, ¦Â¡æ0, ¦Á¡Ü¦Â¡á1 ¤Î»þ¡¢ÅÀ£Â¤ÏÂгÑÀþ£Ã£Ä
; ¾å¤Ë¾è¤Ã¤Æ¤¤¤ë»ö¤Ë¤Ê¤ë¤Î¤Ç¡¢¦Á + ¦Â >= 1 ¤À¤ÈÀþʬ£Á£Â¤ÏÂгÑÀþ¤ò
; ¸òº¹¤¹¤ë¤È¤¤¤¦»ö¤Ë¤Ê¤ë¡£
; £¤è¤Ã¤Æ¡¢ÊýÄø¼°¤ò x ºÂɸ, y ºÂɸ¤Ç¤½¤ì¤¾¤ìʬ²ò¤·¤ÆϢΩÊýÄø¼°¤È¤·¡¢
; ¦Á¤È¦Â¤ò²ò¤¯¤È¾åµ¤Î·×»»¼°¤È¤Ê¤ë¡£
; --------------------------------------------------------------------------
; IsOverlappedPointToRect(px,py,rx,ry,rw,rh)
; (px,py) ¤ÎÅÀ¤¬¡¢(x,y) ¤òº¸¾å¤È¤·Éý w, ¹â¤µ h ¤Î¶ë·ÁÆâ¤Ë¤¢¤ë¤«¤É¤¦¤«¤ò
; ÊÖ¤¹¡£
; °ú¿ô
; px, py - ÅÀ¤ÎºÂɸ
; rx, ry - ¶ë·Á¤Îº¸¾åºÂɸ
; rw, rh - ¶ë·Á¤ÎÉý¤È¹â¤µ
; Ìá¤êÃÍ
; 1 - ÅÀ¤Ï¶ë·ÁÆâ¤Ë¤¢¤ë
; 0 - ÅÀ¤Ï¶ë·ÁÆâ¤Ë¤Ê¤¤
#defcfunc IsOverlappedPointToRect int px, int py, int x, int y, int w, int h
if (px < x): return 0
if (py < y): return 0
if (px >= x + w): return 0
if (py >= y + h): return 0
return 1
; --------------------------------------------------------------------------
; IsOverlappedSegmentToRect(x1,y1,x2,y2,x,y,w,h)
; (x1,y1), (x2,y2) ¤Ç·ë¤Ð¤ì¤ëÀþʬ¤È (x,y) ¤òº¸¾å¤È¤·Éý w, ¹â¤µ h ¤Î¶ë·Á¤¬
; ½Å¤Ê¤Ã¤Æ¤¤¤ë¤«¤É¤¦¤«¤òÊÖ¤¹¡£
; °ú¿ô
; x1, y1 - Àþʬ¤ÎüÅÀ¡
; x2, y2 - Àþʬ¤ÎüÅÀ¢
; x, y - ¶ë·Á¤Îº¸¾åºÂɸ
; w, h - ¶ë·Á¤ÎÉý¤È¹â¤µ
; Ìá¤êÃÍ
; 1 - Àþʬ¤È¶ë·Á¤Ï¸òº¹¤·¤Æ¤¤¤ë
; 0 - Àþʬ¤È¶ë·Á¤Ï¸òº¹¤·¤Æ¤¤¤Ê¤¤
#defcfunc IsOverlappedSegmentToRect int x1, int y1, int x2, int y2, int x, int y, int w, int h
; Àþʬ¤ÎüÅÀ¤¬¶ë·ÁÆâ¤Ë¸ºß¤¹¤ë¤«¤É¤¦¤«¤òÄ´¤Ù¤ë
if (IsOverlappedPointToRect(x1,y1,x,y,w,h)): return 1
if (IsOverlappedPointToRect(x2,y2,x,y,w,h)): return 1
; ¤³¤³¤Ç¸¡½Ð¤µ¤ì¤ë¤Î¤Ï¡¢¶ë·ÁÆâ¤Ë ¡Àþʬ¤Îξü¡¢¢Àþʬ¤Î°ìÊý¤ÎüÅÀ ¤¬
; ¸ºß¤¹¤ë¾ì¹ç¤Ç¤¢¤ë¡£¤³¤ì°Ê¹ß¤Ï¡¢Àþʬ¤ÎüÅÀ¤¬¶ë·Á³°¤Ë¤¢¤ë¾ì¹ç¤ò¼è¤ê
; °·¤¦¡£¤Ä¤Þ¤ê¡¢¡Î¾Ã¼¤È¤â¶ë·ÁÆâ¤Ë¤Ï¸ºß¤·¤Ê¤¤¤¬¡¢¤½¤Îξü¤ò·ë¤ÖÀþʬ
; ¤¬¶ë·Á¾å¤òÄ̲᤹¤ë¾ì¹ç ¢Àþʬ¤â´°Á´¤Ë¶ë·Á¤ò³°¤ì¤Æ¤¤¤ë¾ì¹ç ¤Ç¤¢¤ë¡£
; Àþʬ¤¬¶ë·ÁÆâ¤Ë¸ºß¤¹¤ë¤«¤É¤¦¤«¤òÄ´¤Ù¤ë
if (_IsCross(x2-x1,y2-y1,x-x1,y+h-y1,x+w-x1,y-y1)): return 1
if (_IsCross(x2-x1,y2-y1,x-x1,y-y1,x+w-x1,y+h-y1)): return 1
return 0
#global
; Äê¿ôÄêµÁ
#const KEYCODE_LCLICK 1 ; º¸¥¯¥ê¥Ã¥¯¤Î¥¡¼¥³¡¼¥É
#const KEYCODE_RCLICK 2 ; ±¦¥¯¥ê¥Ã¥¯¤Î¥¡¼¥³¡¼¥É
*start
; ÊÑ¿ôÄêµÁ
rect = 200, 200, 240, 80 ; ¶ë·Á¤Î x, y ºÂɸ¤ÈÉý¤È¹â¤µ
pt1 = 100, 50 ; Àþʬ¤ÎüÅÀ¡ (x,y)
pt2 = 540, 50 ; Àþʬ¤ÎüÅÀ¢ (x,y)
result = 0 ; ¸òº¹È½Äê¤Î·ë²Ì
; ¥¿¥¤¥È¥ëÀßÄê
title "º¸¡¦±¦¥¯¥ê¥Ã¥¯¤ÇÀþʬ¤ÎüÅÀ¡¡¦¢¤ò°ÜÆ°"
*main
gosub *update
gosub *output
await 20
goto *main
*update
; ¥¯¥ê¥Ã¥¯¸¡½Ð¡õ°ÜÆ°
getkey isClick, KEYCODE_LCLICK
if (isClick): pt1 = mousex, mousey
getkey isClick, KEYCODE_RCLICK
if (isClick): pt2 = mousex, mousey
; Àþʬ¤È¶ë·Á¤Î¸òº¹È½Äê
result = IsOverlappedSegmentToRect(pt1(0),pt1(1),pt2(0),pt2(1),rect(0),rect(1),rect(2),rect(3))
return
*output
; ÉÁ²èÈ¿±Ç¶Ø»ß
redraw 0
; ²èÌÌ¥¯¥ê¥¢
color 255, 255, 255
boxf
; ¶ë·ÁÉÁ²è
color 204, 204, 240
boxf rect(0), rect(1), rect(2)+rect(0)-1, rect(3)+rect(1)-1
; ÀþʬÉÁ²è
color 0, 0, 0
line pt2(0), pt2(1), pt1(0), pt1(1)
pos pt1(0), pt1(1): mes "¡"
pos pt2(0), pt2(1): mes "¢"
; ¸òº¹È½Äê¤Î·ë²Ì¤òÉÁ²è
pos 0, 0
if (result) {
mes "ȽÄê·ë²Ì: ¸òº¹¤·¤Æ¤¤¤ë"
} else {
mes "ȽÄê·ë²Ì: ¸òº¹¤·¤Æ¤¤¤Ê¤¤"
}
; ÉÁ²èÈ¿±Ç
redraw 1
return
| |
|