I need a "slider" in a circle

Renato Muzzini muzzini at accmed.org
Tue Jul 4 17:24:03 CEST 2017


> Il giorno 04/lug/2017, alle ore 16:20, Todd Fabacher via use-livecode <use-livecode at lists.runrev.com> ha scritto:
> 
> Hello Livecode group,
> 
> I have a situation where we need a slider, not a straight line, but as a
> circle. I thing Scott Rossi did a demo of this at San Diego LC conference,
> but I can't find the code samples to check. I just need to restrict the
> movement to a circle when the user moves their finger. Maybe there is some
> kind of dial example somewhere???
> 
> All I am looking to do is move the slider in the semi-circle to move the
> value forward or backwards.
> 
> Thanks,
> 
> Todd




using math:

constant kDelay=10 //0,1,100…
local sMove
on mouseDown
   put true into sMove
   moveMe
end mouseDown

on mouseUp
   put false into sMove
end mouseUp

on mouseRelease
   put false into sMove
end mouseRelease

on moveMe
   if not(sMove) then exit moveMe
   put (the width of grc "circle")/2 into R
   put (item 1 of the loc of grc "circle") into x0
   put (item 2 of the loc of grc "circle") into y0
   put min(MAX(the mouseH, the left of grc "circle"), the right of grc "circle") into x
   put min(MAX(the mouseV, item 2 of the loc of grc "circle"), the bottom of grc "circle") into y
   put sqrt(R^2 - (x-x0)^2)+y0 into y
   set the loc of me to x,y
   put trunc(x),trunc(y) into fld "values"
   send "moveMe" to me in kDelay millisec
end moveMe

/*******
recipe:
- have an oval named "circle". and be it a circle…
- have a grc/img with the above script
- have a field named "values", just to collect the values
- adjust kDelay for your needs
- feel free to hide the oval
- do what you need with values
********/


regards.
re.mu.




More information about the use-livecode mailing list