home *** CD-ROM | disk | FTP | other *** search
/ DTP Toolbox / DTPToolbox.iso / propage4.0 / arexx / drawrectangle.pdrx < prev    next >
Encoding:
Text File  |  1995-01-14  |  3.7 KB  |  113 lines

  1. /*
  2. Routine to draw rectangles in Pro Draw. An example to show how it works.
  3. Written by Don Cox, Jan 95. Copyright. Not Public Domain.
  4. */
  5. /* $VER: DrawRectangle Jan 95 */
  6.  
  7. /* This leaves a file called traceDr in ram: for you to check out */
  8. call open("STDERR","ram:traceDR","W") 
  9. trace r
  10.  
  11. oldunits = pdm_GetUnits()
  12. call pdm_SetUnits(2) /* work in metric */
  13. call pdm_AutoUpdate(0)
  14.  
  15. if ~show(l, "gdarexxsupport.library") then
  16.    if ~addlib("gdarexxsupport.library",0,-30) then
  17.       exit_msg("Please install the gdarexxsupport.library in your libs: directory before running this Genie.")
  18.  
  19. numeric digits 14 /* mathematical precision */
  20.  
  21. /* User marks out bounding box for first shape - the shape can be bigger than the box if the coordinates specified in numstring are big enough */
  22. box = pdm_ClickArea("Drag out box to show size of first bounding box")
  23. if box = "" then exit_msg("No box")
  24.  
  25. colour1 = "WHITE" 
  26. colour2 = "BLACK"
  27. incrementX = .4 /* Arbitrary setting for spacing */
  28. rotation1 = 0 /* Curve can be rotated as it is drawn */
  29. rotation2 = 0
  30.  
  31. identity = 1 /* count objects so they can be all selected at end */
  32. curves. = "" /* initialize compound variable for counting objects */
  33. parse var box cornerX cornerY cornerX2 cornerY2
  34. cornerY2 = strip(cornerY2) /* remove a space */
  35. boxwidth = abs(cornerX2-cornerX)
  36. boxheight = abs(cornerY2-cornerY)
  37. boxleft = cornerX /* Position of user-drawn box sets corner of bounding box */
  38. boxtop = cornerY
  39.  
  40. do i=1 to 4 /* Draw 4 shapes, spaced by increments X and Y */
  41.     call DrawObject
  42.     boxleft = boxleft+incrementX
  43.     incrementY = 2 * i
  44.     boxtop = boxtop+incrementY
  45.     end
  46.     
  47. identity = identity-1
  48. call pdm_SelectObj(curves.1,curves.identity)
  49. call pdm_GroupObj()
  50.  
  51.  
  52. exit_msg()
  53. end
  54.  
  55.  
  56. /* +++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++ */
  57.  
  58. /* Final way out */
  59. exit_msg: procedure expose oldunits
  60. do
  61.     parse arg message
  62.  
  63.     if message ~= '' then call pdm_Inform(1,message,)
  64.     call pdm_ClearStatus()
  65.     call pdm_SetUnits(oldunits)
  66.     call pdm_UpdateScreen(0)
  67.     call pdm_AutoUpdate(1)
  68.     exit
  69. end
  70.  
  71.  
  72. /* ++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++ */
  73.  
  74. /* Draw single object containing two paths.  */
  75. drawobject:
  76.  
  77. boxsizeX = 10 /* Size of bounding box for points defined in numstring */
  78. boxsizeY = 8
  79.  
  80. /* Coords for points on path, each with handles. The point coordinates are relative to the top left corner of the bounding box and the handle coordinates are relative to the point. The whole lot is then scaled so that the bounding box fits the user-drawn box. */
  81. numstring1 = "2 2 0 0 0 0, 8 2 0 0 0 0, 8 6 0 0 0 0, 2 6 0 0 0 0"
  82.  
  83. /* Second path - the first two points are curve points */
  84. numstring2 = "3 3 -1 1 1 -1, 7 3 -1 -1 1 1, 7 5 0 0 0 0, 3 5 0 0 0 0" 
  85.  
  86. scaleY = boxheight/boxsizeY
  87. /* Two options here - to retain aspect or not */
  88. /*scaleX = scaleY*/ /* This keeps proportions as per numstring data */
  89. scaleX = boxwidth/boxsizeX /* or scale to fit box */
  90.  
  91. call pdm_initplot(boxleft, boxtop, scaleX, scaleY, rotation1)
  92. call pdm_PlotBezier(numstring1)
  93. obj = pdm_ClosePlot() /* Draws line across to first point */
  94. curves.identity = obj /* Use compound variable to list objects as drawn */
  95. call pdm_SetLineWeight(obj, 0.00) /* Use 0.00 for "none" */
  96. call pdm_SetFillPattern(obj,1, colour2)
  97. identity = identity+1
  98.     
  99. if numstring2 ~="" then do /* a second path with a solid fill - could combine the two to make a compound object */
  100.     call pdm_initplot(boxleft, boxtop, scaleX, scaleY, rotation2)
  101.     call pdm_PlotBezier(numstring2)
  102.     obj = pdm_ClosePlot()
  103.     curves.identity = obj
  104.     call pdm_SetLineWeight(obj, 0.00)
  105.     call pdm_SetFillPattern(obj,1, colour1)
  106.     identity = identity+1
  107.     end
  108.  
  109. return
  110.  
  111. /* +++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++ */
  112.  
  113.