Rotating Graphics
Dar Scott
dsc at swcp.com
Fri Mar 5 12:03:08 EST 2004
On Friday, March 5, 2004, at 09:28 AM, Springer, Paul wrote:
> Thanks for the help. As a beginner with RR, I need a little
> clarification.
It is I who needs to be clear.
> 1. When you say "Rotate that." Do you mean with a built in command or
> with a
> custom command that is re-calculating where the points should be?
Custom command or function. Like this:
function rotateAboutPoint centerPoint, pointList -- returns point list
set the numberFormat to "0.###########"
...
end rotateAboutPoint
...
put the exactPoints of graphic "Space Hog 1" into hPoints
put rotateAboutPoint( spaceStationLoc, hPoints ) into hPoints
set the exactPoints of graphic "Space Hog 1" to hPoints
...
> 2. Aren't there points already defined for the polygons vertices?
Yes.
> Do I need
> to somehow use my custom properties instead of those?
Yes and maybe no.
My guess is that you are seeing a drift and shrink because of
truncation. Since the points for a polygon must be whole numbers the
accumulated errors show quickly. The use of a custom property to hold
points allows greater precision and much, much less drift.
You don't have to hold them in a custom property. You can keep them in
a global array with one set of points for each polygon. You don't have
to use a setProp, you can explicitly create the (rounded) points from
the exactPoints each time you change the points.
If you rotate images or groups, too, you might want to set things up so
that you send a command of yours to the control and the control knows
how to rotate itself.
Another benefit of this method is that you can make very small changes
that do not affect the display, but will add up.
Dar Scott
More information about the use-livecode
mailing list