revRotatePoly

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Fermin
Posts: 142
Joined: Fri Jun 05, 2015 10:44 pm

revRotatePoly

Post by Fermin » Fri Apr 14, 2023 5:17 pm

Hi, can someone please help me?, I'm having a problem with revRotatePoly.
Every time I use it to preview a recently modified graphic object, a polygon I created earlier on that same object shows up. Can anyone help me figure out why this is happening? Thanks a lot.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: revRotatePoly

Post by richmond62 » Fri Apr 14, 2023 5:36 pm

I am not quite sure what you mean.

This seems to work alright:
-
SShot 2023-04-14 at 19.32.46.png
-
Apart from the distinctly non-intuitive:

Code: Select all

revRotatePoly the name of grc "P5", 20
which would be far, far better were it [pseudo]

Code: Select all

revRotatePoly grc "P5", 20
everything seems to work with no obvious problems.

But, then, I don't understand what you mean by this:
a polygon I created earlier on that same object shows up

Fermin
Posts: 142
Joined: Fri Jun 05, 2015 10:44 pm

Re: revRotatePoly

Post by Fermin » Fri Apr 14, 2023 6:00 pm

Thanks Richmond. In my case, adapting to your example, it would be something like this:

Let's say I modify the points of that graphic 'p5' so that instead of a pentagon it draws a square, for example. Okay, I would see the square then. However, as soon as I execute the same code again:

revRotatePoly the name of grc 'p5', 20

The square disappears and the pentagon reappears !!!

It's true that I'm not working with regular polygons, but rather transforming geographic coordinates from Google Earth, but I'm not sure why this is happening. It's very likely that it's some silly mistake on my part, but I've been at it for a while and can't figure out the problem

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: revRotatePoly

Post by richmond62 » Fri Apr 14, 2023 6:29 pm

SShot 2023-04-14 at 20.28.06.png
-
INDEED . . .

just the same "over here". :(
Attachments
ROLY_POLY 2.livecode.zip
Stack.
(1.28 KiB) Downloaded 56 times

Fermin
Posts: 142
Joined: Fri Jun 05, 2015 10:44 pm

Re: revRotatePoly

Post by Fermin » Fri Apr 14, 2023 6:50 pm

"Power to the squares!!! :shock:
... Anyway, nothing to do about it. Let's see if I can figure out the solution. :roll:

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

Re: revRotatePoly

Post by bn » Fri Apr 14, 2023 6:59 pm

Hi Fermin,

What happens is that revRotatePoly creates a custom property of the polygon the first time it is invoked.
The reason is that the points of the polygon are integers and when rotating integers they "degrade" very quickly. To alleviate that the points of the polygon are saved to the custom property of the graphic "realPoints" as real numbers, i.e. like 123.54321.

If you now repeat revRotatePoly after having changed the points of the graphic Livecode looks first at the custom property and uses the real number to rotate the graphic again.

You can avoid that by doing after changing the points of your graphic

Code: Select all

set the realPoints of graphic "myGraphic" to empty
and then do a revRotatePoly. The polygon will then use the new points for rotation.

Kind regards
Bernd

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: revRotatePoly

Post by richmond62 » Fri Apr 14, 2023 7:17 pm

I would just suppose this is where one has to get one's head
round effective points and real points . . . a bit like fake news. 8)

Fermin
Posts: 142
Joined: Fri Jun 05, 2015 10:44 pm

Re: revRotatePoly

Post by Fermin » Fri Apr 14, 2023 7:37 pm

Thank you, Richmond... and Thank you very much, Bernd!!! Understood, applied, and problem solved. :D

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: revRotatePoly

Post by richmond62 » Fri Apr 14, 2023 8:12 pm

Thank you very much, Bernd!!!
He always has 'a march' on the rest of us. 8)
Attachments
ROLY_POLY 3.livecode.zip
Stack.
(1.31 KiB) Downloaded 59 times

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

Re: revRotatePoly

Post by bn » Fri Apr 14, 2023 8:27 pm

richmond62 wrote:
Fri Apr 14, 2023 8:12 pm
Thank you very much, Bernd!!!
He always has 'a march' on the rest of us. 8)
As far as march is concerned:

My favorite radio ad from Pan Am was
Son, don't walk if you don't have to.

:)

Kind regards
Bernd

Post Reply

Return to “Talking LiveCode”