home *** CD-ROM | disk | FTP | other *** search
Wrap
/* Routine to draw rectangles in Pro Draw. An example to show how it works. Written by Don Cox, Jan 95. Copyright. Not Public Domain. */ /* $VER: DrawRectangle Jan 95 */ /* This leaves a file called traceDr in ram: for you to check out */ call open("STDERR","ram:traceDR","W") trace r oldunits = pdm_GetUnits() call pdm_SetUnits(2) /* work in metric */ call pdm_AutoUpdate(0) if ~show(l, "gdarexxsupport.library") then if ~addlib("gdarexxsupport.library",0,-30) then exit_msg("Please install the gdarexxsupport.library in your libs: directory before running this Genie.") numeric digits 14 /* mathematical precision */ /* 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 */ box = pdm_ClickArea("Drag out box to show size of first bounding box") if box = "" then exit_msg("No box") colour1 = "WHITE" colour2 = "BLACK" incrementX = .4 /* Arbitrary setting for spacing */ rotation1 = 0 /* Curve can be rotated as it is drawn */ rotation2 = 0 identity = 1 /* count objects so they can be all selected at end */ curves. = "" /* initialize compound variable for counting objects */ parse var box cornerX cornerY cornerX2 cornerY2 cornerY2 = strip(cornerY2) /* remove a space */ boxwidth = abs(cornerX2-cornerX) boxheight = abs(cornerY2-cornerY) boxleft = cornerX /* Position of user-drawn box sets corner of bounding box */ boxtop = cornerY do i=1 to 4 /* Draw 4 shapes, spaced by increments X and Y */ call DrawObject boxleft = boxleft+incrementX incrementY = 2 * i boxtop = boxtop+incrementY end identity = identity-1 call pdm_SelectObj(curves.1,curves.identity) call pdm_GroupObj() exit_msg() end /* +++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++ */ /* Final way out */ exit_msg: procedure expose oldunits do parse arg message if message ~= '' then call pdm_Inform(1,message,) call pdm_ClearStatus() call pdm_SetUnits(oldunits) call pdm_UpdateScreen(0) call pdm_AutoUpdate(1) exit end /* ++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++ */ /* Draw single object containing two paths. */ drawobject: boxsizeX = 10 /* Size of bounding box for points defined in numstring */ boxsizeY = 8 /* 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. */ 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" /* Second path - the first two points are curve points */ 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" scaleY = boxheight/boxsizeY /* Two options here - to retain aspect or not */ /*scaleX = scaleY*/ /* This keeps proportions as per numstring data */ scaleX = boxwidth/boxsizeX /* or scale to fit box */ call pdm_initplot(boxleft, boxtop, scaleX, scaleY, rotation1) call pdm_PlotBezier(numstring1) obj = pdm_ClosePlot() /* Draws line across to first point */ curves.identity = obj /* Use compound variable to list objects as drawn */ call pdm_SetLineWeight(obj, 0.00) /* Use 0.00 for "none" */ call pdm_SetFillPattern(obj,1, colour2) identity = identity+1 if numstring2 ~="" then do /* a second path with a solid fill - could combine the two to make a compound object */ call pdm_initplot(boxleft, boxtop, scaleX, scaleY, rotation2) call pdm_PlotBezier(numstring2) obj = pdm_ClosePlot() curves.identity = obj call pdm_SetLineWeight(obj, 0.00) call pdm_SetFillPattern(obj,1, colour1) identity = identity+1 end return /* +++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++ */