44
44
// Fix for SVG Style attribute errors if no ; is found i.e. attribute is last attribute of style string the code now works (untested)
45
45
// Fix for SVG Font Size Bug - px was replaced with 0 instead of "" meaning that some times 2px would turn to 20
46
46
// Fix: fontstyle or line style etc missing if style="" is used instead of font attributes. Error produced: fontstyle fontline fontfamily missing line 707-709 / Translate Rotate Scale missing 710-712 among others svg ARC 02 Should work now.
47
// Bug: Empty text in SVG text in proporcion
48
// Bug: If fill is after line, the change of fill is performed after line is drawn. (SVI_CFG from wikipedia and proporcion from wikipedia)
49
// Bug: translate support for groups or individual objects such as proporcion transform="translate(642.5,-1381.291)" or transform="matrix(0.999962,-8.674822e-3,8.674822e-3,0.999962,1115.829,2072.128)"
51
47
//-------------------------------------------------------------------------- Next Version Blueprint
53
49
// Curve Closing (html5)
54
50
// Support for transformed gradients (??Is this in current version??)
55
51
// Real Arc Drawing using Complex Math from values, draw arc using math in formula
72
function recurseelement($element){
73
global $elementcounter;
76
if($element->getName()=="clipPath"){
77
$attrs=$element->attributes();
78
$sxe = new SimpleXMLElement("<use id='".$attrs['id']."' />");
79
$graphnodes[$elementcounter]=$sxe;
54
$graphnodes = array();
55
$colorstops = array();
61
$gradientname = "foo";
64
$svgfilepath = "../media/svgconverter/";
66
function recurseelement( $element ) {
67
global $elementcounter;
69
if( $element -> getName() == "clipPath" ) {
70
$attrs = $element -> attributes();
71
$sxe = new SimpleXMLElement( "<use id='".$attrs['id']."' />" );
72
$graphnodes [$elementcounter] = $sxe;
83
foreach ($element->children() as $child) {
84
if($child->getName()=="clipPath"||$child->getName()=="defs"||$child->getName()=="g"||$child->getName()=="linearGradient"||$child->getName()=="radialGradient"){
86
// Most others except for clipPath are added
87
if($child->getName()=="defs"||$child->getName()=="g"||$child->getName()=="linearGradient"||$child->getName()=="radialGradient"){
88
$graphnodes[$elementcounter]=$child;
91
recurseelement($child);
93
}else if($child->getName()=="use"||$child->getName()=="ellipse"||$child->getName()=="circle"||$child->getName()=="stop"||$child->getName()=="polygon"||$child->getName()=="line"||$child->getName()=="polyline"||$child->getName()=="path"||$child->getName()=="rect"||$child->getName()=="text"){
94
// Add element to queue
95
$graphnodes[$elementcounter]=$child;
98
echo "//Unknown element: ".$child->getName()."<br>";
75
foreach( $element -> children() as $child ) {
76
if( $child -> getName() == "clipPath" || $child -> getName() == "defs" || $child -> getName() == "g" || $child -> getName() == "linearGradient" || $child -> getName() == "radialGradient" ) {
77
// Most others except for clipPath are added
78
if( $child -> getName() == "defs" || $child -> getName() == "g" || $child -> getName() == "linearGradient" || $child -> getName() == "radialGradient" ) {
79
$graphnodes [$elementcounter] = $child;
82
recurseelement( $child );
83
} else if( $child -> getName() == "use" || $child -> getName() == "ellipse" || $child -> getName() == "circle" || $child -> getName() == "stop" || $child -> getName() == "polygon" || $child -> getName() == "line" || $child -> getName() == "polyline" || $child -> getName() == "path" || $child -> getName() == "rect" || $child -> getName() == "text" ) {
84
// Add element to queue
85
$graphnodes [$elementcounter] = $child;
88
echo "//Unknown element: ".$child -> getName()."<br>";
102
if($element->getName()=="g"){
104
$attrs=$element->attributes();
105
$sxe = new SimpleXMLElement("<eg id='".$attrs['id']."' />");
106
$graphnodes[$elementcounter]=$sxe;
111
if($element->getName()=="defs"){
112
$sxe = new SimpleXMLElement("<defsend/>");
113
$graphnodes[$elementcounter]=$sxe;
91
if( $element -> getName() == "g" ) {
93
$attrs = $element -> attributes();
94
$sxe = new SimpleXMLElement( "<eg id='".$attrs['id']."' />" );
95
$graphnodes [$elementcounter] = $sxe;
98
if( $element -> getName() == "defs" ) {
99
$sxe = new SimpleXMLElement( "<defsend/>" );
100
$graphnodes [$elementcounter] = $sxe;
120
if(isset($_POST['svgname'])){
122
$svg = simplexml_load_file($_POST['svgname']);
124
// Recurse into elements and add to element stack
125
// its important that we only process hierarchies of g elements and layers
126
foreach ($svg as $element) {
127
if($element->getName()=="clipPath"||$element->getName()=="defs"||$element->getName()=="g"||$element->getName()=="linearGradient"||$element->getName()=="defs"||$element->getName()=="radialGradient"){
128
if($element->getName()=="clipPath"||$element->getName()=="defs"||$element->getName()=="g"||$element->getName()=="linearGradient"||$element->getName()=="radialGradient"){
129
$graphnodes[$elementcounter]=$element;
132
recurseelement($element);
133
}else if($element->getName()=="use"||$element->getName()=="radialGradient"||$element->getName()=="linearGradient"||$element->getName()=="polygon"||$element->getName()=="line"||$element->getName()=="polyline"||$element->getName()=="path"||$element->getName()=="rect"||$element->getName()=="ellipse"||$element->getName()=="circle"||$element->getName()=="text"){
134
// Add element to queue
135
$graphnodes[$elementcounter]=$element;
138
echo "//Unknown element: ".$element->getName()."\n";
148
foreach ($graphnodes as $graphelement) {
150
// Clear Line Style and Fill Styles
155
// For text element get
156
if($graphelement->getName()=="text"){
157
if(isset($graphelement[0])){
158
$textline=$graphelement[0];
162
// To get ID comment/code
163
$attrs=$graphelement->attributes();
164
$xlinkattrs=$graphelement->attributes('http://www.w3.org/1999/xlink');
166
// For use element get
167
if($graphelement->getName()=="use"){
168
if(isset($attrs['id'])){
169
// We are in an id use statement
170
$clipid=strval($attrs['id']);
172
// We are in the reference use statement
173
$clippaths[$clipid]=substr(strval($xlinkattrs['href']),1);
177
if($graphelement->getName()=="linearGradient"){
179
if(isset($attrs['id'])){
180
$gradientname=$attrs['id'];
182
if(!isset($attrs['x1'])){
183
// Linear Gradient is not complete, this means that it is an inkscape element!
185
}else if(isset($xlinkattrs['href'])){
187
echo "var ".$gradientname."=c.createLinearGradient(".$attrs['x1'].",".$attrs['y1'].",".$attrs['x2'].",".$attrs['y2'].");\n";
189
// Now we create a new gradient with the following properties
190
$gradientref=$xlinkattrs['href'];
191
$gradientref=substr($gradientref,1,strlen($gradientref)-1);
193
if(isset($colorstops["$gradientref"])){
194
foreach($colorstops["$gradientref"] as $key => $value){
195
echo $gradientname.".addColorStop(".$value.");\n";
200
echo "var ".$gradientname."=c.createLinearGradient(".$attrs['x1'].",".$attrs['y1'].",".$attrs['x2'].",".$attrs['y2'].");\n";
202
}else if($graphelement->getName()=="radialGradient"){
203
if(isset($attrs['id'])){
204
$gradientname=$attrs['id'];
206
if(!isset($attrs['cx'])){
207
// Radial Gradient is not complete, this means that it is an inkscape element!
209
}else if(isset($xlinkattrs['href'])){
210
echo "var ".$gradientname."=c.createRadialGradient(".$attrs['cx'].",".$attrs['cy'].",0,".$attrs['cx'].",".$attrs['cy'].",".$attrs['r'].");\n";
212
// Now we create a new gradient with the following properties
213
$gradientref=$xlinkattrs['href'];
214
$gradientref=substr($gradientref,1,strlen($gradientref)-1);
216
if(isset($colorstops["$gradientref"])){
217
foreach($colorstops["$gradientref"] as $key => $value){
218
echo $gradientname.".addColorStop(".$value.");\n";
223
echo "var ".$gradientname."=c.createRadialGradient(".$attrs['cx'].",".$attrs['cy'].",0,".$attrs['cx'].",".$attrs['cy'].",".$attrs['r'].");\n";
225
}else if($graphelement->getName()=="stop"){
226
$stopcolor=$attrs['style'];
227
if(strpos($stopcolor,";",11)!==false){
228
$stopcolorend=strpos($stopcolor,";",11);
230
$stopcolorend=strlen($stopcolor);
232
$stopcolor=substr($stopcolor,11,$stopcolorend-11);
235
if(isset($colorstops["$gradientname"])){
236
array_push($colorstops["$gradientname"],$attrs['offset'].",'".$stopcolor."'");
239
array_push($poo,$attrs['offset'].",'".$stopcolor."'");
240
$colorstops["$gradientname"]=$poo;
243
echo $gradientname.".addColorStop(".$attrs['offset'].",'".$stopcolor."');\n";
247
// We assume that defsid is the only use of ID
248
if(isset($attrs['id'])) $defsid=$attrs['id'];
251
// For each attribute of svg
253
// We process attributes after gradients but before the drawing elements.
255
foreach ($graphelement->attributes() as $key => $val) {
257
// Get font parameters!
258
if ($key == "if"&&$graphelement->getName()=="text"){
262
// Get font parameters!
263
if ($key == "font-size"&&$graphelement->getName()=="text"){
267
if ($key == "font-family"&&$graphelement->getName()=="text"){
269
$fontfamily=str_replace("'","",$fontfamily);
271
if(!(strpos($fontfamily,"-Oblique")===FALSE)){
272
$fontfamily=str_replace("-Oblique","",$fontfamily);
275
if(!(strpos($fontfamily,"-Bold")===FALSE)){
276
$fontfamily=str_replace("-Bold","",$fontfamily);
279
if(!(strpos($fontfamily,"-Italic")===FALSE)){
280
$fontfamily=str_replace("-Italic","",$fontfamily);
283
if(!(strpos($fontfamily,"Bold")===FALSE)){
284
$fontfamily=str_replace("Bold","",$fontfamily);
285
$fontstyle=$fontstyle." Bold";
287
if(!(strpos($fontfamily,"Italic")===FALSE)){
288
$fontfamily=str_replace("Italic","",$fontfamily);
289
$fontstyle=$fontstyle." Italic";
294
if ($graphelement->getName()=="text"){
295
if($key=="x") $textx=$val;
296
if($key=="y") $texty=$val;
299
if ($graphelement->getName()=="rect"){
300
if($key=="x") $linex1=$val;
301
if($key=="y") $liney1=$val;
302
if($key=="width") $linex2=$val;
303
if($key=="height") $liney2=$val;
306
if ($graphelement->getName()=="ellipse"||$graphelement->getName()=="circle"){
307
// Element is either a circle or an ellipse
308
if($key=="cx") $cx=$val;
309
if($key=="cy") $cy=$val;
314
if($key=="rx") $rx=$val;
315
if($key=="ry") $ry=$val;
318
if (($key == "x1"||$key == "y1"||$key == "x2"||$key == "y2")&&$graphelement->getName()=="line"){
319
// Element is a line element with 4 coordinate parameters
320
if($key=="x1") $linex1=$val;
321
if($key=="x2") $linex2=$val;
322
if($key=="y1") $liney1=$val;
323
if($key=="y2") $liney2=$val;
324
}else if ($key == "transform"&&$graphelement->getName()=="text"){
333
$dochr=substr($workstr,$j,1);
334
if($dochr==" "||$dochr=="("||$dochr==")"){
335
if(trim($dostr)!=""&&$dostr!="matrix"){
336
$params[$noparams++]=$dostr;
347
}while($j<=strlen($workstr));
348
if(trim($dostr)!=""){
349
$params[$noparams++]=$dostr;
352
$translate="c.translate(".$params[4].",".$params[5].");\n";
353
$rotate="c.rotate(".$params[1].",".$params[2].");\n";
354
$scale="c.scale(".$params[0].",".$params[3].");\n";
356
}elseif ($key == "stroke"){
357
echo "" .'c.strokeStyle = "' . $val . '";' . "\n";
359
}elseif ($key == "opacity"){
361
}elseif ($key == "fill"){
363
if(strpos($val,"url(")===false){
364
echo "" .'c.fillStyle = "' . $val. '";' . "\n";
366
echo "c.fillStyle=".substr($val,5,strlen($val)-6).";\n";
370
}elseif ($key == "style"){
371
$fillpos=strpos($val,"fill:");
372
if($fillpos!==false){
373
$fillposend=strpos($val,";",$fillpos);
374
if($fillposend===false) $fillposend=strlen($val);
375
$fillstyle=substr($val,$fillpos+5,$fillposend-$fillpos-5);
376
if($fillstyle!="none"){
377
if(strpos($fillstyle,"url(")===false){
378
echo "c.fillStyle = '".$fillstyle ."';\n";
380
echo "c.fillStyle=".substr($fillstyle,5,strlen($fillstyle)-6).";\n";
385
$strokepos=strpos($val,"stroke:");
386
if($strokepos!==false){
387
$strokeposend=strpos($val,";",$strokepos);
388
if($strokeposend===false) $strokeposend=strlen($val);
389
$linestyle=substr($val,$strokepos+7,$strokeposend-$strokepos-7);
390
if($linestyle!="none"){
391
echo "" .'c.strokeStyle = "' . $linestyle . '";' . "\n";
395
$strokepos=strpos($val,"stroke-width:");
396
if($strokepos!==false){
397
$strokeposend=strpos($val,";",$strokepos);
398
if($strokeposend===false) $strokeposend=strlen($val);
399
$strokewidth=substr($val,$strokepos+13,$strokeposend-$strokepos-13);
400
$strokewidth=str_replace("px","",$strokewidth);
401
echo "\n" . 'c.lineWidth = "' . $strokewidth . '";' . "\n";
404
$fontsizepos=strpos($val,"font-size:");
405
if($fontsizepos!==false){
406
$fontsizeend=strpos($val,";",$fontsizepos);
407
if($fontsizeend===false) $fontsizeend=strlen($val);
408
$fontline=substr($val,$fontsizepos+10,$fontsizeend-$fontsizepos-10);
409
$fontline=str_replace("px","",$fontline);
412
$fontfamilypos=strpos($val,"font-family:");
413
if($fontfamilypos!==false){
414
$fontfamilyend=strpos($val,";",$fontfamilypos);
415
if($fontfamilyend===false) $fontfamilyend=strlen($val);
416
$fontfamily=substr($val,$fontfamilypos+12,$fontfamilyend-$fontfamilypos-12);
419
$fontstylepos=strpos($val,"font-style:");
420
if($fontstylepos!==false){
421
$fontstyleend=strpos($val,";",$fontstylepos);
422
if($fontstyleend===false) $fontstyleend=strlen($val);
423
$fontstyle=substr($val,$fontstylepos+11,$fontstyleend-$fontstylepos-11);
426
}elseif ($key == "stroke-width"){
427
echo "\n" . 'c.lineWidth = "' . $val . '";' . "\n";
428
}elseif ($key == "points"&&($graphelement->getName()=="polygon"||$graphelement->getName()=="polyline"||$graphelement->getName()=="line")) {
430
$defsstring.="c.beginPath();\n";
432
echo "c.beginPath();\n";
435
// dostr loop for polygons. Bugfix: if old char is e, then we do not break string at -
445
$dochr=substr($workstr,$j,1);
446
if(($dochr=="-" && $oldchr!="e" && $oldchr!="E")||$dochr==","||$dochr==" "){
447
if(trim($dostr)!=""){
448
$params[$noparams++]=$dostr;
459
}while($j<=strlen($workstr));
460
if(trim($dostr)!=""){
461
$params[$noparams++]=$dostr;
464
for($j=0;$j<$noparams;$j+=2){
467
$defsstring.="c.moveTo(".$params[$j].",".$params[$j+1].");\n";
469
echo "c.moveTo(".$params[$j].",".$params[$j+1].");\n";
473
$defsstring.="c.lineTo(".$params[$j].",".$params[$j+1].");\n";
475
echo "c.lineTo(".$params[$j].",".$params[$j+1].");\n";
480
// If a polygon close path if not i.e. polyline keep it open
481
if($noparams>=2&&$graphelement->getName()=="polygon"){
483
$defsstring.="c.lineTo(".$params[0].",".$params[1].");\n";
485
echo "c.lineTo(".$params[0].",".$params[1].");\n";
490
echo "c.globalAlpha = $opacity;\n";
493
if($fillstyle=="none"&&$linestyle=="none"){
495
echo 'c.fillStyle = "#000";';
497
echo "c.fill();\n\n";
500
if($fillstyle!="none"){
503
if($linestyle=="none") echo "\n";
506
if($linestyle!="none"){
508
echo "c.stroke();\n\n";
513
$defsstring.="c.clip();\n\n";
516
}elseif ($key == "d") {
523
// Draw d line commands. This is a fix for the bug that requires the line settings to be assigned before the line commands
527
echo "c.beginPath();\n";
541
$chr=substr($str,$i,1);
542
if($chr=="H"||$chr=="h"||$chr=="V"||$chr=="v"||$chr=="M"||$chr=="m"||$chr=="C"||$chr=="c"||$chr=="L"||$chr=="A"||$chr=="a"||$chr=="l"||$chr=="z"||$chr=="Z"||$chr=="s"||$chr=="S"||$i==strlen($str)){
543
// Process Parameters for any parameter command
544
if($command=="M"||$command=="m"||$command=="c"||$command=="C"||$command=="v"||$command=="V"||$command=="h"||$command=="H"||$command=="s"||$command=="S"||$command=="l"||$command=="L"||$command=="a"||$command=="A"){
552
// dochr loop for other drawing commands. Bug fix: If we encounter - and before it is an e we do nothing, otherwise proceed as normal
556
$dochr=substr($workstr,$j,1);
557
if(($dochr=="-" && $oldchr!="e" && $oldchr!="E")||$dochr==","||$dochr==" "){
558
if(trim($dostr)!=""){
559
$params[$noparams++]=$dostr;
570
}while($j<=strlen($workstr));
571
if(trim($dostr)!=""){
572
$params[$noparams++]=$dostr;
576
if($command=="M" || $command=="m"){
577
for($j=0;$j<$noparams;$j+=2){
579
// Normal moveto set cx,cy
583
echo "c.moveTo(".$cx.",".$cy.");\n";
587
}else if($command=="m"){
591
echo "c.moveTo(".$cx.",".$cy.");\n";
598
echo "c.moveTo(".$cx.",".$cy.");\n";
606
echo "c.lineTo(".$cx.",".$cy.");\n";
607
}else if($command=="m"){
610
echo "c.lineTo(".$cx.",".$cy.");\n";
614
}else if ($command=="C"||$command=="c"){
616
for($j=0;$j<$noparams;$j+=6){
626
echo "c.bezierCurveTo(".$p1x.",".$p1y.",".$p2x.",".$p2y.",".$cx.",".$cy.");\n";
627
// Curveto absolute set cx to final point, other coordinates are control points
628
}else if($command=="c"){
629
// Curveto relative set cx to final point, other coordinates are relative control points
630
$p1x=$cx+$params[$j];
631
$p1y=$cy+$params[$j+1];
632
$p2x=$cx+$params[$j+2];
633
$p2y=$cy+$params[$j+3];
638
echo "c.bezierCurveTo(".$p1x.",".$p1y.",".$p2x.",".$p2y.",".$cx.",".$cy.");\n";
641
}else if ($command=="S"||$command=="s"){
642
//context . quadraticCurveTo(cpx, cpy, x, y)
644
for($j=0;$j<$noparams;$j+=4){
652
echo "c.bezierCurveTo(".$lastpointx.",".$lastpointy.",".$p1x.",".$p1y.",".$cx.",".$cy.");\n";
653
// Curveto absolute set cx to final point, other coordinates are control points
654
}else if($command=="s"){
655
// Curveto relative set cx to final point, other coordinates are relative control points
656
$p1x=$cx+$params[$j];
657
$p1y=$cy+$params[$j+1];
662
echo "c.bezierCurveTo(".$lastpointx.",".$lastpointy.",".$p1x.",".$p1y.",".$cx.",".$cy.");\n";
665
}else if ($command=="V"||$command=="v"){
667
for($j=0;$j<$noparams;$j++){
670
echo "c.lineTo(".$cx.",".$cy.");\n";
671
}else if($command=="v"){
672
// Curveto relative set cx to final point, other coordinates are relative control points
674
echo "c.lineTo(".$cx.",".$cy.");\n";
677
}else if ($command=="H"||$command=="h"){
679
for($j=0;$j<$noparams;$j++){
682
echo "c.lineTo(".$cx.",".$cy.");\n";
683
}else if($command=="h"){
684
// Curveto relative set cx to final point, other coordinates are relative control points
686
echo "c.lineTo(".$cx.",".$cy.");\n";
689
}else if ($command=="L"||$command=="l"){
691
for($j=0;$j<$noparams;$j+=2){
695
echo "c.lineTo(".$cx.",".$cy.");\n";
696
}else if($command=="l"){
697
// Curveto relative set cx to final point, other coordinates are relative control points
700
echo "c.lineTo(".$cx.",".$cy.");\n";
703
}else if ($command=="Z"||$command=="z"){
704
echo "c.lineTo(".$firstpointx.",".$firstpointy.");\n";
705
}else if ($command=="A"||$command=="a"){
706
// To avoid hard math - draw arc as a line
707
for($j=0;$j<$noparams;$j+=7){
711
$largeflag=$params[3];
712
$sweepflag=$params[4];
715
echo "c.lineTo(".$cx.",".$cy.");\n";
726
}while($i<=strlen($str));
728
echo "c.globalAlpha = $opacity;\n";
730
if($fillstyle=="none"&&$linestyle=="none"){
731
echo 'c.fillStyle = "#000";';
733
echo "c.fill();\n\n";
735
if($fillstyle!="none"){
736
// echo "c.save();\n\n";
737
// echo "c.scale(2.5,2.5);\n";
739
// echo "c.restore();\n\n";
740
if($linestyle=="none") echo "\n";
742
if($linestyle!="none"){
743
echo "c.stroke();\n";
751
if($graphelement->getName()=="text"){
753
echo "c.globalAlpha = $opacity;\n";
755
echo "c.beginPath();\n";
757
echo "c.font = '".$fontstyle." ".$fontline."px ".$fontfamily."';\n";
759
if(isset($translate)&&isset($rotate)&&isset($scale)){
765
if(isset($textx)&&isset($texty)){
766
echo "c.fillText('".$textline."',".$textx.",".$texty.");\n";
768
echo "c.fillText('".$textline."',0,0);\n";
772
if($linestyle!="none"){
773
if(isset($textx)&&isset($texty)){
774
echo "c.strokeText('".$textline."',".$textx.",".$texty.");\n";
776
echo "c.strokeText('".$textline."',0,0);\n";
780
echo "c.restore();\n\n";
782
}elseif($graphelement->getName()=="rect"){
784
// This rectangle must be clipped!
785
if(isset($attrs['clip-path'])){
786
$clipid=substr($attrs['clip-path'],5);
787
$clipid=substr($clipid,0,strlen($clipid)-1);
788
$clipid=$clippaths[$clipid];
792
echo $clipdefs[strval($clipid)];
795
echo "c.globalAlpha = $opacity;\n";
797
echo "c.beginPath();\n";
798
echo "c.moveTo(".$linex1.",".$liney1.");\n";
799
echo "c.lineTo(".($linex1+$linex2).",".($liney1).");\n";
800
echo "c.lineTo(".($linex1+$linex2).",".($liney1+$liney2).");\n";
801
echo "c.lineTo(".($linex1).",".($liney1+$liney2).");\n";
802
echo "c.lineTo(".($linex1).",".($liney1).");\n";
803
if($fillstyle!="none"){
804
// echo "c.save();\n\n";
805
// echo "c.scale(1,1);\n";
807
// echo "c.restore();\n\n";
809
if($linestyle=="none") echo "\n";
811
if($linestyle!="none"){
812
echo "c.stroke();\n";
814
// This rectangle must be clipped!
815
if(isset($attrs['clip-path'])){
816
echo "c.restore();\n";
105
if( isset( $_POST ['svgname'])) {
106
$svg = simplexml_load_file( $svgfilepath . $_POST ['svgname'] );
107
// Recurse into elements and add to element stack
108
// It is important to only process hierarchies of g elements and layers
109
foreach( $svg as $element ) {
110
if( $element -> getName() == "clipPath" || $element -> getName() == "defs" || $element -> getName() == "g" || $element -> getName() == "linearGradient" || $element -> getName() == "defs" || $element -> getName() == "radialGradient" ) {
111
if( $element -> getName() == "clipPath" || $element -> getName() == "defs" || $element -> getName() == "g" || $element -> getName() == "linearGradient" || $element -> getName() == "radialGradient" ) {
112
$graphnodes [$elementcounter] = $element;
115
recurseelement($element);
116
}else if( $element -> getName() == "use" || $element -> getName() == "radialGradient" || $element -> getName() == "linearGradient" || $element -> getName() == "polygon" || $element -> getName() == "line" || $element -> getName() == "polyline" || $element -> getName() == "path" || $element -> getName() == "rect" || $element -> getName() == "ellipse" || $element -> getName() == "circle" || $element -> getName() == "text") {
117
// Add element to queue
118
$graphnodes [$elementcounter] = $element;
121
echo "//Unknown element: ".$element -> getName()."\n";
129
foreach( $graphnodes as $graphelement ) {
130
// Clear Line Style and Fill Styles
134
// For text element get
135
if( $graphelement -> getName() == "text" ) {
136
if( isset( $graphelement[0])) {
137
$textline = $graphelement[0];
140
// To get ID comment/code
141
$attrs = $graphelement -> attributes();
142
$xlinkattrs = $graphelement -> attributes( 'http://www.w3.org/1999/xlink' );
143
// For use element get
144
if( $graphelement -> getName() == "use" ) {
145
if( isset( $attrs['id'] )) {
146
// We are in an id use statement
147
$clipid = strval( $attrs['id'] );
149
// We are in the reference use statement
150
$clippaths [$clipid] = substr( strval( $xlinkattrs ['href'] ),1);
153
if( $graphelement -> getName() == "linearGradient" ) {
154
if( isset( $attrs ['id'] )) {
155
$gradientname = $attrs ['id'];
157
if( !isset( $attrs['x1'] )) {
158
// Linear Gradient is not complete, this means that it is an inkscape element!
160
} else if( isset( $xlinkattrs ['href'] )) {
161
echo "var ".$gradientname." = c.createLinearGradient( ".$attrs['x1']." , ".$attrs['y1']." , ".$attrs['x2']." , ".$attrs['y2']." );\n";
162
// Now we create a new gradient with the following properties
163
$gradientref = $xlinkattrs ['href'];
164
$gradientref = substr( $gradientref, 1, strlen( $gradientref ) -1 );
165
if( isset( $colorstops ["$gradientref"] )){
166
foreach( $colorstops ["$gradientref"] as $key => $value) {
167
echo $gradientname.".addColorStop( ".$value." );\n";
171
echo " var ".$gradientname." = c.createLinearGradient( ".$attrs['x1']." , ".$attrs['y1']." , ".$attrs['x2']." , ".$attrs['y2']." );\n";
173
} else if( $graphelement -> getName() == "radialGradient" ) {
174
if( isset( $attrs ['id'] )) {
175
$gradientname = $attrs ['id'];
177
if( !isset( $attrs ['cx'])) {
178
// Radial Gradient is not complete, this means that it is an inkscape element!
180
} else if( isset( $xlinkattrs ['href'])) {
181
echo " var ".$gradientname." = c.createRadialGradient( ".$attrs['cx']." , ".$attrs['cy']." , 0 , ".$attrs['cx']." , ".$attrs['cy']." , ".$attrs['r']." );\n";
182
// Now we create a new gradient with the following properties
183
$gradientref = $xlinkattrs ['href'];
184
$gradientref = substr( $gradientref, 1, strlen( $gradientref )-1);
185
if( isset( $colorstops ["$gradientref"])) {
186
foreach( $colorstops ["$gradientref"] as $key => $value) {
187
echo $gradientname.".addColorStop( ".$value." );\n";
191
echo " var ".$gradientname." = c.createRadialGradient( ".$attrs['cx']." , ".$attrs['cy']." , 0, ".$attrs['cx']." , ".$attrs['cy']." , ".$attrs['r']." );\n";
193
} else if( $graphelement -> getName() == "stop" ) {
194
$stopcolor = $attrs ['style'];
195
if( strpos( $stopcolor, ";" , 11) !== false ) {
196
$stopcolorend = strpos( $stopcolor, ";" , 11);
198
$stopcolorend = strlen( $stopcolor );
200
$stopcolor = substr( $stopcolor, 11, $stopcolorend - 11 );
202
if( isset( $colorstops ["$gradientname"] )) {
203
array_push( $colorstops ["$gradientname"], $attrs['offset'].", '".$stopcolor."' " );
206
array_push( $poo, $attrs ['offset'].", '".$stopcolor."' " );
207
$colorstops ["$gradientname"] = $poo;
210
echo $gradientname.".addColorStop( ".$attrs['offset'].", '".$stopcolor."' );\n";
213
// We assume that defsid is the only use of ID
214
if( isset( $attrs ['id'] )) $defsid = $attrs ['id'];
216
// For each attribute of svg
217
// We process attributes after gradients but before the drawing elements.
218
foreach( $graphelement -> attributes() as $key => $val ) {
219
// Get font parameters!
220
if( $key == "if" && $graphelement -> getName() == "text" ) {
223
// Get font parameters!
224
if( $key == "font-size" && $graphelement -> getName() == "text" ) {
227
if( $key == "font-family" && $graphelement -> getName() == "text" ) {
229
$fontfamily = str_replace( "'", "", $fontfamily );
231
if( !( strpos( $fontfamily, "-Oblique" ) === FALSE )) {
232
$fontfamily = str_replace( "-Oblique", "", $fontfamily );
235
if( !( strpos( $fontfamily, "-Bold" ) === FALSE )) {
236
$fontfamily = str_replace( "-Bold", "", $fontfamily );
239
if( !( strpos( $fontfamily, "-Italic" ) === FALSE )) {
240
$fontfamily = str_replace( "-Italic", "", $fontfamily );
241
$fontstyle = "Italic";
243
if( !( strpos( $fontfamily, "Bold" ) === FALSE )) {
244
$fontfamily = str_replace( "Bold", "", $fontfamily );
245
$fontstyle = $fontstyle."Bold";
247
if( !( strpos( $fontfamily, "Italic" ) === FALSE )) {
248
$fontfamily = str_replace( "Italic", "", $fontfamily );
249
$fontstyle = $fontstyle."Italic";
252
if( $graphelement -> getName() == "text" ) {
260
if( $graphelement -> getName() == "rect" ) {
267
if( $key == "width" ) {
270
if( $key == "height" ) {
274
if( $graphelement -> getName() == "ellipse" || $graphelement -> getName() == "circle" ) {
275
// Element is either a circle or an ellipse
293
if(( $key == "x1" || $key == "y1" || $key == "x2" || $key == "y2" ) && $graphelement -> getName() == "line" ) {
294
// Element is a line element with 4 coordinate parameters
307
} else if( $key == "transform" && $graphelement -> getName() == "text" ) {
314
$dochr = substr( $workstr, $j, 1 );
315
if( $dochr == " " || $dochr == "( " || $dochr == " ) ") {
316
if( trim( $dostr ) != "" && $dostr != "matrix" ) {
317
$params [$noparams++] = $dostr;
319
if( $dochr == "-" ) {
328
}while( $j <= strlen( $workstr ));
329
if( trim( $dostr ) != "" ) {
330
$params [$noparams++] = $dostr;
332
$translate = "c.translate( ".$params[4].", ".$params[5]." );\n";
333
$rotate = "c.rotate( ".$params[1]." , ".$params[2]." );\n";
334
$scale = "c.scale( ".$params[0]." , ".$params[3]." );\n";
335
} else if( $key == "stroke" ) {
336
echo "" .'c.strokeStyle = "' . $val . '";' . "\n";
338
} else if( $key == "opacity" ) {
340
} else if( $key == "fill" ) {
341
if( $val != "none" ) {
342
if( strpos( $val, "url( ") === false) {
343
echo "" .'c.fillStyle = "' . $val. '";' . "\n";
345
echo "c.fillStyle = ".substr( $val, 5, strlen( $val ) - 6 ).";\n";
349
} else if ($key == "style" ) {
350
$fillpos = strpos( $val, "fill:" );
351
if( $fillpos !== false ) {
352
$fillposend = strpos( $val, ";", $fillpos);
353
if( $fillposend === false ) {
354
$fillposend = strlen( $val );
356
$fillstyle = substr( $val, $fillpos + 5, $fillposend - $fillpos - 5 );
357
if( $fillstyle != "none" ) {
358
if(strpos($fillstyle,"url(")===false){
359
echo "c.fillStyle = '".$fillstyle ."';\n";
361
echo "c.fillStyle = ".substr( $fillstyle, 5, strlen( $fillstyle ) - 6 ).";\n";
365
$strokepos = strpos( $val, "stroke:" );
366
if( $strokepos !== false ) {
367
$strokeposend = strpos( $val, ";", $strokepos );
368
if( $strokeposend === false ) {
369
$strokeposend = strlen( $val );
371
$linestyle = substr( $val, $strokepos + 7, $strokeposend - $strokepos - 7 );
372
if( $linestyle != "none" ) {
373
echo "" .'c.strokeStyle = "' . $linestyle . '";' . "\n";
376
$strokepos = strpos( $val, "stroke-width:" );
377
if( $strokepos !== false ) {
378
$strokeposend = strpos( $val, ";", $strokepos );
379
if( $strokeposend === false ) {
380
$strokeposend = strlen( $val );
382
$strokewidth = substr( $val, $strokepos + 13, $strokeposend - $strokepos - 13 );
383
$strokewidth = str_replace( "px", "", $strokewidth );
384
echo "\n" . 'c.lineWidth = "' . $strokewidth . '";' . "\n";
386
$fontsizepos = strpos( $val, "font-size:" );
387
if( $fontsizepos !== false ) {
388
$fontsizeend = strpos( $val, ";", $fontsizepos);
389
if( $fontsizeend === false ) {
390
$fontsizeend = strlen( $val );
392
$fontline = substr( $val, $fontsizepos + 10, $fontsizeend - $fontsizepos - 10 );
393
$fontline = str_replace( "px", "", $fontline);
395
$fontfamilypos = strpos( $val, "font-family:" );
396
if( $fontfamilypos !== false ) {
397
$fontfamilyend = strpos( $val, ";", $fontfamilypos);
398
if( $fontfamilyend === false ) {
399
$fontfamilyend=strlen($val);
401
$fontfamily = substr( $val, $fontfamilypos + 12, $fontfamilyend - $fontfamilypos - 12 );
403
$fontstylepos = strpos( $val, "font-style:" );
404
if( $fontstylepos !== false ) {
405
$fontstyleend = strpos( $val, ";", $fontstylepos );
406
if( $fontstyleend === false ) {
407
$fontstyleend=strlen($val);
409
$fontstyle = substr( $val, $fontstylepos + 11, $fontstyleend - $fontstylepos - 11 );
411
} else if( $key == "stroke-width" ) {
412
echo "\n" . 'c.lineWidth = "' . $val . '";' . "\n";
413
} else if( $key == "points" &&( $graphelement -> getName() == "polygon" || $graphelement -> getName() == "polyline" || $graphelement -> getName() == "line" )) {
415
$defsstring .= "c.beginPath();\n";
417
echo "c.beginPath();\n";
419
// dostr loop for polygons. Bugfix: if old char is e, then we do not break string at -
429
$dochr = substr( $workstr, $j, 1 );
430
if( ( $dochr == "-" && $oldchr != "e" && $oldchr != "E" ) || $dochr == "," || $dochr == " " ) {
431
if( trim( $dostr ) != "" ) {
432
$params [$noparams++] = $dostr;
434
if( $dochr == "-" ) {
443
} while( $j <= strlen( $workstr ));
444
if( trim( $dostr ) != "") {
445
$params [$noparams++] = $dostr;
447
for( $j = 0; $j < $noparams; $j += 2) {
450
$defsstring .= "c.moveTo( ".$params [$j].",".$params [$j+1].");\n";
452
echo "c.moveTo( ".$params[$j].",".$params[$j+1].");\n";
456
$defsstring .= "c.lineTo( ".$params[$j].",".$params[$j+1].");\n";
458
echo "c.lineTo( ".$params[$j].",".$params[$j+1].");\n";
462
// If a polygon close path if not i.e. polyline keep it open
463
if( $noparams >= 2 && $graphelement -> getName() == "polygon" ) {
465
$defsstring .= "c.lineTo( ".$params[0].",".$params[1]." );\n";
467
echo "c.lineTo( ".$params[0].",".$params[1]." );\n";
471
echo "c.globalAlpha = $opacity;\n";
473
if( $fillstyle == "none" && $linestyle == "none" ) {
475
echo 'c.fillStyle = "#000";';
477
echo "c.fill();\n\n";
480
if( $fillstyle != "none" ) {
483
if( $linestyle == "none" ) {
488
if( $linestyle != "none" ) {
490
echo "c.stroke();\n\n";
494
$defsstring .= "c.clip();\n\n";
496
} else if ( $key == "d" ) {
500
// Draw d line commands. This is a fix for the bug that requires the line settings to be assigned before the line commands
501
if( isset( $dval )) {
502
echo "c.beginPath();\n";
515
$chr = substr( $str, $i, 1 );
516
if( $chr == "H" || $chr == "h" || $chr == "V" || $chr == "v" || $chr == "M" || $chr == "m" || $chr == "C" || $chr == "c" || $chr == "L" || $chr == "A" || $chr == "a" || $chr == "l" || $chr == "z" || $chr == "Z" || $chr == "s" || $chr == "S" || $i == strlen( $str )) {
517
// Process Parameters for any parameter command
518
if( $command == "M" || $command == "m" || $command == "c" || $command == "C" || $command == "v" || $command == "V" || $command == "h" || $command == "H" || $command == "s" || $command == "S" || $command == "l" || $command == "L" || $command == "a" || $command == "A" ) {
525
// dochr loop for other drawing commands. Bug fix: If we encounter - and before it is an e we do nothing, otherwise proceed as normal
528
$dochr=substr($workstr,$j,1);
529
if(($dochr=="-" && $oldchr!="e" && $oldchr!="E")||$dochr==","||$dochr==" "){
530
if(trim($dostr)!=""){
531
$params[$noparams++]=$dostr;
542
} while( $j <= strlen( $workstr ));
543
if( trim( $dostr ) != "" ) {
544
$params [$noparams++] = $dostr;
547
if( $command == "M" || $command == "m" ) {
548
for( $j = 0; $j < $noparams; $j += 2 ) {
550
// Normal moveto set cx,cy
551
if( $command == "M" ) {
554
echo "c.moveTo(".$cx.",".$cy.");\n";
558
} else if( $command == "m" ) {
562
echo "c.moveTo(".$cx.",".$cy.");\n";
568
$cy += $params[$j+1];
569
echo "c.moveTo( ".$cx.",".$cy." );\n";
574
if( $command == "M" ) {
577
echo "c.lineTo(".$cx.",".$cy.");\n";
578
} else if( $command == "m" ) {
580
$cy += $params[$j+1];
581
echo "c.lineTo(".$cx.",".$cy.");\n";
585
} else if( $command == "C" || $command == "c" ) {
587
for( $j = 0; $j < $noparams; $j += 6 ) {
588
if( $command == "C" ) {
590
$p1y = $params[$j+1];
591
$p2x = $params[$j+2];
592
$p2y = $params[$j+3];
597
echo "c.bezierCurveTo( ".$p1x.",".$p1y.",".$p2x.",".$p2y.",".$cx.",".$cy.");\n";
598
// Curveto absolute set cx to final point, other coordinates are control points
599
} else if( $command == "c" ) {
600
// Curveto relative set cx to final point, other coordinates are relative control points
601
$p1x=$cx+$params[$j];
602
$p1y=$cy+$params[$j+1];
603
$p2x=$cx+$params[$j+2];
604
$p2y=$cy+$params[$j+3];
609
echo "c.bezierCurveTo(".$p1x.",".$p1y.",".$p2x.",".$p2y.",".$cx.",".$cy.");\n";
612
} else if( $command == "S" || $command == "s" ) {
613
//context . quadraticCurveTo(cpx, cpy, x, y)
615
for( $j = 0; $j < $noparams; $j += 4 ) {
616
if( $command == "S" ) {
623
echo "c.bezierCurveTo(".$lastpointx.",".$lastpointy.",".$p1x.",".$p1y.",".$cx.",".$cy.");\n";
624
// Curveto absolute set cx to final point, other coordinates are control points
625
} else if( $command == "s" ) {
626
// Curveto relative set cx to final point, other coordinates are relative control points
627
$p1x=$cx+$params[$j];
628
$p1y=$cy+$params[$j+1];
633
echo "c.bezierCurveTo(".$lastpointx.",".$lastpointy.",".$p1x.",".$p1y.",".$cx.",".$cy.");\n";
636
} else if( $command == "V" || $command == "v" ) {
638
for($j=0;$j<$noparams;$j++){
641
echo "c.lineTo(".$cx.",".$cy.");\n";
642
} else if( $command == "v" ) {
643
// Curveto relative set cx to final point, other coordinates are relative control points
645
echo "c.lineTo(".$cx.",".$cy.");\n";
648
} else if( $command == "H" || $command == "h" ) {
650
for($j=0;$j<$noparams;$j++){
653
echo "c.lineTo(".$cx.",".$cy.");\n";
654
} else if( $command == "h" ) {
655
// Curveto relative set cx to final point, other coordinates are relative control points
657
echo "c.lineTo(".$cx.",".$cy.");\n";
660
} else if( $command == "L" || $command == "l" ) {
662
for($j=0;$j<$noparams;$j+=2){
666
echo "c.lineTo(".$cx.",".$cy.");\n";
667
} else if( $command == "l" ) {
668
// Curveto relative set cx to final point, other coordinates are relative control points
671
echo "c.lineTo(".$cx.",".$cy.");\n";
674
} else if( $command == "Z" || $command == "z" ) {
675
echo "c.lineTo(".$firstpointx.",".$firstpointy.");\n";
676
} else if( $command == "A" || $command == "a" ) {
677
// To avoid hard math - draw arc as a line
678
for( $j = 0; $j < $noparams; $j += 7 ) {
682
$largeflag = $params[3];
683
$sweepflag = $params[4];
686
echo "c.lineTo(".$cx.",".$cy.");\n";
696
} while( $i <= strlen( $str ));
697
echo "c.globalAlpha = $opacity;\n";
698
if( $fillstyle == "none" && $linestyle == "none" ) {
699
echo 'c.fillStyle = "#000";';
701
echo "c.fill();\n\n";
703
if( $fillstyle != "none" ) {
704
// echo "c.save();\n\n";
705
// echo "c.scale(2.5,2.5);\n";
707
// echo "c.restore();\n\n";
708
if( $linestyle == "none" ) {
821
}elseif($graphelement->getName()=="circle"||$graphelement->getName()=="ellipse"){
822
echo "c.globalAlpha = $opacity;\n";
824
echo "c.beginPath();\n";
831
$xsp=$cx-($rx*0.552);
832
$xep=$cx+($rx*0.552);
833
$ysp=$cy-($ry*0.552);
834
$yep=$cy+($ry*0.552);
836
echo "c.moveTo(".$cx.",".$ys.");\n";
837
echo "c.bezierCurveTo(".$xsp.",".$ys.",".$xs.",".$ysp.",".$xs.",".$cy.");\n";
838
echo "c.bezierCurveTo(".$xs.",".$yep.",".$xsp.",".$ye.",".$cx.",".$ye.");\n";
839
echo "c.bezierCurveTo(".$xep.",".$ye.",".$xe.",".$yep.",".$xe.",".$cy.");\n";
840
echo "c.bezierCurveTo(".$xe.",".$ysp.",".$xep.",".$ys.",".$cx.",".$ys.");\n";
842
if($fillstyle!="none"){
844
if($linestyle=="none") echo "\n";
846
if($linestyle!="none"){
847
echo "c.stroke();\n";
850
}elseif($graphelement->getName()=="line"){
851
echo "context.beginPath();\n";
852
echo "context.moveTo(".$linex1.",".$liney1.");\n";
853
echo "context.lineTo(".$linex1.",".$liney1.");\n";
854
echo "context.stroke();\n";
856
}elseif($graphelement->getName()=="g"){
857
// We only print groups that have an ID
858
// if(isset($attrs['id'])){
859
echo "//-------------------------------\n";
860
echo "// Group: ".$attrs['id']."\n";
861
echo "//-------------------------------\n";
863
}elseif($graphelement->getName()=="eg"){
864
// We only print groups that have an ID
865
if(isset($attrs['id'])){
866
echo "//-------------------------------\n";
867
echo "// GroupEnd: ".$attrs['id']."\n";
868
echo "//-------------------------------\n";
871
}elseif($graphelement->getName()=="defs"){
874
}elseif($graphelement->getName()=="defsend"){
876
$clipdefs[strval($defsid)]=$defsstring;
712
if( $linestyle != "none" ) {
713
echo "c.stroke();\n";
718
if( $graphelement -> getName() == "text" ) {
719
echo "c.globalAlpha = $opacity;\n";
720
echo "c.beginPath();\n";
722
echo "c.font = '".$fontstyle." ".$fontline."px ".$fontfamily."';\n";
723
if( isset( $translate ) && isset( $rotate ) && isset( $scale )) {
728
if( isset( $textx ) && isset( $texty )) {
729
echo "c.fillText( '".$textline."',".$textx.",".$texty." );\n";
731
echo "c.fillText('".$textline."',0,0);\n";
733
if( $linestyle != "none" ) {
734
if( isset( $textx ) && isset( $texty )) {
735
echo "c.strokeText('".$textline."',".$textx.",".$texty.");\n";
737
echo "c.strokeText('".$textline."',0,0);\n";
740
echo "c.restore();\n\n";
741
} else if( $graphelement -> getName() == "rect" ) {
742
// This rectangle must be clipped!
743
if( isset( $attrs['clip-path'] )) {
744
$clipid = substr( $attrs['clip-path'], 5);
745
$clipid = substr( $clipid, 0, strlen( $clipid ) - 1 );
746
$clipid = $clippaths [$clipid];
748
echo $clipdefs[strval($clipid)];
750
echo "c.globalAlpha = $opacity;\n";
751
echo "c.beginPath();\n";
752
echo "c.moveTo(".$linex1.",".$liney1.");\n";
753
echo "c.lineTo(".($linex1+$linex2).",".($liney1).");\n";
754
echo "c.lineTo(".($linex1+$linex2).",".($liney1+$liney2).");\n";
755
echo "c.lineTo(".($linex1).",".($liney1+$liney2).");\n";
756
echo "c.lineTo(".($linex1).",".($liney1).");\n";
757
if( $fillstyle != "none" ) {
758
// echo "c.save();\n\n";
759
// echo "c.scale(1,1);\n";
761
// echo "c.restore();\n\n";
762
if( $linestyle == "none" ) echo "\n";
764
if( $linestyle != "none" ) {
765
echo "c.stroke();\n";
767
// This rectangle must be clipped!
768
if( isset( $attrs ['clip-path'] )) {
769
echo "c.restore();\n";
772
} else if( $graphelement -> getName() == "circle" || $graphelement -> getName() == "ellipse" ) {
773
echo "c.globalAlpha = $opacity;\n";
774
echo "c.beginPath();\n";
779
$xsp = $cx - ( $rx*0.552 );
780
$xep = $cx + ( $rx*0.552 );
781
$ysp = $cy - ( $ry*0.552 );
782
$yep = $cy + ( $ry*0.552 );
783
echo "c.moveTo(".$cx.",".$ys.");\n";
784
echo "c.bezierCurveTo(".$xsp.",".$ys.",".$xs.",".$ysp.",".$xs.",".$cy.");\n";
785
echo "c.bezierCurveTo(".$xs.",".$yep.",".$xsp.",".$ye.",".$cx.",".$ye.");\n";
786
echo "c.bezierCurveTo(".$xep.",".$ye.",".$xe.",".$yep.",".$xe.",".$cy.");\n";
787
echo "c.bezierCurveTo(".$xe.",".$ysp.",".$xep.",".$ys.",".$cx.",".$ys.");\n";
788
if( $fillstyle != "none" ) {
790
if( $linestyle == "none" ) echo "\n";
792
if( $linestyle != "none" ) {
793
echo "c.stroke();\n";
796
} else if( $graphelement -> getName() == "line" ) {
797
echo "context.beginPath();\n";
798
echo "context.moveTo(".$linex1.",".$liney1.");\n";
799
echo "context.lineTo(".$linex1.",".$liney1.");\n";
800
echo "context.stroke();\n";
801
} else if( $graphelement -> getName() == "g" ) {
802
// We only print groups that have an ID
803
// if(isset($attrs['id'])){
804
echo "//-------------------------------\n";
805
echo "// Group: ".$attrs['id']."\n";
806
echo "//-------------------------------\n";
808
} else if( $graphelement -> getName() == "eg" ) {
809
// We only print groups that have an ID
810
if( isset( $attrs['id'] )) {
811
echo "//-------------------------------\n";
812
echo "// GroupEnd: ".$attrs['id']."\n";
813
echo "//-------------------------------\n";
816
} else if( $graphelement -> getName() == "defs" ) {
819
} else if( $graphelement -> getName() == "defsend" ) {
820
if( $defsid != "" ) {
821
$clipdefs[strval($defsid)]=$defsstring;
b'\\ No newline at end of file'