%! % POSTSCRIPT SVG CIRXUT FRONT END ps2svg1.psl % ============================================= % by Don Lancaster v1.0 September 2, 2018 % ===================== % Copyright c. 2018 by Don Lancaster and Synergetics, Box 809, % Thatcher AZ, 85552 (428) 428-4073. synergetics@tinaja.com % All commercial rights and all electronic media rights *fully* % reserved. Linking welcome. Reposting is expressly forbidden. % Further support on http://www.tinaja.com % Consulting services available via don@tinaja.com % This PostScrit code is a front end interface for web SVG % and the Cricut machine from https://shop.cricut.com/. % It automatically generates SVG files from appropriate code. % It specifically models a portion of the demo of % https://www.w3.org/Graphics/SVG/IG/resources/svgprimer.html % ========= % This file requires the previous download of gonzo.psl % available from http://www.tinaja.com/post01.asp % Make sure the following line agrees with your own gonzo.psl location (C:/Users/don/Desktop/gonzo/gonzo.psl) run % use internal gonzo % ========== gutility begin % turn on the gonzo utilities nuisance begin % turn on the nuisance commands printerror % turn on the printing error trapper % IMPORTANT NOTE: This file DEMANDS Acrobat Distiller be run from % the Windows command line using a magic incantation of //acrodist /F . % This is required to allow reading and writing of disk or USB based files. % PostScript Reference Manual at % https://www.adobe.com/content/dam/acom/en/devnet/actionscript/articles/PLRM.pdf % More PostScript Support at https://www.tinaja.com/pssamp1.shtml % PostScript Video at https://www.youtube.com/watch?v=C_tWW560tAE % ///////// WEB FRIENDLY COLOR UTILITY ///////////// % tintmat is a self-generating list of 216 triple color values % not yet in gonzo /webtintmat [ 0 1 5 { /a exch store 0 1 5 { /b exch store 0 1 5 { 5 div b 5 div a 5 div }for } for } for ] def % setwebtint accepts a color number 0 to 215 and then % sets the PostScript color generator for later use... /setwebtint { abs cvi 216 cvi mod % restrict range webtintmat exch 3 mul 3 getinterval % get values from table aload pop setrgbcolor} def % and set them %%%%%%%%%%%% service procs %%%%%%%%%%%%%%%%%%%%% /yellow.svg {35 setwebtint /curcolor ("yellow")store } store /green.svg {18 setwebtint /curcolor ("green") store } store /circle.svg {/rad exch store /cy exch store /cx exch store newpath cx cy rad 0 360 arc % x y r ang1 ang2 arc wf (\n \" to sequence wf ( stroke=) curcolor mergestr ( )mergestr writestring wf ( stroke-width=") currentlinewidth cvi 5 string cvs mergestr ("\>\n) mergestr writestring } store /setwhgrid { /inch {72 mul} store 2 inch 8 inch translate pssf dup neg scale % reverse vertical! } store /showwhgrid { gsave % grid on ps only! 0 setlinewidth 33 setwebtint [{0 0 mt width r} width psres div 11 ] yrpt [{0 0 mt height u} height psres div 11 ] xrpt width 200 div setlinewidth 0 0 mt width r 0 width 2 div mt width r 0 width mt width r 0 0 mt height u height 2 div 0 mt height u height 0 mt height u grestore} store /startdoc { includeshtml { % only if html wf (\\n) writestring wf (\\n) writestring wf (\\n) writestring wf (\n) writestring } if wf (\\n) writestring % everybody wf (\) mergestr writestring wf (\n) writestring } store /enddoc { wf (\n Sorry, your browser does not support inline SVG.\n) writestring wf (\n\\n) writestring includeshtml { wf (\\n) writestring wf (\\n) writestring } if } store %%%%%%%%%%%%% presently supported svg commands %%%%%%% % width height cx cy rad circle yellow green stroke stroke-width % %%%%%%%%%%%% Example #1 - green yellow circle %%%%%%%%%%%%%%%%%%% /gycirc1 { % green & yellow circle % file management header ( required for each proc ) ... /thispsfilename (/ps2svg2.psl) store % update for back reference! /includeshtml true store % full shtml or just svg? /svgfilename (gycirc1) store % filename ( less postfix! ) /svgfilenameprefix % local dest file prefix MUST EDIT! (C:/Users/don/Desktop/web/new_psutils818/psutils/ps2xml/) store /wf svgfilenameprefix svgfilename % open svg dest file mergestr includeshtml { % add postfix (.shtml)}{(.svg)} ifelse mergestr (w+) file store % begin custom ps to svg code ... /pssf 2 store % PDF display scale factor /showPDFgrid true store % include optional PDF grid? /putgridontop true store % place optional grid on top? /psres 10 store % optional PDF grid line spacing /width 100 store % size of svg bounding box /height 100 store setwhgrid % ps display at pssf magnification showPDFgrid {showwhgrid} if % false = no optional pdf grids startdoc % begin xml code & possibly shtml 50 50 48 circle.svg % as in cx cy rad gsave yellow.svg fill.svg grestore % fill circle 4 setlinewidth green.svg stroke.svg % stroke circle showPDFgrid putgridontop and % overlay grid? {showwhgrid} if enddoc % end xml code & possibly shtml wf closefile % close output file } store %%%%%%%%% select code to run here %%%%%%%%%%%%%%%% gycirc1 % uncomment to run % EOF %