
'#compact
$ filename "t.exe"
'uses rtl32
'uses rtl64
uses ../GDIWindow/window.inc


Window "Knobs",400,300,2

sys sxMouse,syMouse

class Knob
  '
  sys px,py,sx,sy     'position and sensing-size
  single sens,sang,ang
  '
  method pos() as sys
  if MouseButton=1 then
    if sxMouse>=px-sx and sxMouse<=px+sx then
    if syMouse>=py-sy and syMouse<=py+sy then
      ang=sang+(xMouse-sxMouse+yMouse-syMouse)*sens
      if ang>6 then ang=6
      if ang<0 then ang=0
    end if
    end if
  elseif MouseButton=0 then
    sang=ang
  end if
  end method
  '
  method show() as sys
  Oval px-sx, py-sy, sx*2, sy*2, 255,0,200
  Line px,py,px+sx*sin(ang),py-sy*cos(ang),2,200,200,200
  end method
  '
  method fvalue() as single
  return ang*.166667
  end method
  '
  method bvalue() as sys
  return 255*ang*.166667
  end method
  '
end class


knob c1<=(100,100,25,15,.075)
knob c2<=(100,150,25,15,.075)
knob c3<=(100,200,25,15,.075)


While AscKey=0 and WinExit=0
ClsColor c1.bvalue,c2.bvalue,c3.bvalue
if mouseButton=0 then
  sxMouse=xMouse
  syMouse=yMouse
end if
c1.pos : c1.show
c2.pos : c2.show
c3.pos : c3.show
FlipBuffer
WaitFPS 60
Wend
