I can`t get a line to rotate!

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

Post Reply
glenn9
Posts: 234
Joined: Wed Jan 15, 2020 10:45 pm

I can`t get a line to rotate!

Post by glenn9 » Thu Jan 16, 2025 11:05 am

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

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: I can`t get a line to rotate!

Post by Klaus » Thu Jan 16, 2025 11:35 am

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

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: I can`t get a line to rotate!

Post by richmond62 » Thu Jan 16, 2025 11:37 am

This is because a line graphic is defined with points:
-
SShot 2025-01-16 at 12.35.26.png
-

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.
Last edited by richmond62 on Thu Jan 16, 2025 12:12 pm, edited 1 time in total.

glenn9
Posts: 234
Joined: Wed Jan 15, 2020 10:45 pm

Re: I can`t get a line to rotate!

Post by glenn9 » Thu Jan 16, 2025 11:48 am

Thank you both, now understand! Regards, Glenn

RogGuay
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 122
Joined: Fri Apr 28, 2006 12:10 am

Re: I can`t get a line to rotate!

Post by RogGuay » 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
Attachments
RotatingLine.livecode.zip
(1.17 KiB) Downloaded 773 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: I can`t get a line to rotate!

Post by richmond62 » Sat Jan 18, 2025 9:15 am

Works wonderfully in LC 9.6.3 Community!

And "elsewhere". 8)

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: I can`t get a line to rotate!

Post by bn » Sat Jan 18, 2025 4:36 pm

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

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: I can`t get a line to rotate!

Post by bogs » Sat Jan 18, 2025 9:05 pm

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.
Image

RogGuay
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 122
Joined: Fri Apr 28, 2006 12:10 am

Re: I can`t get a line to rotate!

Post by RogGuay » Sat Jan 18, 2025 11:43 pm

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

ScrollbarLab.livecode.zip
(11.6 KiB) Downloaded 755 times
Screenshot 2025-01-18 at 2.31.22 PM.png

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: I can`t get a line to rotate!

Post by bn » Sun Jan 19, 2025 9:48 am

Thank you Roger for the scrollbars. They look very nice and work very well.

Kind regards
Bernd

RogGuay
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 122
Joined: Fri Apr 28, 2006 12:10 am

Re: I can`t get a line to rotate!

Post by RogGuay » Sun Jan 19, 2025 11:55 pm

Thank you, Bernd.

I discovered a couple of problems with the horizontal option on card 2.

Here is an updated copy that fixes them
ScrollbarLab.livecode.zip
(13.04 KiB) Downloaded 778 times
Cheers Roger

EMR
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 4
Joined: Wed Jun 14, 2006 12:24 pm

Re: I can`t get a line to rotate!

Post by EMR » Mon Jan 20, 2025 12:40 pm

I have used the command revRotatePoly to rotate a line. The dictionary says you can also rotate a curve or irregular polygon.

Eric R

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: I can`t get a line to rotate!

Post by bn » Mon Jan 20, 2025 1:09 pm

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

RogGuay
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 122
Joined: Fri Apr 28, 2006 12:10 am

Re: I can`t get a line to rotate!

Post by RogGuay » Mon Jan 20, 2025 11:55 pm

Hi Bernd,

I'm so sorry to have missed those and I thank you for finding them Here is the update:
ScrollbarLab.livecode.zip
(12.99 KiB) Downloaded 710 times
Many cheers,

Roger

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: I can`t get a line to rotate!

Post by Klaus » Tue Jan 21, 2025 9:45 am

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

Post Reply