Button vs. Message box scripts;
Jim Hurley
jhurley at infostations.com
Tue Apr 1 08:14:01 EST 2003
>
>Message: 13
>Date: Sun, 30 Mar 2003 14:24:39 -0800
>To: use-revolution at lists.runrev.com
>From: "Jeanne A. E. DeVoto" <jeanne at runrev.com>
>Subject: Re: Button vs. Message box scripts; P.S. Invert matrices?
>Reply-To: use-revolution at lists.runrev.com
>
>At 6:54 AM -0800 3/28/03, Jim Hurley wrote:
>>On mouseUp
>>revrotatepoly graphic "MyPoly", 90
>>end mouseUp
>>
>>return an error: "Chunk source is not a container."
>
>The problem here is that revRotatePoly needs an expression that evaluates
>to a graphic reference, not a graphic reference itself. (This is for
>complicated reasons having to do with the fact that revRotatePoly is a
>Transcript library routine.) This will work:
>
> revRotatePoly the long ID of graphic "MyPoly",90
Jeanne,
Following your instructions I went into the RR toy box of back
scripts to find the code for revRotatePoly. There are some strange
things there. I do not understand "revPoints" at all. It seems to be
a whole new kind of source for value. But ignorance is bliss and,
using your suggestion about using the long ID I came up with the
following version of revRotatePoly which seems to work in buttons.
on mouseUp
revRotatePoly2 "myGraphic",45
end mouseUp
on revRotatePoly2 pGraphic, pAngle
lock screen -- Add this line
put the long ID of graphic pGraphic into pGraphic --Add this line
--put the topLeft of pGraphic into tTopLeft # Delete this line
put revPoints(pGraphic) into tPoints
put the loc of pGraphic into tLoc
pr tLoc
put sin(pAngle * (pi / 180)) into tSinAngle
put cos(pAngle * (pi / 180)) into tCosAngle
put (number of items of tPoints) div 2 into tNumItems
repeat with i = 1 to tNumItems
put (item (i + (i - 1)) of tPoints) into tCurrentH -- + item 1 of
the center
put (item (i + i) of tPoints) into tCurrentV -- + item 2 of the center
--Use "round" instead of trunc in the lines below
put round((tCosAngle * tCurrentH) - (tSinAngle * tCurrentV)) into tTempH
put round((tSinAngle * tCurrentH) + (tCosAngle * tCurrentV)) into tTempV
put tTempH + (item 1 of tPoints) into tCurrentH
put tTempV + (item 2 of tPoints) into tCurrentV
put tCurrentH,tCurrentV & comma after tFinalPoints
end repeat
delete last char of tFinalPoints
set the points of pGraphic to tFinalPoints
-- set the topLeft of pGraphic to tTopLeft # Delete this line
set the loc of pGraphic to tLoc -- Add this line
unlock screen --Add this line
end revRotatePoly2
I found that resetting the graphic loc at the end did less violence
to the position of the graphic after rotation but this may be a
matter of preference.
Also, using round rather than trunc maintains the shape of the
graphic a little better. Doing 8 rotations of 45 degrees with trunc
does alter the shape.
Regards,
Jim
--
Jim Hurley
More information about the use-livecode
mailing list