Re: the realPoints
Posted: Thu Jun 09, 2022 11:04 pm
FWIW, from revcommonlibrary:
Code: Select all
# OK-2007-07-05: Rewrote revRotatePoly and revPoints to fix bug 4882
# Parameters
# pGraphic : A reference to a graphic
# pAngle : The angle to rotate the graphic by
# Description
# Performs a rotation transformation whose origin is the loc of the graphic and
# whose magnitude is pAngle degrees. Preserves the topLeft of the graphic, but may
# cause distortion due to rounding errors.
command revRotatePoly pGraphic, pAngle
local tPoints, tFinalPoints
local tLoc
local tSinAngle, tCosAngle
local tCurrentH, tCurrentV, tTransformedH, tTransformedV
local tOrigLeft, tOrigTop
lock screen
lock messages
if the realPoints of pGraphic is empty then
put the effective points of pGraphic into tPoints
else
put the realPoints of pGraphic into tPoints
end if
put the loc of pGraphic into tLoc
put item 1 of tLoc into tOrigLeft
put item 2 of tLoc into tOrigTop
put sin(pi*pAngle/180) into tSinAngle
put cos(pi*pAngle/180) into tCosAngle
repeat for each line tPoint in tPoints
if tPoint is not empty then
put item 1 of tPoint into tCurrentH
put item 2 of tPoint into tCurrentV
put (tOrigLeft+(tCosAngle*tCurrentH)-(tSinAngle*tCurrentV), tOrigTop+(tCosAngle*tCurrentV)+(tSinAngle*tCurrentH) ) after tFinalPoints
end if
put cr after tFinalPoints
end repeat
delete char -1 of tFinalPoints -- is CR
if the style of pGraphic is among the items of "oval,rectangle,roundrect,regular" then
set the style of pGraphic to "polygon"
end if
set points of pGraphic to tFinalPoints
set the realPoints of pGraphic to tFinalPoints
set loc of pGraphic to tLoc
unlock messages
unlock screen
end revRotatePoly
command revRotatePolygonOld pGraphic, pAngle
local tTopLeft
put the topLeft of pGraphic into tTopLeft
local tPoints
put revPoints(pGraphic) into tPoints
local tLoc
put the loc of pGraphic into tLoc
local tSinAngle
put sin(pAngle * (pi / 180)) into tSinAngle
local tCosAngle
put cos(pAngle * (pi / 180)) into tCosAngle
local tLineCount
put (the number of lines of tPoints) into tLineCount
local tCurrentH, tCurrentV, tTransformedH, tTransformedV, tFinalPoints
repeat for each line tPoint in tPoints
if tPoint is empty then
put empty & return after tFinalPoints
next repeat
end if
put item 1 of tPoint into tCurrentH
put item 2 of tPoint into tCurrentV
put trunc((tCosAngle * tCurrentH) - (tSinAngle * tCurrentV)) into tTransformedH
put trunc((tSinAngle * tCurrentH) + (tCosAngle * tCurrentV)) into tTransformedV
put tTransformedH + (item 1 of line 1 of tPoints) into tCurrentH
put tTransformedV + (item 2 of line 1 of tPoints) into tCurrentV
put tCurrentH,tCurrentV & return after tFinalPoints
end repeat
delete the last char of tFinalPoints
set the points of pGraphic to tFinalPoints
set the topLeft of pGraphic to tTopLeft
end revRotatePolygonOld