|
Post by honky on May 22, 2023 12:34:23 GMT
Good morning, I have horizontal lines every 20 pixels. With Py = MouseY, I place a box. (which falls where I click: 132, 145, 157 ... ect ...) I would like the box to be placed with a step of 10 pixels 130 140 150. How to do ? Thank you for.
|
|
|
Post by tsh73 on May 22, 2023 13:22:06 GMT
Have a look
nomainwin open "Do some clicks" for graphics_nsb_nf as #gr #gr "trapclose [quit]" #gr "down"
#gr "home" #gr "posxy cx cy"
for y = 20 to 2*cy step 20 #gr "line ";0;" "; y;" "; 2*cx;" "; y next
#gr "flush" #gr "when leftButtonUp [draw]" wait
[draw] ch=20 cw=10 ' MouseX; " "; MouseY 'ajust them to 10 mx= 10*int(MouseX/10) my= 10*int(MouseY/10) #gr "place ";mx;" ";my #gr "\";mx;",";my #gr "place ";mx;" ";my #gr "box ";mx+cw*len(mx;",";my);" ";my-ch wait
[quit] close #gr end
|
|
|
Post by honky on May 22, 2023 14:16:13 GMT
It's work fine. Thank you tsh73
|
|
|
Post by flobert on Jun 13, 2023 9:28:30 GMT
|
|
|
Post by plus on Jun 13, 2023 11:15:26 GMT
Fine tuned, stepping 20 and putting boxes between the lines. nomainwin open "Do some clicks" for graphics_nsb_nf as #gr #gr "trapclose [quit]" #gr "down"
#gr "home" #gr "posxy cx cy"
for y = 20 to 2*cy step 20 #gr "line ";0;" "; y;" "; 2*cx;" "; y next
#gr "flush" #gr "when leftButtonUp [draw]" wait
[draw] ch=20 cw=10 ' MouseX; " "; MouseY 'ajust them to 10 mx= 10*int(MouseX/10) my= 20*int(MouseY/20)+ 20 #gr "place ";mx+12;" ";my-3 #gr "\";mx;",";my #gr "place ";mx;" ";my+1 #gr "box ";mx+cw*len(mx;",";my);" ";my-ch wait
[quit] close #gr end
|
|