yesno "library of routines for svg formatted drawing" ifyes start notepad.exe " %me " halt :intentions 1)provide easy production of svg formatted files 2)easy control of fill (color), fill-opacity (0-1), stroke (color) stroke-opacity, stroke-width, font-size, text-anchor (left or middle) 3)draw svg primitives rect, line, circle, path, text, arcs 4)combine box as rect+text, connector as line+circles 4a) provide hints for positioning the next box, nextx nexty 5)provide an easy reference system for item location, dimension, attributes example mybox.x mybox.y .width .height .textx .texty .right .bottom .cx .cy .text .fill .fill-opacity .stroke .stroke-opacity .stroke-width .font-size .text-anchor 5a)provide easy constructs for drawing connections between items 5b)add simple, non-recrusive, grouping suchas parent.children 5c)draw children as a stack of boxes relative to the parent box 5d)grandchildren are appendable to children, make visual space available using gapx and gapy 6)add polygons, mypolygon.points .radius .radius2 .cx and .cy calculates each vector's coordinates as .x1 .y1 .x2 .y2 etc mid-segments as .x1.5 .y1.5 )read tables of data, retievable based on rowName.columnName or tableName.RowName.ColumnName 7)construct heirachal drawings storage simply requires linked lists parent.children and child.parents 7a)expression of a branch requires recursive functions with filo stacks example item and all children, grandchildren, to some depth example item and all parents, grandparents, etc, to some height 7b)final items and subcompontents should be easily addressable example root.box1.subA.cy parent.child.grandchild.greatgrandchild.text 7c)relational data should be treated seprately from visual handling visualize as a directory tree, left right or middle justified, reducing size away from root item #------------------------------------------------------------------------ macros and other command abbreviations :initialize # svg stuff... set fill PowderBlue set fill-opacity 0.9 set stroke grey set stroke-width 3 set stroke-opacity 0.9 set text-anchor left set font-size 12 set text "hello world, this is %me " # structured graphic stuff... set svg-width 1000 set svg-height 1000 set box-width 100 set box-height 100 set svg.right 0 set svg.bottom 0 set drawitemtext true set textX 10 set textY 10 set parent null set child null set stack-anchor below set line-term-1 dot set line-term-2 dot set topcenter cx y set bottomcenter cx bottom set leftcenter x cy set rightcenter right cy set polygon.form star set polygon.radius 100 set polygon.radius2 50 set print.vertex.name false set print.vertex.dot false set vertex-dot.scale 0.05 set revealing-path 1 == 0 set default.wire black 0.5 # initialize-macros set library %me set drawBox call drawBox %me set drawLine call drawLine %me set drawLineByName call drawlinebyname %me set drawlinelogical call drawlinelogical %me set drawLineR2L call drawLineRightToLeft %me set drawLineB2T call drawLineBottomToTop %me set drawStack call drawstack %me set drawText call drawText %me set drawWord call drawWord %me set drawCircle call drawCircle %me set drawChildren call drawChildren %me set child-scale.left 0.1 set child.shift.bottom 0 set child-scale.width 0.9 set store call store %me set recall call recall %me set recallBoxData call recallboxdata %me set recallTableData call recallTableData %me set readTableColumnNames call readTableColumnNames %me set readTableDataRow call readTableDataRow %me set drawPolygon call drawPolygon %me set halter call halter %me set define call define %me set pathpopper call pathpopper %me set pathpusher call pathpusher %me set kidspopper call kidspopper %me set kidspusher call kidspusher %me set drawtree call drawtree %me set drawarc call drawarc %me set drawcurve call drawcurve %me set drawjumper call drawjumper %me set lineformat %drawjumper set drawswerve call drawswerve %me set drawlinestyled call drawlinestyled %me set drawarrowhead call drawArrowHead %me set close-svg-file goto close-svg-file %me set swap call swap %me set swap-terminus 1 == 0 set parentfont call parent-settings %me set childfont call child-settings %me # prepare outputfiles # write the svg header set outputfilename title.svg set writesvg save %outputfilename delete %outputfilename %writesvg " # trouble shooting dump delete 2.txt # connections.txt delete connections.txt save connections.txt #connect color thickness source target save connections.txt # %date %time "created by %me # parts dimension database delete db.txt save db.txt ":top %date %time created by %me save db.txt goto "%1 # tree relations del tree.txt # visual updates form 4 textpict 4 %me exit :halter troubleshooting related info yesno " %1 %2 %3 %4 %5 %6 %7 %8 %9 " ifno halt exit :swap point 3 %1 point %1 %2 set %2 %3 exit # -------------------------------------------heirarchal stuff :drawtree topkid concat topkid %1 call pathpusher . null call kidspusher . %topkid null set prevkids.children ignore set nexty %y set parent null :draw.loop thiskid more kids set thiskid %kids1 xsave 2.txt thiskid %thiskid call kidspopper call pathpusher . %thiskid call drawthiskid if " %prevkids.children " == " null " goto pop if " %thiskid " == " pop " goto pop2 if " %thiskid " == " null " exit #see if this kid has children concat temp %thiskid .children point temp %temp set thiskids.children %temp set temp %temp null #if not... if " %temp " == " null " goto pop #otherwise goto next :pop2 call pathpopper call restore-parent-size :pop call pathpopper call restore-parent-size set thiskids.children "" if " %path " == " null " exit goto draw.loop :next :repeat set prevkids.children %thiskids.children call kidspusher . %thiskids.children pop goto draw.loop :restore-parent-size div font-size %font-size %child-scale div fill-opacity %fill-opacity %child-scale div stroke-width %stroke-width %child-scale div box-width %box-width %child-scale div box-height %box-height %child-scale xif %revealing-path mul box-height %box-height %child-scale mul temp %child-swing-scale -1 mul temp %box-width %temp sum x %x %temp exit :drawthiskid if %thiskid == pop goto next if %thiskid == null exit sum nexty %nexty %stroke-width %xstroke-width call path2parent %drawbox %thiskid %x %nexty :next mul temp %box-width %child-swing-scale sum x %x %temp mul font-size %font-size %child-scale mul box-height %box-height %child-scale mul box-width %box-width %child-scale xif %revealing-path div box-width %box-width %child-scale mul stroke-width %stroke-width %child-scale mul fill-opacity %fill-opacity %child-scale exit :path2parent (converts path list to single dotted name) goto next . %path :next set parent %2 if %parent == null exit goto next . %3 %4 %5 %6 %7 %8 %9 :next :path2parent.loop if " %1 " == " null " exit concat parent %1 . %parent set path2parent.list %2 %3 %4 %5 %6 %7 %8 %9 goto path2parent.loop . %path2parent.list :define parent children linked lists set parent %1 set kids %2 %3 %4 %5 %6 %7 %8 %9 #add more kids to this parent's list of children concat parent.children %parent .children point children %parent.children set %parent.children %children %kids #add this parent to each child's list of parents goto define.loop . %kids null :define.loop set thiskid %1 set kids %2 %3 %4 %5 %6 %7 %8 %9 null if %thiskid == null exit concat thiskids.parents %thiskid .parents point family %thiskids.parents set %thiskids.parents %family %parent goto define.loop . %kids # ------------------------------------------stack routines :pathpopper #sets path, path.rev, path.0 ~ path.20 set path0 %path1 set path1 %path2 set path2 %path3 set path3 %path4 set path4 %path5 set path5 %path6 set path6 %path7 set path7 %path8 set path8 %path9 set path9 %path10 set path10 %path11 set path11 %path12 set path12 %path13 set path13 %path14 set path14 %path15 set path15 %path16 set path16 %path17 set path17 %path18 set path18 %path19 set path19 %path20 set path20 "" set path %path1 %path2 %path3 %path4 %path5 %path6 %path7 %path8 %path9 %path10 %path11 %path12 %path13 %path14 %path15 %path16 %path17 %path18 %path19 %path20 %path21 %path22 set path.rev %path20 %path19 %path18 %path17 %path16 %path15 %path14 %path13 %path12 %path11 %path10 %path9 %path8 %path7 %path6 %path5 %path4 %path3 %path2 %path1 xsave 2.txt "pathpopp %path0 - %path " exit :pathpusher item set path20 %path19 set path19 %path18 set path18 %path17 set path17 %path16 set path16 %path15 set path15 %path14 set path14 %path13 set path13 %path12 set path12 %path11 set path11 %path10 set path10 %path9 set path9 %path8 set path8 %path7 set path7 %path6 set path6 %path5 set path5 %path4 set path4 %path3 set path3 %path2 set path2 %path1 set path1 %1 set path %path1 %path2 %path3 %path4 %path5 %path6 %path7 %path8 %path9 %path10 %path11 %path12 %path13 %path14 %path15 %path16 %path17 %path18 %path19 %path20 set path.rev %path20 %path19 %path18 %path17 %path16 %path15 %path14 %path13 %path12 %path11 %path10 %path9 %path8 %path7 %path6 %path5 %path4 %path3 %path2 %path1 xsave 2.txt "path.rev %path.rev " exit :kidspopper (for recursive to-do list stacking) set kid0 %kids1 set kids1 %kids2 set kids2 %kids3 set kids3 %kids4 set kids4 %kids5 set kids5 %kids6 set kids6 %kids7 set kids7 %kids8 set kids8 %kids9 set kids9 %kids10 set kids10 %kids11 set kids11 %kids12 set kids12 %kids13 set kids13 %kids14 set kids14 %kids15 set kids15 %kids16 set kids16 %kids17 set kids17 %kids18 set kids18 %kids19 set kids19 %kids20 set kids20 %kids21 set kids21 %kids22 set kids22 %kids23 set kids23 %kids24 set kids24 %kids25 set kids25 %kids26 set kids26 %kids27 set kids27 %kids28 set kids28 %kids29 set kids29 %kids30 set kids %kids1 %kids2 %kids3 %kids4 %kids5 %kids6 %kids7 %kids8 %kids9 %kids10 %kids11 %kids12 %kids13 %kids14 %kids15 %kids16 %kids17 %kids18 %kids19 %kids20 %kids21 %kids22 %kids23 %kids24 %kids25 %kids26 %kids27 %kids28 %kids29 %kids30 xsave 2.txt "kidspopp %kid0 - %kids " exit :kidspusher kids to be added to the stack goto kidspusher.rev . %9 %8 %7 %6 %5 %4 %3 %2 %1 :kidspusher.rev if " %1 " == " skip " goto skip set kids30 %kids29 set kids29 %kids28 set kids28 %kids27 set kids27 %kids26 set kids26 %kids25 set kids25 %kids24 set kids24 %kids23 set kids23 %kids22 set kids22 %kids21 set kids21 %kids20 set kids20 %kids19 set kids19 %kids18 set kids18 %kids17 set kids17 %kids16 set kids16 %kids15 set kids15 %kids14 set kids14 %kids13 set kids13 %kids12 set kids12 %kids11 set kids11 %kids10 set kids10 %kids9 set kids9 %kids8 set kids8 %kids7 set kids7 %kids6 set kids6 %kids5 set kids5 %kids4 set kids4 %kids3 set kids3 %kids2 set kids2 %kids1 set kids1 %1 set kids %kids1 %kids2 %kids3 %kids4 %kids5 %kids6 %kids7 %kids8 %kids9 %kids10 %kids11 %kids12 %kids13 %kids14 %kids15 %kids16 %kids17 %kids18 %kids19 %kids20 %kids21 %kids22 %kids23 %kids24 %kids25 %kids26 %kids27 %kids28 %kids29 %kids30 goto kidspusher.rev . %2 %3 %4 %5 %6 %7 %8 %9 skip :skip xsave 2.txt "kidspush %kids " exit :parent-settings set stroke black set stroke-width 2 set font-Size 12 set text-anchor left set width 90 set height 40 set parent null exit :child-settings set stroke black set font-Size 8 set text-anchor middle set width 90 set height 20 set gapY 0 exit :store id variableName set store.source %2 concat store.name %1 . %2 point store.value %store.source xset %store.name %store.value concat store.name : %store.name # save to database-sub-script save db.txt "" save db.txt %store.name save db.txt set itemvalue %store.value save db.txt exit exit #--------------------------------------- recall parent from database, all known (co)ordinates by name :recallBoxdata return Owner set recalf %recall . %1 %2 %recalf x %recalf y %recalf width %recalf height %recalf cx %recalf cy %recalf nextX %recalf nextY %recalf textX %recalf textY %recalf right %recalf bottom %recalf font-size %recalf text-anchor %recalf fill %recalf fill-opacity %recalf stroke %recalf stroke-width %recalf stroke-opacity exit :recall return owner(row) item(column) concat return %1 . %3 set recall.owner %2 concat itemname %2 . %3 xpoint itemValue %itemname set itemvalue 0 # if owner is missing then skip xpoint test %recall.owner xconcat test %test empty xtextpict 1 "test %test xif " %test " == " empty " goto skip # otherwise call %itemname db.txt :skip set %return %itemValue save 2.txt # recall %return %itemValue %recall.owner exit :recallTableData return tableName rowID columnName ------------------------------------------- concat recallTableData.return %1 concat recallTableData.name %2 . %3 . %4 point recallTableData.value %recallTableData.name set %recallTableData.return %recallTableData.value exit :readTableColumnNames list of column names concat c1 %1 concat c2 %2 concat c3 %3 concat c4 %4 concat c5 %5 concat c6 %6 concat c7 %7 concat c8 %8 concat c9 %9 set readTable.row 0 exit :readTableDataRow sum readTable.row %readTable.row 1 concat d1 %1 set d2 %2 set d3 %3 set d4 %4 set d5 %5 set d6 %6 set d7 %7 set d8 %8 set d9 %9 concat e0 %c1 . %d1 .row concat e1 %c1 . %d1 . %c1 concat e2 %c1 . %d1 . %c2 concat e3 %c1 . %d1 . %c3 concat e4 %c1 . %d1 . %c4 concat e5 %c1 . %d1 . %c5 concat e6 %c1 . %d1 . %c6 concat e7 %c1 . %d1 . %c7 concat e8 %c1 . %d1 . %c8 concat e9 %c1 . %d1 . %c9 set %e0 %readTable.row set %e1 %d1 set %e2 %d2 set %e3 %d3 set %e4 %d4 set %e5 %d5 set %e6 %d6 set %e7 %d7 set %e8 %d8 set %e9 %d9 exit :drawChildren parent count list ------------------------------------------:drawChildren set parent %1 set childCount %2 set drawLoopItem %3 set drawLoopList %4 %5 %6 %7 %8 %9 null %recallBoxData parent %parent mul x %child-scale.left %parent.width sum x %parent.x %x sum y %parent.texty %parent.font-size mul box-width %child-scale.width %parent.width mul box-height %y -1 sum box-height %parent.bottom %box-height div box-height %box-height %childCount sum box-height %box-height %child.shift.bottom mul child.shift.bottom.neg %child.shift.bottom -1 mul font-size %parent.font-size 0.9 #div font-size %font-size %childCount %drawBox %drawLoopItem %x %y goto drawChildrenLoop . %drawLoopList :drawChildrenLoop list if %1 == null exit set drawLoopItem %1 set drawLoopList %2 %3 %4 %5 %6 %7 %8 %9 null sum y %y %box-height %child.shift.bottom.neg %drawBox %drawLoopItem %x %Y goto drawChildrenLoop . %drawLoopList #------------------------------------------------------------------------ stack builder :drawStack set parent %1 set drawStackItem %2 set drawStackList " %3 %4 %5 %6 %7 %8 %9 null " %recallBoxData Parent %parent %drawBox %drawStackItem %parent.x %parent.nexty goto drawstackLoop . %drawStackList :drawstackLoop if %1 == null exit set drawStackItem %1 set drawStackList " %2 %3 %4 %5 %6 %7 %8 %9 null " %drawBox %drawStackItem %parent.x %nextY goto drawstackLoop . %drawStackList #------------------------------------------------------------------------ boxes maker :drawBox id x y set text %1 concat id %1 set prevx %x set prevy %y set x %2 set y %3 set %id box textpict 1 %parent textpict 2 %thiskid textpict 3 %text textpict 4 %id concat wire %id .wire point wire %wire set wire %wire %default.wire if %parent <> null concat id %parent . %id if %parent <> null save tree.txt "%connect %parent %id if %revealing-path set text %id set width %box-width set height %box-height mul -w -1 %width #--------------------------------------- build a database of drawing settings by name sum nextX %x %width %gapX sum nextY %y %height %gapY %store %id width %store %id height %store %id wire x%store %id font-size x%store %id text-anchor x%store %id fill x%store %id fill-opacity x%store %id stroke x%store %id stroke-width x%store %id stroke-opacity %store %id x %store %id y %store %id nextx %store %id nexty #calculate right and bottom edges sum right %x %width sum bottom %y %height %store %id right %store %id bottom #calculate and store middle values sum cx %x %right sum cy %y %bottom mul cx %cx 0.5 mul cy %cy 0.5 %store %id cx %store %id cy if %right > %svg.right set svg.right %right if %bottom > %svg.bottom set svg.bottom %bottom #---------------------------------------------------- position the text while adjusting for font size concat text-anchor-type text-anchor= %text-anchor goto %text-anchor-type :text-anchor=left mul hFontSize %font-Size 0.15 sum textX %x %hFontSize sum textY %y %font-Size %hfontSize goto writesvgbox :text-anchor=right set textX %right set textY %bottom goto writesvgbox :text-anchor=middle mul hFontSize %font-Size 0.3 set textX %cx sum textY %cy %hFontSize :writesvgbox %writesvg " %store %id textX %store %id textY if %drawitemtext == true goto drawText . %textX %textY exit :drawWord word x y set text %1 goto drawtext . %2 %3 :drawText textX textY set textX %1 set textY %2 %writesvg " %text exit #------------------------------------------------------------------------ line drawing procedures :drawlinestyled stroke stroke-width parent child source target set stroke %1 set stroke-width %2 set parent %3 set child %4 goto drawlinelogical . %5 %6 :drawlinelogical id1 id2 # will detirmine lineformat and facets set id1 %1 set id2 %2 if %swap-terminus %swap id1 id2 textpict 1 %stroke textpict 2 %stroke-width textpict 3 %id1 textpict 4 %id2 if %parent == null goto skip . # no need to prepend parent to id set idsave %id1 concat id1 %parent . %id1 %recall idt %id1 x if %idt.x == 0 set id1 %idsave set idsave %id2 concat id2 %parent . %id2 %recall idt %id2 x if %idt.x == 0 set id2 %idsave :skip if %child == null goto skip . # no need to append child to id set idsave %id1 concat id1 %id1 . %child # if the child is missing, revert to idsave %recall idt %id1 x if %idt.x == 0 set id1 %idsave # same for child2 set idsave %id2 concat id2 %id2 . %child %recall idt %id2 x if %idt.x == 0 set id2 %idsave :skip # test-for-element-non-zero save 2.txt #linelogical %id1 %id2 %recall id1 %id1 x if %id1.x == 0 exit %recall id2 %id2 x if %id2.x == 0 exit %recall id1 %id1 cy %recall id2 %id2 cy %recall id1 %id1 right %recall id2 %id2 right %recall id1 %id1 wire goto next . %id1.wire :next if %stroke == default set stroke %1 if %stroke-width == default set stroke-width %2 # calculate-deltas mul dx %x2 -1 sum dx %dx %x1 if %dx < 0 mul dx %dx -1 mul dy %y2 -1 sum dy %dy %y1 if %dy < 0 mul dy %dy -1 # set-defaults set x1 %id1.right set x2 %id2.right set y1 %id1.cy set y2 %id2.cy set lineformat %drawjumper set source-terminus %drawcircle %x1 %y1 %stroke-width set target-terminus %drawarrowhead %x2 %y2 1 # test for swerve format usability if %id1.right < %id2.x goto maybe if %id1.x > %id2.right goto maybe goto ready :maybe set lineformat %drawswerve if %id1.right < %id2.x set x2 %id2.x if %id1.x > %id2.right set x1 %id1.x set source-terminus %drawcircle %x1 %y1 %stroke-width set target-terminus %drawarrowhead %x2 %y2 1 if %id1.right < %id2.x set target-terminus %drawarrowhead %x2 %y2 -1 :ready save connections.txt "%connect" %stroke %stroke-width null null %id1 %id2 %source-terminus %lineformat %x1 %y1 %x2 %y2 %target-terminus exit :drawLineBottomToTop id1 id2 goto drawlineByName . cx bottom cx y %1 %2 :drawLineRightToLeft id1 id2 goto drawlineByName . right cy x cy %1 %2 :drawlineByName x1 y1 x2 y2 id1 id2 set x1 %1 set y1 %2 set x2 %3 set y2 %4 set id1 %5 set id2 %6 #build names of database elements if %child == null goto skip . (no need to append child to id) concat id1 %id1 . %child concat id2 %id2 . %child #if the child1 is missing revert to the original id concat idt %5 . %child .x point idt %idt sum idt %idt 0 if %idt == 0 set id1 %5 #same for child2 concat idt %6 . %child .x point idt %idt sum idt %idt 0 if %idt == 0 set id2 %6 :skip if %parent == null goto skip . (no need to prepend parent to id) concat id1 %parent . %id1 concat id2 %parent . %id2 :skip concat x1 %id1 . %x1 concat x2 %id2 . %x2 concat y1 %id1 . %y1 concat y2 %id2 . %y2 #pull in data to local variables point x1 %x1 point x2 %x2 point y1 %y1 point y2 %y2 %lineformat %x1 %y1 %x2 %y2 exit :drawswerve x1 y1 x2 y2 set x1 %1 set y1 %2 set x2 %3 set y2 %4 sum xc %x1 %x2 mul xc %xc 0.5 sum yc %y1 %y2 mul yc %yc 0.5 mul xd %x1 -1 sum xd %xd %x2 mul yd %y1 -1 sum yd %yd %y2 mul xa %xd 0.35 sum xa %xa %x1 mul xb %xd 0.65 sum xb %xb %x1 mul ya %yd 0.00 sum ya %ya %y1 mul yb %yd 1.00 sum yb %yb %y1 %writesvg "" exit :drawline x1 y1 x2 y2 set x1 %1 set y1 %2 set x2 %3 set y2 %4 %writesvg " exit :drawlineconnects x1 y1 x2 y2 set x1 %1 set y1 %2 set x2 %3 set y2 %4 %writesvg " mul r %stroke-width 0.5 if %line-term-1 == none goto next %writesvg " :next if %line-term-2 == none goto next %writesvg " :next exit :drawcircle x y r set circle.cx %1 set circle.cy %2 set circle.radius %3 if %circle.radius < 0.0 mul circle.radius %circle.radius -1 %writesvg " exit :drawjumper x1 y1 x2 y2 set x1 %3 set y1 %4 set x2 %1 set y2 %2 sum yn %y1 %y2 mul yn %yn 0.5 set xr %x1 if %x1 < %x2 set xr %x2 mul xn %y1 -1 sum xn %xn %yn if %xn < 0 mul xn %xn -1 sum xn %xn %xr if %xn > %svg.right set svg.right %xn %writesvg "" exit :drawarc x1 y1 x2 y2 mul xd %3 -1 sum xd %xd %1 mul yd %2 -1 sum yd %yd %4 sum xc %1 %3 mul xc %xc 0.5 sum yc %2 %4 mul yc %yc 0.5 sum xQ %xc %yd sum yQ %yc %xd goto drawcurve . %1 %2 %xQ %yQ %3 %4 :drawcurve v1 vC v2 %writesvg "" exit #------------------------------------------------------------------------ save and quit :close-svg-file %writesvg " #cleanup due to the limitations of passing the quote characters as parameters start fix.bat wait 0.5 start %outputfilename halt delete fix.bat save fix.bat "changer.exe %outputfilename /from \009 /to \032 save fix.bat pause save fix.bat "changer.exe %outputfilename /from ODQ\032 /to \034 save fix.bat "changer.exe %outputfilename /from \032CDQ /to \034 save fix.bat "changer.exe %outputfilename /from DQ /to \034 start fix.bat wait 2 start %outputfilename halt set delay rd 0.75 start changer.exe " %outputfilename /from \009 /to \032 %delay start changer.exe " %outputfilename /from ODQ\032 /to \034 %delay start changer.exe " %outputfilename /from \032CDQ /to \034 %delay start changer.exe " %outputfilename /from DQ /to \034 %delay start %outputfilename halt #------------------------------------------------------------------------ polygons :drawPolygon takes: item-id ; assumes: polygon.form .cx .cy .radius .radius2 concat polygon-id %1 set polygon.text %1 #itemize center concat temp %polygon-id .cx set %temp %polygon.cx concat temp %polygon-id .cy set %temp %polygon.cy concat temp %polygon-id .cv set %temp %polygon.cx %polygon.cy set polygon.cv %polygon.cx %polygon.cy set text-anchor middle #itemize radii concat temp %polygon-id .radius set %temp %polygon.radius concat temp %polygon-id .radius2 set %temp %polygon.radius2 #initialize extents set polygon.left %polygon.cx set polygon.right %polygon.cx set polygon.top %polygon.cy set polygon.bottom %polygon.cy #initialize variables for polyfunc set polyfunc call polyfunc . set svgpath " #itemize x0.5 y0.5 v0.5 concat temp %polygon-id .x0.5 sum value %firstx %lastx mul value %value 0.5 set %temp %value set vertex %value concat temp %polygon-id .y0.5 sum value %firsty %lasty mul value %value 0.5 set %temp %value concat temp %polygon-id .v0.5 set %temp %vertex %value set polygon.midv %vertex %value #itemize extents left right top bottom concat temp %polygon-id .left set %temp %polygon.left concat temp %polygon-id .right set %temp %polygon.right concat temp %polygon-id .top set %temp %polygon.top concat temp %polygon-id .bottom set %temp %polygon.bottom #itemize width height concat temp %polygon-id .width mul value %polygon.left -1 sum %temp %value %polygon.right concat temp %polygon-id .height mul value %polygon.top -1 sum %temp %value %polygon.bottom if %print.vertex.dot != true goto next %drawcircle %polygon.midv %vertex-dot.radius :next if %print.vertex.dot != true goto next %drawcircle %polygon.v %vertex-dot.radius if %lastpoint == 1 goto next %drawcircle %polygon.midv %vertex-dot.radius if %print.vertex.name != true goto next set text left %drawtext %polygon.left %polygon.cy set text right %drawtext %polygon.right %polygon.cy set text top %drawtext %polygon.cx %polygon.top set text bottom %drawtext %polygon.cx %polygon.bottom :next if %drawitemtext != true exit set text %polygon.text goto drawText . %polygon.cv :polygon:tables "%polyfunc" sine cosine name extents :triangle :poly3 %polyFunc 0.000 1.000 A set path.mode L %polyFunc 0.866 -0.500 B %polyFunc -0.866 -0.500 C exit :diamond :poly4 %polyFunc 0.000 1.000 A set path.mode L %polyFunc 1.000 0.000 B %polyFunc 0.000 -1.000 C %polyFunc -1.000 0.000 D exit :square set polygon.radius2 %polygon.radius :poly4rot %polyFunc 0.707 0.707 A set path.mode L %polyFunc 0.707 -0.707 B %polyFunc -0.707 -0.707 C %polyFunc -0.707 0.707 D exit :poly5 %polyFunc 0.000 1.000 A set path.mode L %polyFunc 0.951 0.309 B %polyFunc 0.588 -0.809 C %polyFunc -0.588 -0.809 D %polyFunc -0.951 0.309 E exit :house mul polygon.radius2 %polygon.radius 0.6 :poly5rot %polyFunc 0.588 0.809 A set path.mode L %polyFunc 0.951 -0.309 B %polyFunc 0.000 -1.000 C %polyFunc -0.951 -0.309 D %polyFunc -0.588 0.809 E exit :poly6 %polyFunc 0.000 1.000 A set path.mode L %polyFunc 0.866 0.500 B %polyFunc 0.866 -0.500 C %polyFunc 0.000 -1.000 D %polyFunc -0.866 -0.500 E %polyFunc -0.866 0.500 F exit :poly6rot :hexagon %polyFunc 0.500 0.866 A set path.mode L %polyFunc 1.000 0.000 B %polyFunc 0.500 -0.866 C %polyFunc -0.500 -0.866 D %polyFunc -1.000 0.000 E %polyFunc -0.500 0.866 F exit :poly8 %polyFunc 0.000 1.000 A set path.mode L %polyFunc 0.707 0.707 B %polyFunc 1.000 0.000 C %polyFunc 0.707 -0.707 D %polyFunc 0.000 -1.000 E %polyFunc -0.707 -0.707 F %polyFunc -1.000 0.000 G %polyFunc -0.707 0.707 H exit :poly8rot :octogon %polyFunc 0.383 0.924 A set path.mode L %polyFunc 0.924 0.383 B %polyFunc 0.924 -0.383 C %polyFunc 0.383 -0.924 D %polyFunc -0.383 -0.924 E %polyFunc -0.924 -0.383 F %polyFunc -0.924 0.383 G %polyFunc -0.383 0.924 H exit :poly10 :star %polyFunc 0.000 1.000 A set path.mode L %polyFunc 0.588 0.809 B %polyFunc 0.951 0.309 C %polyFunc 0.951 -0.309 D %polyFunc 0.588 -0.809 E %polyFunc 0.000 -1.000 F %polyFunc -0.588 -0.809 G %polyFunc -0.951 -0.309 H %polyFunc -0.951 0.309 I %polyFunc -0.588 0.809 J exit :poly10rot %polyFunc 0.309 0.951 A set path.mode L %polyFunc 0.809 0.588 B %polyFunc 1.000 0.000 C %polyFunc 0.809 -0.588 D %polyFunc 0.309 -0.951 E %polyFunc -0.309 -0.951 F %polyFunc -0.809 -0.588 G %polyFunc -1.000 0.000 H %polyFunc -0.809 0.588 I %polyFunc -0.309 0.951 J exit :starofdavid mul polygon.radius2 %polygon.radius 0.57 :poly12 %polyFunc 0.000 1.000 A set path.mode L %polyFunc 0.500 0.866 B %polyFunc 0.866 0.500 C %polyFunc 1.000 0.000 D %polyFunc 0.866 -0.500 E %polyFunc 0.500 -0.866 F %polyFunc 0.000 -1.000 G %polyFunc -0.500 -0.866 H %polyFunc -0.866 -0.500 I %polyFunc -1.000 0.000 J %polyFunc -0.866 0.500 K %polyFunc -0.500 0.866 L exit :poly12rot %polyFunc 0.259 0.966 A set path.mode L %polyFunc 0.707 0.707 B %polyFunc 0.966 0.259 C %polyFunc 0.966 -0.259 D %polyFunc 0.707 -0.707 E %polyFunc 0.259 -0.966 F %polyFunc -0.259 -0.966 G %polyFunc -0.707 -0.707 H %polyFunc -0.966 -0.259 I %polyFunc -0.966 0.259 J %polyFunc -0.707 0.707 K %polyFunc -0.259 0.966 L exit :polyFunc x y polyFunc.vertex.name set x %1 set y %2 set polyFunc.vertex.name %3 mul x %x %polygon.radius mul y %y %polygon.radius sum x %x %polygon.cx sum y %y %polygon.cy set svgpath %svgpath " " %path.mode %x %y :polyFunc:swap-radii set temp %polygon.radius set polygon.radius %polygon.radius2 set polygon.radius2 %temp #itemize vertii concat temp %polygon-id .x %poly.point set %temp %x concat temp %polygon-id .y %poly.point set %temp %y concat temp %polygon-id .v %poly.point set %temp %x %y set polygon.v %x %y #update extents if %x < %polygon.left set polygon.left %x if %x > %polygon.right set polygon.right %x if %y < %polygon.top set polygon.top %y if %y > %polygon.bottom set polygon.bottom %y if %poly.point == 1 goto point=1 #itemize mid segment concat temp %polygon-id .x %lastpoint .5 sum value %x %lastx mul value %value 0.5 set %temp %value set polygon.midv %value concat temp %polygon-id .y %lastpoint .5 sum value %y %lasty mul value %value 0.5 set %temp %value concat temp %polygon-id .v %lastpoint .5 set %temp %polygon.midv %value set polygon.midv %polygon.midv %value goto next :point=1 set firstX %x set firstY %y :next set lastx %x set lasty %y set lastpoint %poly.point sum poly.point %poly.point 1 if %print.vertex.dot != true goto next %drawcircle %polygon.v %vertex-dot.radius if %lastpoint == 1 goto next %drawcircle %polygon.midv %vertex-dot.radius :next if %print.vertex.name != true exit set text %polyFunc.vertex.name goto drawtext . %x %y :drawArrowHead x y direction mul a %stroke-width 3 mul b %stroke-width -.8 mul c %stroke-width 1.6 if %3 < 0 mul a %a -1 %writesvg "" exit