Author Topic: Knob Controls  (Read 1505 times)

0 Members and 2 Guests are viewing this topic.

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3581
    • Oxygen Basic
Knob Controls
« on: April 03, 2012, 09:29:55 AM »
Using the same technique as sliders.

Click and drag to turn them.

Code: [Select]
include ""

Window "Knobs",400,300,2

sys sxMouse,syMouse

class Knob
  sys px,py,sx,sy     'position and sensing-size
  single sang
  single 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
      if ang>6 then ang=6
      if ang<0 then ang=0
    end if
    end if
  elseif MouseButton=0 then
  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)
knob c2<=(100,150,25,15)
knob c3<=(100,200,25,15)

While AscKey=0 and WinExit=0
ClsColor c1.bvalue,c2.bvalue,c3.bvalue
if mouseButton=0 then
end if
c1.pos :
c2.pos :
c3.pos :
WaitFor 60