
#compact
$ filename "t.exe"
'uses RTL32
'uses RTL64
uses Controls

class ColorDialogBox
====================
  '
  DialogBox d1
  Slider    s1,s2,s3,s4,s5,s6
  sys       r,g,b,h,l,s,p,q
  sys       RgbZone,HcsZone
  '
  method constructor()
  int i
  d1<=40,50,280,300,"Background Colors"
  s1<=100,100,10,15,50,150,100,100,"Red"
  s2<=100,140,10,15,50,150,140,140,"Green"
  s3<=100,180,10,15,50,150,180,180,"Blue"
  s4<=100,220,10,15,50,150,220,220,"Hue"
  s5<=100,260,10,15,50,150,260,260,"Luminance"
  s6<=100,300,10,15,50,150,300,300,"Saturation"
  s4.sc=240 'show scale
  s5.sc=240 'show scale
  s6.sc=240 'show scale
  end method
  '
  method destructor
  end method
  '
  method set()
  s1.set
  s2.set
  s3.set
  s4.set
  s5.set
  s6.set
  end method
  '
  method show()
  d1.show
  s1.show
  s2.show
  s3.show
  s4.show
  s5.show
  s6.show
  end method
  '
  method anchor()
  d1.anchor
  s1.anchor
  s2.anchor
  s3.anchor
  s4.anchor
  s5.anchor
  s6.anchor
  end method

  method move()
  d1.move(xMouse-sxMouse,yMouse-syMouse)
  int tx=d1.px-d1.spx
  int ty=d1.py-d1.spy
  s1.move tx,ty
  s2.move tx,ty
  s3.move tx,ty
  s4.move tx,ty
  s5.move tx,ty
  s6.move tx,ty
  end method
  '
  method HcsFeedback(sys c)
  ColorRGBToHLS c,h,l,s
  s4.fset h,240
  s5.fset l,240
  s6.fset s,240
  end method
  '
  method RgbFeedback(sys c)
  r=c and 255
  shr c,8
  g=c and 255
  shr c,8
  b=c and 255
  s1.bset r
  s2.bset g
  s3.bset b
  end method
  '
  method GetHcsColor() as sys
  h=s4.fget 240
  l=s5.fget 240
  s=s6.fget 240
  return ColorHLStoRGB h,l,s
  end method
  '
  method GetRgbColor() as sys
  return s1.bget()+s2.bget()*0x100+s3.bget()*0x10000
  end method
  '
  method zone() as sys
  return d1.zone
  end method
  '
  method zones(sys *RgbZone,*HcsZone)
  RgbZone=s1.zone()+s2.zone()+s3.zone()
  HcsZone=s4.zone()+s5.zone()+s6.zone()
  end method
  '
  method action()
  if mouseButton=0
    anchor
    q=0
  end if
  if q
    move
  elseif MouseButton
    set
    zones RgbZone,HcsZone
    if RgbZone then
      HcsFeedback GetRgbColor
    elseif HcsZone
      RgbFeedback GetHcsColor
    elseif zone
      q=1
    end if
  end if
  show
  end method
  '
end class

new ColorDialogBox cdb

do
  if EscKey then exit do
  if mouseButton=0
    sxMouse=xMouse
    syMouse=yMouse
  endif
  ClsColor cdb.GetRgbColor
  cdb.action
  FlipBuffer
  if MouseButton or AscKey
    sleep 10
  else
    sleep 100
  endif
end do

del cdb

