Rotating a graphic 360degrees in 60s

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9655
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Rotating a graphic 360degrees in 60s

Post by dunbarx » Fri Nov 13, 2020 8:14 pm

Yikes.

That worked. Great idea. "Points" is not included in the dictionary list of "effective" properties. It certainly should be. And the main purpose of the keyword itself is to allow a control to distinguish either inherited properties or locally set ones. I wonder what other properties there are that are not on that list.

Even with a 3600 side graphic that is 40 cm in diameter some adjacent points are duplicated.

I wonder if the OP is still watching this.

Craig

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: Rotating a graphic 360degrees in 60s

Post by SparkOut » Fri Nov 13, 2020 10:20 pm

dunbarx wrote:
Fri Nov 13, 2020 8:14 pm
I wonder if the OP is still watching this.

Craig
Well, there's still an interested audience whether or not the OP is continuing with it.

I got popcorn and everything.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9655
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Rotating a graphic 360degrees in 60s

Post by dunbarx » Sat Nov 14, 2020 12:15 am

Bernd.

[quoteset the dashes of grc "hand" to the width of grc "ellipse"/2 - 35,250,0,250,0

]lets me hide a 600 pixel long line graphic except for the first part. So it seems that the limit applies to the dash interval not the absolute length of the hidden part of the line.[/quote]

What you did was set the width of the first solid dash, then a nice long blank, then a 0 width second dash, then another long blank, etc. So you kludged a solid, then two 250-limited blanks with "no" solid in between.

Nice.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9655
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Rotating a graphic 360degrees in 60s

Post by dunbarx » Sat Nov 14, 2020 1:22 am

So here is a down and dirty second hand. It does not exactly make one revolution per minute. That needs refinement of the effective points of the large graphic, whereas right now it is using a simple wait command. It uses the "rect" method.

But it is pretty smooth.

Craig
second hand.livecode.zip
(1.29 KiB) Downloaded 156 times

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3997
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Rotating a graphic 360degrees in 60s

Post by bn » Sat Nov 14, 2020 1:51 am

Craig,

That moves very smoothly. Nice.

I occured to me that a clockface could be oval. For that I did a version that dynamically changed dashes to let the seconds hand keep the same distance from the ellipse. That however ran into the 1 pixels problem (rounding problem) and one noticed a change in distance by 1 pixel while moving.

I gave up on dashes and decided a strokeGradient would be smoother. Which in fact it turned out to be.
I set a radial stroke gradient that has the coordinates of the ellipse and which has a gradient stop that is transparent. That cuts the handle visually off and adapts smoothly to the ellipse when changing length of handle.

For me that is the most versatile solution regarding display of seconds smoothly on a round or oval clock face.

(change graphic "ellipse" to see the effect.)

drawSecondsHandClock4.livecode.zip
(2.09 KiB) Downloaded 138 times

Kind regards
Bernd

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9655
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Rotating a graphic 360degrees in 60s

Post by dunbarx » Sat Nov 14, 2020 5:23 pm

Bernd.

So much fun.

There is an issue with an ellipse, in that the rotational speed of the hand is greater near the major axis and slows as it approaches the minor axis.

I am going to try to find a way (just because, since I do not know if the OP cares about it) to make the circular second hand actually take exactly one minute per revolution. No "wait" gadget will, on its own, do. I will try to set the endpoint changes based on interrogating the milliseconds, or maybe even the long milliseconds, and take a "step" based on those values. Should be easy, but I hope it will not introduce any visible jerkiness.

Craig

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3997
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Rotating a graphic 360degrees in 60s

Post by bn » Sat Nov 14, 2020 5:51 pm

dunbarx wrote:
Sat Nov 14, 2020 5:23 pm
Bernd.

So much fun.

There is an issue with an ellipse, in that the rotational speed of the hand is greater near the major axis and slows as it approaches the minor axis.

I am going to try to find a way (just because, since I do not know if the OP cares about it) to make the circular second hand actually take exactly one minute per revolution. No "wait" gadget will, on its own, do. I will try to set the endpoint changes based on interrogating the milliseconds, or maybe even the long milliseconds, and take a "step" based on those values. Should be easy, but I hope it will not introduce any visible jerkiness.

Craig
Craig,

The examples I posted are synchronized using the milliseconds to exactly take one minute to complete the round trip. They are exact to the second.

The last one is easy to integrate into the "clock" Glenn (the OP) was referring to.


There is an issue with an ellipse, in that the rotational speed of the hand is greater near the major axis and slows as it approaches the minor axis.
I thought it was a feature... :) That is easy to change by setting the "To" and "via" of the stroke gradient. Change the -- marked comments

Code: Select all

 ## give grc hand a strokeGradient that limits its visibility and adapts to ellipse
      put "radial" into tArray["type"]
      put x0,y0 into tArray["from"]
      
      put min(the right of graphic "ellipse" - x0, the bottom of grc "ellipse" - y0) into tMinExtend -- add this
      
      put x0, y0 + tMinExtend into tArray["to"] --  change this
      put x0 + tMinExtend, y0 into tArray["via"] -- change  this
      
      --      put x0,the bottom of graphic "ellipse" into tArray["to"] -- block this
      --      put the right of graphic "ellipse", y0  into tArray["via"] -- block this
      
      ## define two gradient stops
Kind regards
Bernd

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”