## 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: Klaus, FourthWorld, heatherlaine, kevinmiller

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

### Re: Rotating a graphic 360degrees in 60s

Bernd.

Since you are setting the points of the oval graphic at its circumference, aren't you still limited by the resolution of pixels along that circumference?

The advantage of using changes in a rect is that the endpoint pixels can be so far away from the origin that when the computer draws the line, the portion near that origin (out to the circumference of the clock) seems to move much less. We are interested at only the first portion of the graphic. If we could mask the rest of it, we would get a very smooth second hand in the small area of interest.

We do not easily see the jaggeedness of that line, a staircase if you use a magnifying glass, we only see the overall slope, which is definitely changing in steps far finer than single degrees set at the circumference.

Craig
Last edited by dunbarx on Thu Nov 12, 2020 11:23 pm, edited 1 time in total.

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

### Re: Rotating a graphic 360degrees in 60s

I cannot think of a way to make the long-line gadget.

I can make a clock face out of a circle grc and a line graphic of great length with its starting point at the center of the circle to act as the second hand. In this way I can set the rect of the line grc so that it changes VERY smoothly at the rate of a typical second hand.

But how does one mask the area outside the circle? There is no "empty hole" graphic that I can overlay over the clock face. The whole point of this gadget is that most of the second hand is hidden, with only the portion inside the clock face visible.

Paint white everywhere outside the clock face?

Craig

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

### Re: Rotating a graphic 360degrees in 60s

Craig,

I set a line graphic, not to the points of an oval graphic but to an imaginary point of a crircle with a radius of 200 pixel.
That way I can generate a point at that distance that accepts decimal degrees from the milliseconds.

The oval graphic has no points.

I am hiding the length of the line graphic via a complicated setting of inks.

Kind regards
Bernd

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

### Re: Rotating a graphic 360degrees in 60s

Aha.

So you are doing the same thing, using distant points, whereas I am using distant third and fourth items of a rect.

The masking of the outside of the "clock" object is what I will examine when I get a chance.

Craig

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

### Re: Rotating a graphic 360degrees in 60s

I haven't checked whether it/they have any similar techniques, look/feel or smoothness, but maybe one of Hermann's clock gizmos has something to investigate? Eg http://forums.livecode.com/viewtopic.ph ... 98#p146898

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

### Re: Rotating a graphic 360degrees in 60s

SparkOut wrote:
Fri Nov 13, 2020 8:50 am
I haven't checked whether it/they have any similar techniques, look/feel or smoothness, but maybe one of Hermann's clock gizmos has something to investigate? Eg http://forums.livecode.com/viewtopic.ph ... 98#p146898
Those are LCB-widgets and it is easy to do this kind of stuff in Livecode Builder because LCB can do subpixel resolution natively.
All the workarounds in Livecode Script for this type of usage are due to the lack of sub pixel resolution

Kind regards
Bernd

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

### Re: Rotating a graphic 360degrees in 60s

Craig,

here is a way to hide part of a line graphic that does not use inks. It is a lot easier to handle.

drawSecondsHandClock2.livecode.zip

Kind regards
Bernd

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

### Re: Rotating a graphic 360degrees in 60s

For anyone interested in analog clocks:

I uploaded a "railwayclock" to Livecode share/Sample Stacks

http://livecodeshare.runrev.com/stack/978/railwayclock

have fun
Bernd

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

### Re: Rotating a graphic 360degrees in 60s

Aw, Bernd.

That is one of the most clever and adorable kludges I have ever seen, and I consider myself an inveterate Kludger.

To set the dashes of a line graphic to a wide value that permits only the first one to be visible on the card window.

Just lovely.

Craig

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

### Re: Rotating a graphic 360degrees in 60s

Craig,

Thank you, I feel honored.

Kind regards
Bernd

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

### Re: Rotating a graphic 360degrees in 60s

I just discovered that neither the solid nor the blank portion of a line graphic can be greater than 250. You cannot have more than "250,250".

So there is a limit to how big this thing can be built. There is no limit to distance to the points (or rect) but there is a limit to the maximum visible size of the second hand.

Hardly matters...

Craig
Last edited by dunbarx on Sat Nov 14, 2020 12:08 am, edited 1 time in total.

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

### Re: Rotating a graphic 360degrees in 60s

Good to know.

I found in my use case a diamter of 200 pixel gives a very nice resolution for the angle and makes for a smooth motion. So in this case I would never hit the 250 limit.
I did find that "dashes" do not like decimals, only integers. Had me scratch my head when dynamically adjusting "dashes" based on current position in a true ellipse.

Kind regards
Bernd

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

### Re: Rotating a graphic 360degrees in 60s

Since we are both still wasting time on this, however much fun it is, I had hoped that creating a very large regular polygon of 3600 sides would give me 3600 points, and I could get some serious resolution without having to make them trigonometrically. Lazy, you know. But only irregular polygons have points, so that did not work.

I knew that so many points, even with a large polygon, might force some adjacent points to the same value. But that would not have mattered, since I was only using every tenth one.

Craig

EDIT.
since I was only using every tenth one.
Nope. Using every one, or the whole idea of using so many is silly. It does not matter if, with so many, some iterations do not rotate the second hand. The final resultant motion will be very smooth.
Last edited by dunbarx on Fri Nov 13, 2020 8:18 pm, edited 4 times in total.

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

### Re: Rotating a graphic 360degrees in 60s

Craig,

Code: Select all

``````put 600 into semiMajorAxis
set 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.

Kind regards
Bernd

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

### Re: Rotating a graphic 360degrees in 60s

dunbarx wrote:
Fri Nov 13, 2020 8:02 pm
Since we are both still wasting time on this, however much fun it is, I had hoped that creating a very large regular polygon of 3600 sides would give me 3600 points, and I could get some serious resolution without having to make them trigonometrically. Lazy, you know. But only irregular polygons have points, so that did not work.

Craig
how about the effective points of the regular polygon?

Kind regards
Bernd