RevRotatePoly - Workaround found!
David Kwinter
david at kwinter.ca
Thu Apr 17 15:28:01 EDT 2003
Ok, I've adapted a script from Alejandor Tejada's "Polygon Graphic
Transformations" into a function which has the functionality of
RevRotatePoly.
function rotateGraphic gName,rAngle
put "graphic ""e&gName"e into lvselectedgraphic
if existence(lvselectedgraphic) is false then exit rotateGraphic
if the checkLocation of lvselectedgraphic is empty or checkLocation <> the
loc of lvselectedgraphic
then set the exactPoints of lvselectedgraphic to empty
put "1,1 cosangle"&return&"1,2 sinangle"&return&"1,3 0"&return&"2,1
sinangle"&return&"2,2 cosangle"&return&"2,3 0"&return&"3,1 0"&return&"3,2
0"&return&"3,3 1" into fldsource
put "1,1 1"&return&"1,2 0"&return&"1,3 movX"&return&"2,1 0"&return&"2,2
1"&return&"2,3 movY"&return&"3,1 0"&return&"3,2 0"&return&"3,3 1" into
fldmove0
put "Graphic" into origin
put (the left of lvselectedgraphic + the width of
lvselectedgraphic/2),(the top of lvselectedgraphic + the height of
lvselectedgraphic/2) into mzbx
put -(item 1 of mzbx),-(item 2 of mzbx) into mzbx2
put fldmove0 into fldmove1
put fldmove0 into fldmove2
put cos(rAngle * pi / 180) into word 2 of line 1 of fldsource
put - sin(rAngle * pi / 180) into word 2 of line 2 of fldsource
put sin(rAngle * pi / 180) into word 2 of line 4 of fldsource
put cos(rAngle * pi / 180) into word 2 of line 5 of fldsource
put item 1 of mzbx into word 2 of line 3 of fldmove1
put item 2 of mzbx into word 2 of line 6 of fldmove1
put item 1 of mzbx2 into word 2 of line 3 of fldmove2
put item 2 of mzbx2 into word 2 of line 6 of fldmove2
put fldmove1 into qwe
-- put qwe
-- exit mouseup
split qwe by return and space -- qwe is converted in an array
put fldsource into qwa
-- put qwa
-- exit mouseup
split qwa by return and space
put matrixMultiply(qwe,qwa) into qws
put fldmove2 into qwe
-- put qwe
-- exit mouseup
split qwe by return and space
put matrixMultiply(qws,qwe) into qwa
combine qwa using comma
-- put qwa
put "1,1" & space & item 1 of qwa & return into fldsource
put "1,2" & space & item 2 of qwa & return after fldsource
put "1,3" & space & item 3 of qwa & return after fldsource
put "2,1" & space & item 4 of qwa & return after fldsource
put "2,2" & space & item 5 of qwa & return after fldsource
put "2,3" & space & item 6 of qwa & return after fldsource
put "3,1" & space & item 7 of qwa & return after fldsource
put "3,2" & space & item 8 of qwa & return after fldsource
put "3,3" & space & item 9 of qwa after fldsource
put "1,1 0"&return&"1,2 0"&return&"1,3 1"&return&"2,1 0"&return&"2,2
0"&return&"2,3 1"&return&"3,1 0"&return&"3,2 0"&return&"3,3 1" into flddata
if the exactPoints of lvselectedgraphic is empty then put the points of
lvselectedgraphic into fldpointsofgraphic else put the exactPoints of
lvselectedgraphic into fldpointsofgraphic
put fldsource into qwe
split qwe by return and space -- qwe is converted in an array
repeat the number of lines of fldpointsofgraphic
put item 1 of line 1 of fldpointsofgraphic into word 2 of line 3 of
flddata
put item 2 of line 1 of fldpointsofgraphic into word 2 of line 6 of
flddata
delete line 1 of fldpointsofgraphic
put flddata into qwa
split qwa by return and space
put matrixMultiply(qwe,qwa) into qws
combine qws using comma
-- put qws
put item 3 of qws,item 6 of qws & return after fldexactpointsofgraphic
put round(item 3 of qws) & comma& round(item 6 of qws) & return after
fldnewpointsofgraphic
end repeat
set the points of lvselectedgraphic to fldnewpointsofgraphic
set the exactPoints of lvselectedgraphic to fldexactpointsofgraphic
set the checkLocation of lvselectedgraphic to the loc of lvselectedgraphic
choose browse tool
end rotateGraphic
More information about the use-livecode
mailing list