home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
alib
/
d7xx
/
d724
/
donsgenies.lha
/
DonsGenies
/
DonsGenies.lha
/
Don'sGenies
/
BordersSimpleShapes.pprx
< prev
next >
Wrap
Text File
|
1992-08-09
|
27KB
|
823 lines
/* This Genie puts a decorative border around a box, using data stored in the genie. The resulting border is merged into a single box. The current line and fill colours are used.
Genie written and © by Don Cox July 92 */
trace n
address command
signal on error
signal on syntax
signal on halt
signal on break_c
signal on break_d
signal on break_e
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
call ppm_AutoUpdate(0)
call SafeEndEdit.rexx()
cr="0a"x
CurrentUnits = ppm_GetUnits()
select
when CurrentUnits = 1 then do
units="inches"
mul = 1
mul2 = 72
end
when CurrentUnits = 2 then do
units="mm"
mul = 10
mul2 = 28.4
end
otherwise do
call ppm_SetUnits(2)
units="mm"
mul = 10
mul2 = 28.4
end
end
mainbox = ppm_ClickOnBox(" Click on box to be given a border")
if mainbox = 0 then exit_msg("No box selected")
mainpos = ppm_GetBoxPosition(mainbox)
mainXpos = word(mainpos, 1)
mainYpos = word(mainpos, 2)
mainsize = ppm_GetBoxSize(mainbox)
mainwidth = word(mainsize,1)
mainheight = word(mainsize,2)
mainangle = ppm_GetBoxAngle(mainbox)
/* Initialize data strings */
cornerline1 = ""
cornerline2 = ""
cornerline3 = ""
cornerweight1 = ""
cornerweight2 = ""
cornerweight3 = ""
sideline1 = ""
sideline2 = ""
sideline3 = ""
cornerXoffset = 0
cornerYoffset = 0
sideXoffset = 0
sideYoffset = 0
cornerfill1 = 0
cornerfill2 = 0
cornerfill3 = 0
sidefill1 = 0
sidefill2 = 0
sidefill3 = 0
lines = 1
list = "Greek Key"cr"Two Rules"cr"Two Rules Rounded"cr"Two Rules Reverse Rounded"cr"Three Rules"cr"Battlements"cr"Cutout"cr"Filled Squares"cr"Double Squares"cr"Off-Centre Squares"cr"Filled Triangles"cr"Filled Triangles 2"cr"Three Ls"cr"Bars"
chosen = ppm_SelectFromList("Select Border Pattern",30,14,0,list)
if chosen = "" then exit_msg("Aborted by User")
/* Data for various patterns */
select
when chosen = "Bars" then do
cornerline1 = "0 0"cr"3 0"cr"3 3"cr"0 3"cr"0 0"
cornerline2 = "5 0"cr"7 0"cr"7 7"cr"0 7"cr"0 5"cr"5 5"cr"5 0"
cornerline3 = "9 0"cr"11 0"cr"11 11"cr"0 11"cr"0 9"cr"9 9"cr"9 0"
sideline1 = "1 0"cr"3 0"cr"3 12"cr"1 12"cr"1 0"
sideline2 = "5 0"cr"7 0"cr"7 12"cr"5 12"cr"5 0"
sideheight = 12
sidewidth = 8
sideXoffset = 1
sideYoffset = 0
cornerheight = 12
cornerwidth = 12
cornerXoffset = 0
cornerYoffset = 0
cornerfill1 = 1
cornerfill2 = 1
cornerfill3 = 1
sidefill1 = 1
sidefill2 = 1
sidefill3 = 0
lines = 0 /* number of line weights to be set by user */
end
when chosen = "Three Ls" then do
cornerline1 = "0 0"cr"4 0"cr"4 4"cr"0 4"cr"0 0"
cornerline2 = "6 0"cr"9 0"cr"9 9"cr"0 9"cr"0 6"cr"6 6"cr"6 0"
sideline1 = "1 0"cr"3 0"cr"3 8"cr"11 8"cr"11 10"cr"1 10"cr"1 0"
sideline2 = "5 0"cr"7 0"cr"7 4"cr"11 4"cr"11 6"cr"5 6"cr"5 0"
sideline3 = "9 0"cr"11 0"cr"11 2"cr"9 2"cr"9 0"
sideheight = 10
sidewidth = 12
sideXoffset = 1
sideYoffset = 0
cornerheight = 10
cornerwidth = 10
cornerXoffset = 0
cornerYoffset = 0
cornerfill1 = 1
cornerfill2 = 1
sidefill1 = 1
sidefill2 = 1
sidefill3 = 1
lines = 0
end
when chosen = "Filled Triangles 2" then do
cornerline1 = "4.3 0"cr"4.3 4.3"cr"0 4.3"cr"4.3 0"
sideline1 = "0 0"cr"4 0"cr"0 4"cr"0 0"
sideline2 = "5 1"cr"5 5"cr"1 5"cr"5 1"
sideheight = 5
sidewidth = 6.4
sideXoffset = 0.7
sideYoffset = 0
cornerheight = 5
cornerwidth = 5
cornerXoffset = 0
cornerYoffset = 0
cornerfill1 = 1
sidefill1 = 1
sidefill2 = 1
sidefill3 = 0
lines = 0
end
when chosen = "Filled Triangles" then do
cornerline1 = "2.6 0"cr"2.6 2.6"cr"0 2.6"cr"2.6 0"
sideline1 = "0 0"cr"4 4"cr"0 4"cr"0 0"
sideline2 = "2 0"cr"10 0"cr"6 4"cr"2 0"
sideline3 = "12 0"cr"12 4"cr"8 4"cr"12 0"
sideheight = 4
sidewidth = 12
sideXoffset = 0
sideYoffset = 0
cornerheight = 4
cornerwidth = 4
cornerXoffset = 0
cornerYoffset = 0
cornerfill1 = 1
sidefill1 = 1
sidefill2 = 1
sidefill3 = 1
lines = 0
end
when chosen = "Off-Centre Squares" then do
cornerline1 = "0 0"cr"4 0"cr"4 4"cr"0 4"cr"0 0"
cornerline2 = "0 0"cr"2 0"cr"2 2"cr"0 2"cr"0 0"
sideline1 = "1 0"cr"5 0"cr"5 4"cr"1 4"cr"1 0"
sideline2 = "1 0"cr"3 0"cr"3 2"cr"1 2"cr"1 0"
sideheight = 5
sidewidth = 6
sideXoffset = 1
sideYoffset = 0
cornerheight = 5
cornerwidth = 5
cornerXoffset = 0
cornerYoffset = 0
cornerfill1 = 0
sidefill1 = 0
lines = 1
end
when chosen = "Double Squares" then do
cornerline1 = "0 0"cr"4 0"cr"4 4"cr"0 4"cr"0 0"
cornerline2 = "1 1"cr"3 1"cr"3 3"cr"1 3"cr"1 1"
sideline1 = "1 0"cr"5 0"cr"5 4"cr"1 4"cr"1 0"
sideline2 = "2 1"cr"4 1"cr"4 3"cr"2 3"cr"2 1"
sideheight = 5
sidewidth = 6
sideXoffset = 1
sideYoffset = 0
cornerheight = 5
cornerwidth = 5
cornerXoffset = 0
cornerYoffset = 0
cornerfill1 = 0
sidefill1 = 0
lines = 1
end
when chosen = "Filled Squares" then do
cornerline1 = "0 0"cr"4 0"cr"4 4"cr"0 4"cr"0 0"
sideline1 = "1 0"cr"5 0"cr"5 4"cr"1 4"cr"1 0"
sideheight = 5
sidewidth = 6
sideXoffset = 1
sideYoffset = 0
cornerheight = 5
cornerwidth = 5
cornerXoffset = 0
cornerYoffset = 0
cornerfill1 = 1
sidefill1 = 1
lines = 0
end
when chosen = "Cutout" then do
cornerline1 = "0 1"cr"0 0"cr"1 0"
sideline1 = "0 0"cr"1 0"
sideline2 = "3 0"cr"4 0"
sideheight = 1
sidewidth = 4
sideXoffset = 0
sideYoffset = 0
cornerheight = 1
cornerwidth = 1
cornerXoffset = 0
cornerYoffset = 0
lines = 1
end
when chosen = "Battlements" then do
cornerline1 = "0 0"cr"3.3 0"cr"3.3 2.3"cr"2.3 2.3"cr"2.3 3.3"cr"0 3.3"cr"0 0"
sideline1 = "0 6"cr"1 6"cr"1 0"cr"3 0"cr"3 6"cr"4 6"
sideheight = 6
sidewidth = 4
sideXoffset = 0
sideYoffset = 0
cornerheight = 4
cornerwidth = 4
cornerXoffset = 0
cornerYoffset = 0
lines = 1
end
when chosen = "Greek Key" then do
sideline1 = "0 0"cr"6 0"cr"6 5"cr"3 5"cr"3 3"cr"2 3"cr"2 6"cr"7 6"cr"7 0"cr"8 0"
sideline2 = "0 1"cr"5 1"cr"5 4"cr"4 4"cr"4 2"cr"1 2"cr"1 7"cr"8 7"cr"8 1"
sideheight = 8
sidewidth = 8
sideXoffset = 0
sideYoffset = 0
cornerheight = 8
cornerwidth = 8
cornerXoffset = 0
cornerYoffset = 0
Cornerline1 = "0 8"cr"0 0"cr"6 0"cr"6 5"cr"2 5"cr"2 2"cr"4 2"cr"4 3"cr"3 3"cr"3 4"cr"5 4"cr"5 1"cr"1 1"cr"1 6"cr"7 6"cr"7 0"cr"8 0"
Cornerline2 = "1 8"cr"1 7"cr"8 7"cr"8 1"
lines = 0
end
when chosen = "Two Rules" then do
sideline1 = ""
sideline2 = ""
Cornerline1 = ""
cornerline2 = ""
lines = 2
end
when chosen = "Two Rules Rounded" | chosen = "Two Rules Reverse Rounded" then do
sideline1 = ""
sideline2 = ""
Cornerline1 = ""
cornerline2 = ""
lines = 100 /* impossible number as a flag */
end
when chosen = "Three Rules" then do
sideline1 = ""
sideline2 = ""
Cornerline1 = ""
cornerline2 = ""
lines = 3
end
otherwise do
cornerline1 = ""
cornerline2 = ""
cornerline3 = ""
sideline1 = ""
sideline2 = ""
sideline3 = ""
end
end
/* Collect line weights from user */
if lines>3 & lines~=100 then lines = 3
select
when lines = 0 then do
form = ppm_GetForm("Set sizes",8,"Border width ("units")")
if form = "" then exit_msg("Aborted by user")
cornerweight1 = ""
parse var form breadth
end
when lines = 1 then do
form = ppm_GetForm("Set sizes",8,"Border width ("units")"cr"Line weight (points)")
if form = "" then exit_msg("Aborted by user")
parse var form breadth "0a"x cornerweight1
end
when lines = 2 then do
form = ppm_GetForm("Set sizes",8,"Border width ("units")"cr"Line 1 (points)"cr"Line 2 (points)")
if form = "" then exit_msg("Aborted by user")
parse var form breadth "0a"x cornerweight1 "0a"x cornerweight2
end
when lines = 3 then do
form = ppm_GetForm("Set sizes",8,"Border width ("units")"cr"Line 1 (points)"cr"Line 2 (points)"cr"Line 3 (points)")
if form = "" then exit_msg("Aborted by user")
parse var form breadth "0a"x cornerweight1 "0a"x cornerweight2 "0a"x cornerweight3
end
when lines = 100 then do
form = ppm_GetForm("Set sizes",8,"Border width ("units")"cr"Line 1 (points)"cr"Line 2 (points)"cr"Corner Radius ("units")")
if form = "" then exit_msg("Aborted by user")
parse var form breadth "0a"x cornerweight1 "0a"x cornerweight2 "0a"x cornerRadius
if cornerRadius = "" then cornerRadius = breadth*2
end
otherwise nop
end
if breadth="" then exit_msg("Aborted by User")
breadth = breadth/mul /* mm to cm */
if breadth>(word(mainsize,1))/2 | breadth>(word(mainsize,2))/2 then exit_msg("Too big")
defaultweight = (breadth*mul2)/20
if cornerweight1 = "" then cornerweight1 = defaultweight
if cornerweight2 = "" then cornerweight2 = defaultweight
if cornerweight3 = "" then cornerweight3 = defaultweight
if lines = 1 | lines = 0 then do
cornerweight2 = cornerweight1
cornerweight3 = cornerweight1
end
if lines = 2 then cornerweight3 = cornerweight2
sideweight1 = cornerweight1
sideweight2 = cornerweight2
sideweight3 = cornerweight3
maxweight = max(cornerweight1, cornerweight2, cornerweight3)
maxwt = maxweight/72 /* max. line weight in inches */
if CurrentUnits = 2 then maxwt = maxwt*2.54 /* or centimetres */
/* First deal with plain rectangular borders */
if chosen = "Two Rules" then do
call ppm_NewGroup()
call ppm_SetLineWeight(sideweight1)
rect1 = ppm_DrawRect(mainXpos, mainYpos, mainXpos+word(mainsize,1), mainYpos+word(mainsize,2))
call ppm_AddToGroup(rect1)
call ppm_SetLineWeight(sideweight2)
rect2 = ppm_DrawRect(mainXpos+breadth, mainYpos+breadth, mainXpos+word(mainsize,1)-breadth, mainYpos+word(mainsize,2)-breadth)
call ppm_AddToGroup(rect2)
borderbox = ppm_MergeGroup()
call ppm_SetBoxAngle(borderbox,mainangle)
call ppm_SetBoxPosition(borderbox,mainXpos,mainYpos)
/* Set an arbitrary margin in main box */
margin = breadth*2
call ppm_SetBoxMargins(mainbox, margin, margin, margin, margin)
exit_msg("Done")
end
if chosen = "Two Rules Rounded" | chosen = "Two Rules Reverse Rounded" then do
rev = 0
if chosen = "Two Rules Reverse Rounded" then rev = 1
call ppm_ShowStatus(" Calculating outer line ...")
call ppm_NewGroup()
trace n
cornerRadius = cornerRadius/mul /* convert units */
cRadius = cornerRadius /* for positioning centres of arcs */
AA=6.2831853/360 /* 2pi divided by 360 */
AAA=AA*3
angle= 180*AA /* convert to radians */
if rev = 1 then do /* for reverse curve corners */
angle = 90*AA
AAA=-AAA /* anti-clockwise arcs */
cRadius = 0
end
drawstring = mainXpos (mainYpos+cornerRadius)||"0a"x
/* Draw the outer line, using 3 degree steps to give a smooth curve */
call ppm_SetLineWeight(sideweight1)
Xcentre = mainXpos+cRadius /* centre of corner arc */
Ycentre = mainYpos+cRadius
do i = 1 to 30
X2=Xcentre+(cornerRadius*cos(angle))
Y2=Ycentre+(cornerRadius*sin(angle))
angle=angle+AAA
drawstring=drawstring||X2 Y2"0a"x
end
if rev = 1 then drawstring = drawstring||(mainXpos +cornerRadius) mainYpos"0a"x
drawstring = drawstring||(mainXpos +mainwidth -cornerRadius) mainYpos"0a"x
Xcentre = mainXpos+mainwidth-cRadius
Ycentre = mainYpos+cRadius
if rev = 1 then angle = angle+(60*AAA)
do i = 1 to 30
X2=Xcentre+(cornerRadius*cos(angle))
Y2=Ycentre+(cornerRadius*sin(angle))
angle=angle+AAA
drawstring=drawstring||X2 Y2"0a"x
end
if rev = 1 then drawstring = drawstring||(mainXpos +mainwidth) (mainYpos+cornerRadius)"0a"x
drawstring = drawstring||(mainXpos+mainwidth) (mainYpos+mainheight-cornerRadius)"0a"x
Xcentre = mainXpos+mainwidth-cRadius
Ycentre = mainYpos+mainheight-cRadius
if rev = 1 then angle = angle+(60*AAA)
do i = 1 to 30
X2=Xcentre+(cornerRadius*cos(angle))
Y2=Ycentre+(cornerRadius*sin(angle))
angle=angle+AAA
drawstring=drawstring||X2 Y2"0a"x
end
if rev = 1 then drawstring = drawstring||(mainXpos +mainwidth -cornerRadius) (mainYpos+mainheight)"0a"x
drawstring = drawstring||(mainXpos+cornerRadius) (mainYpos+mainheight)"0a"x
Xcentre = mainXpos+cRadius
Ycentre = mainYpos+mainheight-cRadius
if rev = 1 then angle = angle+(60*AAA)
do i = 1 to 30
X2=Xcentre+(cornerRadius*cos(angle))
Y2=Ycentre+(cornerRadius*sin(angle))
angle=angle+AAA
drawstring=drawstring||X2 Y2"0a"x
end
if rev = 1 then drawstring = drawstring||mainXpos (mainYpos+mainheight-cornerRadius)"0a"x
drawstring = drawstring||mainXpos (mainYpos+cornerRadius)"0a"x
call ppm_SaveText("ram:arcdata",drawstring)
box = ppm_DrawPoly("ram:arcdata",boxname)
call ppm_AddToGroup(box)
trace n
/* Draw the inner arc, in 3 degree steps to give a smooth curve */
call ppm_ShowStatus(" Calculating inner line ...")
call ppm_SetLineWeight(sideweight2)
cornerRadius2 = cornerRadius-breadth
if rev = 1 then do
cornerRadius2 = cornerRadius+breadth
cornerRadius = cornerRadius+breadth
a2 = sin(90*AA)/cornerRadius*breadth
a2 = atan(a2/sqrt(-a2*a2+1))
a3 = 3.1415927-(90*AA)-a2
startangle = a2
arcangle = (90*AA)-(2*startangle)
AAA = -(arcangle/30)
angle = (90*AA)-startangle
end
trace n
/* first corner */
drawstring = (mainXpos+breadth) (mainYpos+cornerRadius)||"0a"x
Xcentre = mainXpos+cRadius
Ycentre = mainYpos+cRadius
do i = 0 to 30
X2=Xcentre+(cornerRadius2*cos(angle))
Y2=Ycentre+(cornerRadius2*sin(angle))
angle=angle+AAA
drawstring=drawstring||X2 Y2"0a"x
end
if rev = 1 then drawstring = drawstring||(mainXpos +cornerRadius) (mainYpos+breadth)"0a"x
drawstring = drawstring||(mainXpos +mainwidth -cornerRadius) (mainYpos+breadth)"0a"x
/* second corner */
Xcentre = mainXpos+mainwidth-cRadius
Ycentre = mainYpos+cRadius
if rev = 1 then angle = (180*AA)-startangle
do i = 0 to 30
X2=Xcentre+(cornerRadius2*cos(angle))
Y2=Ycentre+(cornerRadius2*sin(angle))
angle=angle+AAA
drawstring=drawstring||X2 Y2"0a"x
end
if rev = 1 then drawstring = drawstring||(mainXpos +mainwidth -breadth) (mainYpos+cornerRadius)"0a"x
drawstring = drawstring||(mainXpos+mainwidth-breadth) (mainYpos+mainheight-cornerRadius)"0a"x
/* third corner */
Xcentre = mainXpos+mainwidth-cRadius
Ycentre = mainYpos+mainheight-cRadius
if rev = 1 then angle = (270*AA)-startangle
do i = 0 to 30
X2=Xcentre+(cornerRadius2*cos(angle))
Y2=Ycentre+(cornerRadius2*sin(angle))
angle=angle+AAA
drawstring=drawstring||X2 Y2"0a"x
end
if rev = 1 then drawstring = drawstring||(mainXpos +mainwidth -cornerRadius) (mainYpos+mainheight-breadth)"0a"x
drawstring = drawstring||(mainXpos+cornerRadius) (mainYpos+mainheight-breadth)"0a"x
/* fourth corner */
Xcentre = mainXpos+cRadius
Ycentre = mainYpos+mainheight-cRadius
if rev = 1 then angle = 0-startangle
do i = 0 to 30
X2=Xcentre+(cornerRadius2*cos(angle))
Y2=Ycentre+(cornerRadius2*sin(angle))
angle=angle+AAA
drawstring=drawstring||X2 Y2"0a"x
end
if rev = 1 then drawstring = drawstring||(mainXpos +breadth) (mainYpos+mainheight-cornerRadius)"0a"x
drawstring = drawstring||(mainXpos+breadth) (mainYpos+cornerRadius)"0a"x
call ppm_SaveText("ram:arcdata2",drawstring)
box = ppm_DrawPoly("ram:arcdata2",boxname)
call ppm_AddToGroup(box)
borderbox = ppm_MergeGroup()
call ppm_SetBoxAngle(borderbox,mainangle)
call ppm_SetBoxPosition(borderbox,mainXpos-((sideweight1/2)/mul2), mainYpos-((sideweight1/2)/mul2))
/* Set an arbitrary margin in main box */
margin = cornerRadius*1.2
call ppm_SetBoxMargins(mainbox, margin, margin, margin, margin)
exit_msg()
end
if chosen = "Three Rules" then do
call ppm_NewGroup()
call ppm_SetLineWeight(sideweight1)
rect1 = ppm_DrawRect(mainXpos, mainYpos, mainXpos+word(mainsize,1), mainYpos+word(mainsize,2))
call ppm_AddToGroup(rect1)
call ppm_SetLineWeight(sideweight2)
rect2 = ppm_DrawRect(mainXpos+(breadth/3), mainYpos+(breadth/3), mainXpos+word(mainsize,1)-(breadth/3), mainYpos+word(mainsize,2)-(breadth/3))
call ppm_AddToGroup(rect2)
call ppm_SetLineWeight(sideweight3)
rect3 = ppm_DrawRect(mainXpos+breadth, mainYpos+breadth, mainXpos+word(mainsize,1)-breadth, mainYpos+word(mainsize,2)-breadth)
call ppm_AddToGroup(rect3)
borderbox = ppm_MergeGroup()
call ppm_SetBoxAngle(borderbox,mainangle)
call ppm_SetBoxPosition(borderbox,mainXpos,mainYpos)
/* Set an arbitrary margin in main box */
margin = breadth*2
call ppm_SetBoxMargins(mainbox, margin, margin, margin, margin)
exit_msg("Done")
end
/* Now deal with borders using shapes scaled to fit */
mainheight = (word(mainsize, 2))-(breadth*2)
mainwidth = (word(mainsize, 1))-(breadth*2)
call ppm_NewGroup()
count = 0
if cornerline1 ~= "" then do
drawstring = cornerline1
call ppm_SaveText("ram:linedata",drawstring)
call ppm_SetLineWeight(cornerweight1)
call ppm_SetFillPattern(cornerfill1)
cornerbox = ppm_DrawPoly("ram:linedata")
call ppm_AddToGroup(cornerbox)
count = count+1
end
if cornerline2 ~= "" then do
drawstring = cornerline2
call ppm_SaveText("ram:linedata",drawstring)
call ppm_SetLineWeight(cornerweight2)
call ppm_SetFillPattern(cornerfill2)
cornerbox = ppm_DrawPoly("ram:linedata")
call ppm_AddToGroup(cornerbox)
count = count+1
end
if cornerline3 ~= "" then do
drawstring = cornerline3
call ppm_SaveText("ram:linedata",drawstring)
call ppm_SetLineWeight(cornerweight3)
call ppm_SetFillPattern(cornerfill3)
cornerbox = ppm_DrawPoly("ram:linedata")
call ppm_AddToGroup(cornerbox)
count = count+1
end
if count>1 then cornerbox = ppm_MergeGroup() /* Merge fails with 1 box */
if cornerbox ~=0 then do
if cornerheight~=0 & cornerwidth~=0 then call ppm_SetBoxSize(cornerbox, cornerwidth, cornerheight)
call ppm_SetBoxOffset(cornerbox,cornerXoffset,cornerYoffset)
csize = ppm_GetBoxSize(cornerbox)
cXsize = word(csize, 1)
cYsize = word(csize, 2)
cscale = ppm_GetBoxScale(cornerbox)
cscaleX = word(cscale, 1)
cscaleY = word(cscale, 2)
cangle = ppm_GetBoxAngle(cornerbox)
end
call ppm_NewGroup()
count = 0
if sideline1 ~= "" then do
drawstring = sideline1
call ppm_SaveText("ram:linedata",drawstring)
call ppm_SetLineWeight(sideweight1)
call ppm_SetFillPattern(sidefill1)
sidebox = ppm_DrawPoly("ram:linedata")
call ppm_AddToGroup(sidebox)
count = count+1
end
if sideline2 ~= "" then do
drawstring = sideline2
call ppm_SaveText("ram:linedata",drawstring)
call ppm_SetLineWeight(sideweight2)
call ppm_SetFillPattern(sidefill2)
sidebox = ppm_DrawPoly("ram:linedata")
call ppm_AddToGroup(sidebox)
count = count+1
end
if sideline3 ~= "" then do
drawstring = sideline3
call ppm_SaveText("ram:linedata",drawstring)
call ppm_SetLineWeight(sideweight3)
call ppm_SetFillPattern(sidefill3)
sidebox = ppm_DrawPoly("ram:linedata")
call ppm_AddToGroup(sidebox)
count = count+1
end
if count>1 then sidebox = ppm_MergeGroup()
/* Place Corner Units */
call ppm_NewGroup()
call ppm_ShowStatus("Placing Corner Units")
if cornerbox ~=0 then do
cbox = ppm_CloneBox(cornerbox, 0, 0)
call ppm_AddToGroup(cbox)
call ppm_SetBoxAngle(cbox,0)
call ppm_SetBoxSize(cbox, breadth, breadth)
call ppm_SetBoxScale(cbox, cscaleX*breadth/cXsize, cscaleY*breadth/cYsize)
call ppm_SetBoxPosition(cbox, mainXpos, mainYpos)
cbox2 = ppm_CloneBox(cbox, 0, 0)
call ppm_AddToGroup(cbox2)
call ppm_SetBoxPosition(cbox2, mainXpos, mainYpos+mainheight+breadth)
call ppm_SetBoxAngle(cbox2, (cangle+90)//360)
cbox3 = ppm_CloneBox(cbox, 0, 0)
call ppm_AddToGroup(cbox3)
call ppm_SetBoxPosition(cbox3, mainXpos+mainwidth+breadth, mainYpos+mainheight+breadth)
call ppm_SetBoxAngle(cbox3, (cangle+180)//360)
cbox4 = ppm_CloneBox(cbox, 0, 0)
call ppm_AddToGroup(cbox4)
call ppm_SetBoxPosition(cbox4, mainXpos+mainwidth+breadth, mainYpos)
call ppm_SetBoxAngle(cbox4, (cangle+270)//360)
call ppm_SetBoxAngle(cbox, cangle)
end
if sidebox = 0 then exit_msg("Done")
/* Collect original size and graphic scale of box */
if sideheight~=0 & sidewidth~=0 then call ppm_SetBoxSize(sidebox, sidewidth, sideheight)
call ppm_SetBoxOffset(sidebox,sideXoffset,sideYoffset)
scaleX = word(ppm_GetBoxScale(sidebox), 1)
scaleY = word(ppm_GetBoxScale(sidebox), 2)
width = word(ppm_GetBoxSize(sidebox), 1)
height = word(ppm_GetBoxSize(sidebox), 2)
scale1 = breadth/height
width2 = width*scale1
totalwidth = width2
heightcount = mainheight%totalwidth /* Use integer division to get number of repeats */
widthcount = mainwidth%totalwidth
if widthcount = 0 | heightcount = 0 then do
gone = ppm_DeleteBox(sidebox)
gone = ppm_DeleteBox(cornerbox)
gone = ppm_DeleteBox(cbox)
gone = ppm_DeleteBox(cbox2)
gone = ppm_DeleteBox(cbox3)
gone = ppm_DeleteBox(cbox4)
exit_msg("Pattern too big")
end
Xtotalwidth = mainwidth/widthcount /* Exact width of whole pattern */
Ytotalwidth = mainheight/heightcount
Xscale = Xtotalwidth/totalwidth
Yscale = Ytotalwidth/totalwidth
widthX = width2*Xscale
widthY = width2*Yscale
/* Place top units */
call ppm_ShowStatus("Placing Top Units")
leftpos = mainXpos+breadth
do j=1 to widthcount
newbox = ppm_CloneBox(sidebox, 0, 0)
call ppm_AddToGroup(newbox)
call ppm_SetBoxSize(newbox, widthX, breadth)
call ppm_SetBoxPosition(newbox, leftpos, mainYpos)
call ppm_SetBoxScale(newbox, (scaleX *scale1* Xscale), (scaleY * abs(scale1)) )
call ppm_SetBoxAngle(newbox, 0)
leftpos = leftpos+widthX
end
/* Place right side units */
call ppm_ShowStatus("Placing Right Side Units")
toppos = mainYpos+breadth
leftpos = mainXpos+word(mainsize, 1)
do j=1 to heightcount
newbox = ppm_CloneBox(sidebox, 0, 0)
call ppm_AddToGroup(newbox)
call ppm_SetBoxAngle(newbox, 270)
call ppm_SetBoxSize(newbox, widthY, breadth)
call ppm_SetBoxPosition(newbox, leftpos, toppos)
call ppm_SetBoxScale(newbox, (scaleX *scale1* Yscale), (scaleY * abs(scale1)) )
toppos = toppos+widthY
end
/* Place bottom units */
call ppm_ShowStatus("Placing Bottom Units")
leftpos = mainXpos+breadth+mainwidth
toppos = mainYpos+word(mainsize, 2)
do j=1 to widthcount
newbox = ppm_CloneBox(sidebox, 0, 0)
call ppm_AddToGroup(newbox)
call ppm_SetBoxAngle(newbox, 180)
call ppm_SetBoxSize(newbox, widthX, breadth)
call ppm_SetBoxPosition(newbox, leftpos, toppos)
call ppm_SetBoxScale(newbox, (scaleX *scale1* Xscale), (scaleY * abs(scale1)) )
leftpos = leftpos-widthX
end
/* Place left side units */
call ppm_ShowStatus("Placing Left Side Units")
toppos = mainYpos+breadth+mainheight
leftpos = mainXpos
do j=1 to heightcount
newbox = ppm_CloneBox(sidebox, 0, 0)
call ppm_AddToGroup(newbox)
call ppm_SetBoxAngle(newbox, 90)
call ppm_SetBoxSize(newbox, widthY, breadth)
call ppm_SetBoxPosition(newbox, leftpos, toppos)
call ppm_SetBoxScale(newbox, (scaleX *scale1* Yscale), (scaleY * abs(scale1)) )
toppos = toppos-widthY
end
/* Merge all the units into one box */
borderbox = ppm_MergeGroup()
call ppm_SetBoxAngle(borderbox,mainangle)
/* resize box slightly so that thick lines are not cropped */
bsize = ppm_GetBoxSize(borderbox)
bwidth = word(bsize,1)
bheight = word(bsize,2)
call ppm_SetBoxSize(borderbox,bwidth+(maxwt*2),bheight+(maxwt*2))
call ppm_SetBoxPosition(borderbox,mainXpos-maxwt,mainYpos-maxwt)
call ppm_SetBoxOffset(borderbox,maxwt,maxwt)
/* Delete the pattern boxes */
gone = ppm_DeleteBox(cornerbox)
gone = ppm_DeleteBox(sidebox)
/* Set an arbitrary margin in main box */
margin = breadth
boxtype = upper(word(ppm_GetBoxInfo(mainbox),1))
if boxtype = "TEXT" then margin = breadth*2
call ppm_SetBoxMargins(mainbox, margin, margin, margin, margin)
call ppm_BoxToFront(borderbox)
call exit_msg()
end
error:
syntax:
do
exit_msg("Genie failed due to error: "errortext(rc))
end
break_d:
break_e:
break_c:
halt:
call exit_msg("Aborted by User")
exit_msg:
do
parse arg message
if message ~= "" then
call ppm_Inform(1, message,"Resume")
call ppm_ClearStatus()
call ppm_SetUnits(CurrentUnits)
call ppm_AutoUpdate(1)
exit
end