Page 1 of 1
I can`t get a line to rotate!
Posted: Thu Jan 16, 2025 11:05 am
by glenn9
Hi everyone,
I'm trying to get a line to rotate with the following code
Code: Select all
on mouseUp
rotateLine
end mouseUp
on rotateLine
put the angle of graphic "myLine" into tCurrentAngle
add 10 to tCurrentAngle
set the angle of graphic "myLine" to tCurrentAngle
end rotateLine
but the line refuses to move an inch!
My interpretation of the dictionary is that the line should move but I`m getting the impression that a line may not be a moveable object???
Grateful for any help.
Regards,
Glenn
Re: I can`t get a line to rotate!
Posted: Thu Jan 16, 2025 11:35 am
by Klaus
Hi Glenn,
from the dioctionar about "angle":
Specifies the starting angle of an arc or the rotation angle of a regular polygon or image.
So your "line" is probably not a "regular polygon", is it?
You can only set the end- and startpoint of your line.
Best
Klaus
Re: I can`t get a line to rotate!
Posted: Thu Jan 16, 2025 11:37 am
by richmond62
This is because a line graphic is defined with points:
-
-
One of the ways to get this sort of thing to work would be to import a snapshot of your line (so you would have an image) and rotate that: although in my experience the whole thing would deteriorate fairly rapidly.
Re: I can`t get a line to rotate!
Posted: Thu Jan 16, 2025 11:48 am
by glenn9
Thank you both, now understand! Regards, Glenn
Re: I can`t get a line to rotate!
Posted: Sat Jan 18, 2025 12:33 am
by RogGuay
Here is a mathematical solution. For some reason, this works in LC 9.6.13 but not in 9.610
Re: I can`t get a line to rotate!
Posted: Sat Jan 18, 2025 9:15 am
by richmond62
Works wonderfully in LC 9.6.3 Community!
And "elsewhere".

Re: I can`t get a line to rotate!
Posted: Sat Jan 18, 2025 4:36 pm
by bn
RogGuay wrote: ↑Sat Jan 18, 2025 12:33 am
Here is a mathematical solution.
For some reason, this works in LC 9.6.13 but not in 9.610
Hi Roger,
The culprit is the scrollbar. It started to behave strange (at least on Mac) with newer system version and arm. It has to do with the start value of a player being greater that the end value. Then the pageInc of a scrollbar acted funnily.
There is a bug report by Stam
https://quality.livecode.com/show_bug.cgi?id=24436
If you change the scrollbar into a horizontal scrollbar starting from 1 to 360 and save that then it works in LC 9.6.10 for me. Otherwise it crashes LC 9.6.10. I am using an M1 arm Mac Sequoia 15.2.
The good news is that this seems to have been sorted out and your stack works 9.6.13 and 10.0.1 (rc3) for me.
And thanks for posting a mathematical solution which helps me a lot since I must have missed that part of math in school.
Kind regards
Bernd
Re: I can`t get a line to rotate!
Posted: Sat Jan 18, 2025 9:05 pm
by bogs
Um, there is always this...
Code: Select all
on mouseUp
rotateLine
end mouseUp
on rotateLine
repeat 360 times
revRotatePoly the long id of graphic "Line", 1
wait 1
end repeat
end rotateLine
... which will certainly rotate your line. As for your other code, I was unable to produce a result with it regardless. I don't think the other explanations in here cover it (i.e., a rectangle would certainly fall under a regular polygon, and certainly still has points as it's main attribute), but your code did not rotate the rectangle I tested with here, so it may be something else at play.
*Edit - apparently there is some difference between what LC considers a 'regular polygon', and an n-gon, such as a rectangle. If you choose the polygon from the draw library, however, your code will rotate
that for sure.
Re: I can`t get a line to rotate!
Posted: Sat Jan 18, 2025 11:43 pm
by RogGuay
Thanks, Bogs. I thought I had tried that, and it didn't work. Not the first time I've made mistakes!!
And thank you, Bernd for your finding on the scrollbar. It seems like I have long experienced problems with LC's scrollbar. + they're ugly. That's why I usually roll my own and have built a "ScrollbarLab" stack, here for anyone's use if wanted
Re: I can`t get a line to rotate!
Posted: Sun Jan 19, 2025 9:48 am
by bn
Thank you Roger for the scrollbars. They look very nice and work very well.
Kind regards
Bernd
Re: I can`t get a line to rotate!
Posted: Sun Jan 19, 2025 11:55 pm
by RogGuay
Thank you, Bernd.
I discovered a couple of problems with the horizontal option on card 2.
Here is an updated copy that fixes them
Cheers Roger
Re: I can`t get a line to rotate!
Posted: Mon Jan 20, 2025 12:40 pm
by EMR
I have used the command revRotatePoly to rotate a line. The dictionary says you can also rotate a curve or irregular polygon.
Eric R
Re: I can`t get a line to rotate!
Posted: Mon Jan 20, 2025 1:09 pm
by bn
RogGuay wrote: ↑Sun Jan 19, 2025 11:55 pm
I discovered a couple of problems with the horizontal option on card 2.
Here is an updated copy that fixes them
Hi Roger,
Thank you for updating the stack.
I had overlooked the option for a horizontal scrollbar/scroller. The "V" and "H" at the bottom left are easy to overlook. I would suggest to make them more prominent.
The button "Copy to your Stack" on card 2 (horizontal) references the vertical group on card 1 and not the horizontal group on card 2.
Kind regards
Bernd
Re: I can`t get a line to rotate!
Posted: Mon Jan 20, 2025 11:55 pm
by RogGuay
Hi Bernd,
I'm so sorry to have missed those and I thank you for finding them Here is the update:
Many cheers,
Roger
Re: I can`t get a line to rotate!
Posted: Tue Jan 21, 2025 9:45 am
by Klaus
Hi Roger,
very cool, thanks!
Maybe you can post this also in the "Made with LC" forum:
viewforum.php?f=143
Seems too hidden here in this forum "I can`t get a line to rotate!", know what I mean?
Best
Klaus