Change the color with 4 clicks.
Code: Select all
#cmdline "-s gui"
screen 0 'Useful in Linux with a slow terminal
windowtitle "MouseFlip"
dim as long x,y,buttons,result,windowsize,imagesize
windowsize = 400
windowsize -= (windowsize mod 2)
imagesize = (windowsize\2)-1
screenres windowsize,windowsize,32
dim as byte ptr image(1 to 2)
image(1) = imagecreate(imagesize,imagesize,rgb(127,255,0))
image(2) = imagecreate(imagesize,imagesize,rgb(255,127,0))
line image(1),(0,0)-(imagesize,imagesize),0,B
line image(2),(0,0)-(imagesize,imagesize),0,B
dim as byte c(0 to 3)
do
put (0,0),image(c(0)+2),pset
put (0,imagesize+1),image(c(1)+2),pset
put (imagesize+1,0),image(c(2)+2),pset
put (imagesize+1,imagesize+1),image(c(3)+2),pset
result = getmouse (x,y,,buttons)
if (result = 0) and (buttons <> 0) then
if (x < imagesize+1) and (y < imagesize+1) then c(0) = not(c(0)) : c(1) = not(c(1)) : c(2) = not(c(2))
if (x > imagesize+1) and (y < imagesize+1) then c(0) = not(c(0)) : c(2) = not(c(2)) : c(3) = not(c(3))
if (x < imagesize+1) and (y > imagesize+1) then c(0) = not(c(0)) : c(1) = not(c(1)) : c(3) = not(c(3))
if (x > imagesize+1) and (y > imagesize+1) then c(1) = not(c(1)) : c(2) = not(c(2)) : c(3) = not(c(3))
end if
do
result = getmouse (x,y,,buttons)
sleep 10,1
loop until (result <> 0) or (buttons = 0)
loop until len(inkey)
imagedestroy image(1)
imagedestroy image(2)
end