home *** CD-ROM | disk | FTP | other *** search
/ DTP Toolbox / DTPToolbox.iso / utilities / propage_pdraw / donsgenies / prodrawgenies.lha / _PD_TOOLS_BEZ.pdrx < prev    next >
Encoding:
Text File  |  1994-01-26  |  2.6 KB  |  102 lines

  1. /*
  2. BEZIER TOOL
  3.  
  4.     Click down at the position of the control point.
  5.     Drag tangent point to desired position and release.
  6.     Hit ESC to terminate an open curve.
  7.  
  8. Modifiers:
  9.     Double Clicking will bring up a requester which allows you to
  10.     create a multi-sided polygon.
  11.     
  12.     Hold CONTROL and click & release mouse over an existing end
  13.     point to create closed curve or join to existing curve.
  14.     SHIFT - constrains Bezier to be a straight line.
  15.     ALT   - constrains control points to be in a 45° direction
  16.             from the previous control point.
  17. */
  18.  
  19. /* Stars added by Don Cox, Dec. '93.   */
  20.  
  21. msg = PDSetup.rexx(2,0)
  22. units = getclip(pds_units)
  23. if msg ~= 1 then exit_msg(msg)
  24.  
  25. numeric digits 8
  26.  
  27. pi2 = 6.28318
  28. cr = '0a'x
  29.  
  30. sides = getclip(pduserpolysides)
  31. radius = getclip(pduspolyradius)
  32. ratio = getclip(pduspolyratio)
  33. if sides = '' then sides = 5
  34. if radius = '' then radius = 1
  35. if ratio = '' then ratio = 1
  36.  
  37. if units > 2 then radius = pdm_ConvertUnits(1, units, radius
  38. sides = pdm_GetForm("Enter number of sides",8, "Sides:"sides || cr"Radius:"radius || cr"Star Ratio:"ratio)
  39. if sides = '' then exit_msg()
  40.  
  41. parse var sides nsides '0a'x radius '0a'x ratio
  42. nsides = strip(nsides)
  43. radius = strip(radius)
  44. ratio = strip(ratio)
  45.  
  46. if ~(datatype(nsides, n) & datatype(radius, n) & datatype(ratio, n)) then exit_msg("Invalid Entry")
  47. nsides = abs(nsides)
  48. if nsides < 3 then exit_msg("A polygon must have at least 3 sides")
  49. radius = abs(radius)
  50. ratio = abs(ratio)
  51. if units > 2 then radius = pdm_ConvertUnits(units, 1, radius)
  52.  
  53. call setclip(pduserpolysides, nsides)
  54. call setclip(pduspolyradius, radius)
  55. call setclip(pduspolyratio, ratio)
  56.  
  57. ang = pi2 / nsides
  58. posn = pdm_clickellipse("Click at position for polygon..",radius,radius*ratio)
  59. if posn = '' then exit_msg()
  60.  
  61. call pdm_initplot(word(posn,1),word(posn,2),1,1,0)
  62. call pdm_ShowStatus("Working..")
  63.  
  64. radius2 = radius*ratio
  65. steps = 0
  66. do until steps = nsides
  67.     theta = ang * steps
  68.     x = cos(theta) * radius
  69.     y = sin(theta) * radius
  70.     call pdm_plotline(x" "y)
  71.     steps = steps+1
  72.     if steps = nsides then break
  73.     theta = ang * steps
  74.     x = cos(theta) * radius2
  75.     y = sin(theta) * radius2
  76.     call pdm_plotline(x" "y)
  77.     steps = steps+1
  78.    end
  79.  
  80. object = pdm_ClosePlot()
  81. center = pdm_GetCenter(object)
  82. parse var center CoordX CoordY
  83. CoordY = strip(CoordY)
  84. call pdm_RotateObj(object,90,CoordX,CoordY)
  85. object = pdm_SelectObj(object)
  86. call pdm_UpdateScreen(1)
  87.  
  88. exit_msg()
  89.  
  90.  
  91.  
  92. exit_msg: procedure expose units
  93. do
  94.     parse arg message
  95.  
  96.     if message ~= '' then call pdm_Inform(1,message,)
  97.     call pdm_ClearStatus()
  98.     call pdm_SetUnits(units)
  99.     call pdm_AutoUpdate(1)
  100.     exit
  101. end
  102.