Sync On
Set Display Mode 800, 600, 32
Set Window On
Randomize Timer()
 
getImages
Dim Color(2)
CLS RGB( 255, 255, 255 )
 
Do
 
   drawPanel
 
   If MouseClick() =0
      newX = MouseX()
      newY = MouseY()
      oldX = newX
      oldY = newY
   EndIf
 
   If MouseClick() =1
      newX = MouseX()
      newY = MouseY()
      Ink RGB( Color(0), Color(1), Color(2) ), 0
      Line oldX, oldY, newX, newY
      oldX = newX
      oldY = newY
   EndIf
 
Sync : Loop
 
Function getImages()
   ` get color select thingie
   For x = 0 To 50
      For y = 0 To 50
         Ink RGB( x*2.5+y*2.5, 0, 0 ), 0  :  Dot x, y
         Ink RGB( 0, x*2.5+y*2.5, 0 ), 0  :  Dot x+50, y
         Ink RGB( 0, 0, x*2.5+y*2.5 ), 0  :  Dot x+100, y
         Ink RGB( x*2.5+y*2.5, x*2.5+y*2.5, x*2.5+y*2.5 ), 0  :  Dot x+150, y
      Next y
   Next x
   Get Image 1, 0, 0, 200, 50
EndFunction
 
 
Function drawPanel()
   ` panel
   Ink RGB(199,196,158), 0
   Box 0, 0, Screen Width()-1, 50
   ` buttons
   If button( 225, 5, "Clear Screen" ) =1 Then CLS RGB( 255, 255, 255 )
   If button( 225, 25, "Save Image" ) =1
      Get Image 60, 0, 51, Screen Width()-1, Screen Height()-1
      Save Image "c:/image.bmp", 60
      Delete Image 60
   EndIf
   ` paste color select thingie
   Paste Image 1, 0, 0
   ` get draw color
   If MouseClick() =1
      If MouseX() <= 200 And MouseY() <= 50
         Color(0) = RGBR( Point( MouseX(), MouseY() ) )
         Color(1) = RGBG( Point( MouseX(), MouseY() ) )
         Color(2) = RGBB( Point( MouseX(), MouseY() ) )
      EndIf
   EndIf
   ` preview of selected color
   Ink RGB( Color(0), Color(1), Color(2) ), 0
   Box 400, 5, 445, 45
EndFunction
 
 
Function button( x, y, s$ )
   pressed =0
   Ink RGB( 000, 000, 000 ), 0 : Box x-1, y-1, x+Text Width( s$ )+1, y+Text Height( s$ )+1
   Ink RGB( 199, 196, 158 ), 0 : Box x, y, x+Text Width( s$ ), y+Text Height( s$ )
   Ink RGB( 000, 000, 000 ), 0 : Text x, y, s$
   If MouseX() > x And MouseX() < x+Text Width( s$ )+1
      If MouseY() > y And MouseY() < y+Text Height( s$ )+1
         If MouseClick() =1 Then pressed =1
      EndIf
   EndIf
EndFunction pressed