home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format 58
/
af058b.adf
/
PV21.lha
/
REXX
/
Shear.pvrx
< prev
next >
Wrap
Text File
|
1991-08-13
|
3KB
|
110 lines
/* This is a ProVector AREXX macro */
/***************************************************************\
* *
* Macro to 'shear' the selected objects by a given *
* angle. Works on groups, polygons, and polylines, *
* but not text. Needs rexxmathlib.library to work. *
* *
* Ross Cunniff, 10/30/89 *
* *
\***************************************************************/
/* Get the rexxmathlib.library */
if ~exists("LIBS:rexxmathlib.library") then do
'GetBool "Can not find REXXMATHLIB.LIBRARY" "Cancel" "Cancel"'
exit
end
else call addlib "rexxmathlib.library",0,-30,0
/* Address the application and ask that results be returned */
Address 'ProVector'
options results
/* Try to obtain exclusive access to ProVector; quit if not possible */
'Lock'
if rc ~= 0 then exit
/* Get the shear angle from the user; quit if they cancel */
'GetStr "Shear angle:" "OK" "Cancel"'; Angle=Result
if rc ~= 0 then do
'UnLock'
exit
end
/* Check the angle: values outside of -75 degrees to 75 degrees won't work */
if (Angle < -75) | (Angle > 75) then do
'UnLock'
exit
end
/* Find the Sin and Cos of the angle */
Rads = Angle*3.141593653589/180.0
CosA = cos(Rads); SinA = sin(Rads)
/* Get the baseline for shearing */
'SelExtent Ext'; Base = Ext.Y2
'PushUndo'
/* Shear each object in the list of selected objects */
'SelectList Sel'; N = Result
do I = 0 to N-1
call ShearOne(Sel.I,SinA,CosA,Base,1)
end
/* Repair the visual damage done by doing that */
'Repair'
/* All done! Return to normal operations */
'UnLock'
exit
/***************************************************************\
* *
* ShearOne( Obj, SinA, CosA, Base ) - Shears object Obj *
* by the angle whose sine and cosine are SinA and CosA. *
* Shearing is done relative to line through Y==Base. *
* Recursively calls itself in the case of groups. *
* *
\***************************************************************/
ShearOne: procedure
arg Obj,SinA,CosA,Base,Top
/* Find out what we're dealing with */
'TypeOf Obj'; T = Result
if T = 'Group' then do
/* This is a group. Shear each object in the group. */
'GroupObj Obj'; GObj = Result
do while GObj ~= 0
call ShearOne( GObj, SinA, CosA, Base, 0 )
'NextObj GObj'; GObj = Result
end
/* Kludge to fix up bounding box information */
'Rotate Obj 0 0 0'
end
else if (T = 'Polygon') | (T = 'Polyline') then do
/* This is a normal object. Shear each point. */
'GetPoints Obj Pts'; n = Result
i = 0
do while i < n
PX = Pts.i.X; PY = Pts.i.Y
if PX ~= 'INDICATOR' then do
r = (Base - PY) / CosA
PX = PX + r*SinA
Pts.i.X = PX; Pts.i.Y = PY
end
i = i + 1
end
if Top = 1 then do
'SaveUndo Obj'
end
'ChangePoints Obj n Pts'
end
return
/*** EOF shear.pvrx ***/