home *** CD-ROM | disk | FTP | other *** search
- /*
- BEZIER TOOL
-
- Click down at the position of the control point.
- Drag tangent point to desired position and release.
- Hit ESC to terminate an open curve.
-
- Modifiers:
- Double Clicking will bring up a requester which allows you to
- create a multi-sided polygon.
-
- Hold CONTROL and click & release mouse over an existing end
- point to create closed curve or join to existing curve.
- SHIFT - constrains Bezier to be a straight line.
- ALT - constrains control points to be in a 45° direction
- from the previous control point.
- */
-
- /* Stars added by Don Cox, Dec. '93. */
-
- msg = PDSetup.rexx(2,0)
- units = getclip(pds_units)
- if msg ~= 1 then exit_msg(msg)
-
- numeric digits 8
-
- pi2 = 6.28318
- cr = '0a'x
-
- sides = getclip(pduserpolysides)
- radius = getclip(pduspolyradius)
- ratio = getclip(pduspolyratio)
- if sides = '' then sides = 5
- if radius = '' then radius = 1
- if ratio = '' then ratio = 1
-
- if units > 2 then radius = pdm_ConvertUnits(1, units, radius
- sides = pdm_GetForm("Enter number of sides",8, "Sides:"sides || cr"Radius:"radius || cr"Star Ratio:"ratio)
- if sides = '' then exit_msg()
-
- parse var sides nsides '0a'x radius '0a'x ratio
- nsides = strip(nsides)
- radius = strip(radius)
- ratio = strip(ratio)
-
- if ~(datatype(nsides, n) & datatype(radius, n) & datatype(ratio, n)) then exit_msg("Invalid Entry")
- nsides = abs(nsides)
- if nsides < 3 then exit_msg("A polygon must have at least 3 sides")
- radius = abs(radius)
- ratio = abs(ratio)
- if units > 2 then radius = pdm_ConvertUnits(units, 1, radius)
-
- call setclip(pduserpolysides, nsides)
- call setclip(pduspolyradius, radius)
- call setclip(pduspolyratio, ratio)
-
- ang = pi2 / nsides
- posn = pdm_clickellipse("Click at position for polygon..",radius,radius*ratio)
- if posn = '' then exit_msg()
-
- call pdm_initplot(word(posn,1),word(posn,2),1,1,0)
- call pdm_ShowStatus("Working..")
-
- radius2 = radius*ratio
- steps = 0
- do until steps = nsides
- theta = ang * steps
- x = cos(theta) * radius
- y = sin(theta) * radius
- call pdm_plotline(x" "y)
- steps = steps+1
- if steps = nsides then break
- theta = ang * steps
- x = cos(theta) * radius2
- y = sin(theta) * radius2
- call pdm_plotline(x" "y)
- steps = steps+1
- end
-
- object = pdm_ClosePlot()
- center = pdm_GetCenter(object)
- parse var center CoordX CoordY
- CoordY = strip(CoordY)
- call pdm_RotateObj(object,90,CoordX,CoordY)
- object = pdm_SelectObj(object)
- call pdm_UpdateScreen(1)
-
- exit_msg()
-
-
-
- exit_msg: procedure expose units
- do
- parse arg message
-
- if message ~= '' then call pdm_Inform(1,message,)
- call pdm_ClearStatus()
- call pdm_SetUnits(units)
- call pdm_AutoUpdate(1)
- exit
- end
-