include "sdl.inc"

SetDisplay 640,480,1
SetCaption "MouseZone Demo"
SetColorKey 255,0,255

sys p1, byte r,g,b
p1=LoadImage "bmp/font20x.bmp",94

While Key(27)=0 
ClsColor 0,0,255
Rectangle 100,100,200,300, 0,255,0
Paint 450, 50,100,100, 255,50,100
Paint 470,100,100,100, 255,150,10
Paint 490,150,100,100, 55,250,150
Paint 510,200,100,100, 155,250,250

iF MouseButton=1 and MouseZone 450,50,610,300
   int color
   DrawText p1,xMouse-5,yMouse-10,"OK"
   color = GetPixel xMouse,yMouse
   r= GetColorR color
   g= GetColorG color
   b= GetColorB color
End iF

iF MouseZone 100,100,300,400 
   DrawText p1,0,0, "xMouse " + xMouse + " yMouse " + yMouse
   iF MouseButton=1 
      Paint 101,101,196,296, r,g,b
      DrawText p1,100,410,"OKAY,FILLED"
   End iF   
End iF

Flip
SetFps 60
Wend
Ends