home *** CD-ROM | disk | FTP | other *** search
Wrap
/* StepAndRepeatDeLuxe This Genie will make multiple copies of a box with user specified offset and rotation between copies. You can also scale the copies and set the centre of rotation. Written by Don Cox July 92., debug Aug 93. Not Public Domain. All rights reserved. */ if ~show("l", "gdarexxsupport.library") then if ~addlib("gdarexxsupport.library", 0, -30,0) then do call ppm_Inform(1,"Please install the gdarexxsupport.library in your libs: directory before running this Genie.") end cr = '0a'x address command call SafeEndEdit.rexx() units = ppm_GetUnits() if units = 3 then call ppm_SetUnits(2) signal on halt signal on break_c signal on break_e signal on break_d cu = "in" if units = 2 then cu = "cm" call ppm_AutoUpdate(0) call ppm_NewGroup() box = ppm_ClickOnBox("Click on box to duplicate..") if box = 0 then exit_msg("No box selected") call ppm_AddToGroup(box) /* whole set grouped including original box */ dup = 0 trace n source = ppm_Inform(3,"Settings from...","Same again","Defaults","Disk file") oldangle = ppm_GetBoxAngle(box) call ppm_SetBoxAngle(box,0) /* rotate to zero to get centre */ boxpos = ppm_GetBoxPosition(box) curX = word(boxpos, 1 ) curY = word(boxpos, 2 ) boxsize = ppm_GetBoxSize(box) width = word(boxsize, 1 ) height = word(boxsize, 2 ) centreX = curX+(width/2) centreY = curY+(height/2) call ppm_SetBoxAngle(box,oldangle) boxpos = ppm_GetBoxPosition(box) ImageScaleX = word(ppm_GetBoxScale(box),1) ImageScaleY = word(ppm_GetBoxScale(box),2) call ppm_ShowStatus("Position: "curX", "curY" size: w"width", h"height) formstring = "" if source = 0 then do if open("temp","ram:SRD.data","R") then do formstring = readch("temp",512) call close("temp") end if formstring = "" then source = 1 /* defaults if failed */ end /* source = 0 */ if source = 2 then do loadfile = ppm_GetFileName("Load settings from disk","PPage:","") if loadfile = "" then break if open("loader",loadfile,"R") then do formstring = readch("loader",512) call close("loader") end if formstring = "" then source = 1 /* go for defaults */ end if formstring = "" then formstring ="rows:2"||cr"columns:1"||cr"horiz. spacing ("cu"):"width||cr"vertical spacing ("cu"):"height||cr"horiz. offset ("cu"):"0||cr"offset angle:"0||cr"rotation angle:"0||cr"rotation centre, X:"centreX||cr"rotation centre, Y:"centreY||cr"scale, X:1.00"||cr"scale, Y:1.00"||cr"spiral scale:1.00"||cr"spiral spacing("cu"):0"||cr"save settings (Y/N):N"||cr"Link boxes (Y/N):N" form = ppm_GetForm("Step & Repeat DeLuxe", 12, formstring) if form = '' then exit_msg("Aborted by User") parse var form rows '0a'x columns '0a'x horizontal '0a'x vertical '0a'x HorizOffset '0a'x OffsetAngle '0a'x RotAngle '0a'x Xcentre '0a'x Ycentre '0a'x Xscale '0a'x Yscale '0a'x SpiralScale '0a'x SpiralIncrement '0a'x Saving '0a'x Linking if rows = '' then rows = 1 if columns = '' then columns = 1 if horizontal = '' then horizontal = 0 if vertical = '' then vertical = 0 if HorizOffset = "" then HorizOffset = 0 if OffsetAngle = "" then OffsetAngle = 0 if RotAngle = '' then RotAngle = 0 if Xcentre = "" then Xcentre = centreX if Ycentre = "" then Ycentre = centreY if Xscale = "" then Xscale = 1 if Yscale = "" then Yscale = 1 if SpiralScale = "" then SpiralScale = 1 if SpiralIncrement = "" then SpiralIncrement = 0 if ~(datatype(rows, n)) then exit_msg("Invalid Entry for Rows: "rows) if ~(datatype(columns, n)) then exit_msg("Invalid Entry for Columns: "columns) if ~(datatype(horizontal, n)) then exit_msg("Invalid Entry for Horiz. Spacing: "horizontal) if ~(datatype(HorizOffset, n)) then exit_msg("Invalid Entry for Horiz. Offset: "HorizOffset) if ~(datatype(vertical, n)) then exit_msg("Invalid Entry for Vertical Spacing: "vertical) if ~(datatype(OffsetAngle, n)) then exit_msg("Invalid Entry for Offset Angle: "OffsetAngle) if ~(datatype(RotAngle, n)) then exit_msg("Invalid Entry for Rotation Angle: "RotAngle) if ~(datatype(Xcentre, n)) then exit_msg("Invalid Entry for Rotation Centre X: "Xcentre) if ~(datatype(Ycentre, n)) then exit_msg("Invalid Entry for Rotation Centre Y: "Ycentre) if ~(datatype(Xscale, n)) then exit_msg("Invalid Entry for X scale: "Xscale) if ~(datatype(Yscale, n)) then exit_msg("Invalid Entry for Y scale: "Yscale) if ~(datatype(SpiralScale, n)) then exit_msg("Invalid Entry for Spiral Scale: "SpiralScale) if ~(datatype(SpiralIncrement, n)) then exit_msg("Invalid Entry for Spiral Increment: "SpiralIncrement) formstring ="rows:"rows||"0a"x"columns:"columns||"0a"x"horiz. spacing ("cu"):"horizontal||"0a"x"vertical spacing ("cu"):"vertical||"0a"x"horiz. offset ("cu"):"HorizOffset||"0a"x"offset angle:"OffsetAngle||"0a"x"rotation angle:"RotAngle||"0a"x"rotation centre, X:"Xcentre||"0a"x"rotation centre, Y:"Ycentre||"0a"x"scale, X:"Xscale||"0a"x"scale, Y:"Yscale||"0a"x"spiral scale:"SpiralScale||"0a"x"spiral spacing("cu"):"SpiralIncrement||"0a"x"save settings (Y/N):"upper(Saving)||"0a"x"Link boxes (Y/N):"upper(Linking)"0a"x if open("temp","ram:SRD.data","W") then do call seek("temp",0,"B") call writech("temp",formstring) call close("temp") end if upper(Saving) = "Y" then do savefile = ppm_GetFileName("Save settings to disk","PPage:","") if savefile = "" then break if open("saver",savefile,"W") then do call writech("saver",formstring) call close("saver") end end if RotAngle ~=0 then SpiralIncrement = SpiralIncrement/(360/RotAngle) /* get value for each unit */ if upper(linking)="Y" then do /* don't try to link if not text */ info = ppm_GetBoxInfo(box) boxtype = word(info,1) if upper(boxtype) ~= "TEXT" then linking = "N" end AroundCentre = 0 if centreX ~= Xcentre | centreY ~= Ycentre then AroundCentre = 1 rotationangle = oldangle HorizShift = 0 /* sideways shift for offset angle */ if OffsetAngle ~= 0 then do /* use horiz. spacing and offset angle */ Oangle=OffsetAngle*3.1415926/180 /* convert to radians */ vertical = horizontal*sin(Oangle) HorizShift = horizontal*cos(Oangle) end ScaledWidth = width ScaledHeight = height ScaledImageX = ImageScaleX ScaledImageY = ImageScaleY scaling = 0 if Xscale~=1 | Yscale~=1 then scaling = 1 /* set scaling flag */ boxes.1.1 = box /* For single rows or lines of units */ if rows = 1 | columns = 1 then do call ppm_ShowStatus(" Working on single column ") do i = 2 to max(rows,columns) k=i-1 box = boxes.1.k /* to avoid a bug in CloneBox we have to clone first and then set the position */ boxX=word(ppm_GetBoxPosition(box),1) boxY=word(ppm_GetBoxPosition(box),2) boxX=boxX+HorizShift+HorizOffset+horizontal boxY=boxY+vertical newbox = ppm_CloneBox(box, 0,0) call ppm_AddToGroup(newbox) call ppm_SetBoxPosition(newbox,boxX,boxY) boxes.1.i = newbox if rotangle ~= 0 then do newangle = (rotationangle + rotangle)//360 call ppm_SetBoxAngle(newbox, newangle) rotationangle = newangle end if AroundCentre = 1 then do adjustment = newbox "0a"x Xcentre "0a"x Ycentre "0a"x rotangle "0a"x SpiralScale "0a"x SpiralIncrement call rotator(adjustment) end if upper(linking)="Y" then linked = ppm_LinkBox(box,newbox) if scaling = 1 then do ScaledWidth = ScaledWidth*abs(Xscale) ScaledHeight = ScaledHeight*abs(Yscale) ScaledImageX = ScaledImageX*Xscale ScaledImageY = ScaledImageY*Yscale call ppm_SetBoxSize(newbox,ScaledWidth,ScaledHeight) call ppm_SetBoxScale(newbox,ScaledImageX,ScaledImageY) vertical = vertical * abs(Yscale) horizontal = horizontal * abs(Xscale) end end /* of column */ end /* rows or columns = 1 */ else do /* for multiple columns */ /* make first column */ call ppm_ShowStatus(" Working on column 1") do i = 2 to rows k=i-1 box = boxes.1.k /* to avoid a bug in CloneBox we have to clone first and then set the position */ boxX=word(ppm_GetBoxPosition(box),1) boxY=word(ppm_GetBoxPosition(box),2) boxX=boxX+HorizShift+HorizOffset boxY=boxY+vertical newbox = ppm_CloneBox(box, 0,0) call ppm_AddToGroup(newbox) call ppm_SetBoxPosition(newbox,boxX,boxY) boxes.1.i = newbox if rotangle ~= 0 then do newangle = (rotationangle + rotangle)//360 call ppm_SetBoxAngle(newbox, newangle) rotationangle = newangle end if AroundCentre = 1 then do adjustment = newbox "0a"x Xcentre "0a"x Ycentre "0a"x rotangle "0a"x SpiralScale "0a"x SpiralIncrement call rotator(adjustment) end if upper(linking)="Y" then linked = ppm_LinkBox(box,newbox) if scaling = 1 then do ScaledImageY = ScaledImageY*Yscale ScaledHeight = ScaledHeight*abs(Yscale) call ppm_SetBoxSize(newbox,width,ScaledHeight) call ppm_SetBoxScale(newbox,ImageScaleX,ScaledImageY) vertical = vertical * abs(Yscale) end end /* of first column */ vertical = height box = boxes.1.1 rotationangle = oldangle do j = 2 to columns call ppm_ShowStatus(" Working on column "j) k = j-1 rotationangle = ppm_GetBoxAngle(boxes.k.1) do i = 1 to rows box = boxes.k.i /* to avoid a bug in CloneBox we have to clone first and then set the position */ boxX=word(ppm_GetBoxPosition(box),1) boxY=word(ppm_GetBoxPosition(box),2) boxX=boxX+Horizontal newbox = ppm_CloneBox(box, 0,0) call ppm_AddToGroup(newbox) call ppm_SetBoxPosition(newbox,boxX,boxY) boxes.j.i = newbox if rotangle ~= 0 then do newangle = (rotationangle + rotangle)//360 call ppm_SetBoxAngle(newbox, newangle) rotationangle = newangle end if AroundCentre = 1 then do adjustment = newbox "0a"x Xcentre "0a"x Ycentre "0a"x rotangle "0a"x SpiralScale "0a"x SpiralIncrement call rotator(adjustment) end if upper(linking)="Y" then linked = ppm_LinkBox(box,newbox) if scaling = 1 then do ScaledWidth = word(ppm_GetBoxSize(box),1) * abs(Xscale) ScaledHeight = word(ppm_GetBoxSize(box),2) ScaledImageX = word(ppm_GetBoxScale(box),1) *Xscale ScaledImageY = word(ppm_GetBoxScale(box),2) call ppm_SetBoxSize(newbox,ScaledWidth,ScaledHeight) call ppm_SetBoxScale(newbox,ScaledImageX,ScaledImageY) vertical = vertical * abs(Yscale) ScaledImageY = ScaledImageY * Yscale end end /* rows */ if scaling = 1 then do horizontal = horizontal* abs(Xscale) vertical = height ScaledImageX = ScaledImageX*Xscale ScaledImageY = ImageScaleY end end /* columns */ end /* multiple columns */ exit_msg() end /* Rotate box around a centre */ rotator: procedure parse arg box '0a'x Xcentre '0a'x Ycentre '0a'x angle '0a'x SpiralScale '0a'x SpiralIncrement startangle = ppm_GetBoxAngle(box) call ppm_SetBoxAngle(box,0) boxpos = ppm_GetBoxPosition(box) boxleft = word(boxpos,1) boxtop = word(boxpos,2) boxsize = ppm_GetBoxSize(box) boxwidth = word(boxsize,1) boxheight = word(boxsize,2) boxcentreX = boxleft+(boxwidth/2) boxcentreY = boxtop+(boxheight/2) rangle=angle*3.1415926/180 /* convert to radians */ cosa = cos(rangle) sina = sin(rangle) Xoffset = boxcentreX-Xcentre Yoffset = boxcentreY-Ycentre newX = (Xoffset*cosa)+(Yoffset*sina) newY = (Yoffset*cosa)-(Xoffset*sina) if SpiralIncrement ~= 0 then do /* using Pythagoras to split increment of radius into x & y */ incX = (SpiralIncrement * newX) / (sqrt((newX*newX) + (newY*newY))) incY = (SpiralIncrement * newY) / (sqrt((newX*newX) + (newY*newY))) newX = NewX + incX newY = newY + incY end x = Xcentre+newX y = Ycentre+newY x = x * SpiralScale y = y * SpiralScale call ppm_SetBoxPosition(box,x-(boxwidth/2),y-(boxheight/2)) call ppm_SetBoxAngle(box,startangle) return break_d: break_e: break_c: halt: call exit_msg("User aborted Genie!") exit_msg: procedure expose units do parse arg message if message ~= '' then call ppm_Inform(1, message,"Resume") call ppm_ClearStatus() call ppm_SetUnits(units) call ppm_AutoUpdate(1) exit end