/lenasys/0.1

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/0.1

« back to all changes in this revision

Viewing changes to svg Converter/svgtocanvas.php

  • Committer: Gustav Hartvigsson
  • Date: 2013-04-03 15:20:28 UTC
  • mfrom: (9.2.3 lenasys)
  • Revision ID: gustav.hartvigsson@gmail.com-20130403152028-2pxwtfhr0c8rduy4
Merging the changes made by implementation group 2 from 20130403 into trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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)" 
50
 
//  
51
47
//-------------------------------------------------------------------------- Next Version Blueprint
52
48
// Version 3.7
53
49
//    Curve Closing (html5)
65
61
        $gradientname = "foo";
66
62
        $isinkscape = false;
67
63
        $stopcounter = 0;
68
 
 
 
64
        $svgfilepath = "../media/svgconverter/";
 
65
        
69
66
function recurseelement( $element ) {
70
67
        global $elementcounter;
71
68
        global $graphnodes;
106
103
}
107
104
 
108
105
if( isset( $_POST ['svgname'])) {
109
 
        $svg = simplexml_load_file( $_POST ['svgname'] );
 
106
        $svg = simplexml_load_file( $svgfilepath . $_POST ['svgname'] );
110
107
        // Recurse into elements and add to element stack
111
108
        // It is important to only process hierarchies of g elements and layers
112
109
        foreach( $svg as $element ) {
325
322
                                                        $dostr = "";
326
323
                                                }
327
324
                                        } else {
328
 
                                                $dostr. = $dochr;
 
325
                                                $dostr .= $dochr;
329
326
                                        }
330
327
                                        $j++;
331
328
                                }while( $j <= strlen( $workstr ));
415
412
                                echo "\n" . 'c.lineWidth = "' . $val . '";' . "\n";
416
413
                        } else if( $key == "points" &&( $graphelement -> getName() == "polygon" || $graphelement -> getName() == "polyline" || $graphelement -> getName() == "line" )) {
417
414
                                if( $defsmode ) {
418
 
                                        $defsstring. = "c.beginPath();\n";
 
415
                                        $defsstring .= "c.beginPath();\n";
419
416
                                } else {
420
417
                                        echo "c.beginPath();\n";
421
418
                                }
440
437
                                                        $dostr = "";
441
438
                                                }
442
439
                                        } else {
443
 
                                                $dostr. = $dochr;
 
440
                                                $dostr .= $dochr;
444
441
                                        }
445
442
                                        $j++;
446
443
                                        } while( $j <= strlen( $workstr ));
450
447
                                        for( $j = 0; $j < $noparams; $j += 2) {
451
448
                                                if( $j == 0 ) {
452
449
                                                        if( $defsmode ) {
453
 
                                                                $defsstring. = "c.moveTo( ".$params [$j].",".$params [$j+1].");\n";
 
450
                                                                $defsstring .= "c.moveTo( ".$params [$j].",".$params [$j+1].");\n";
454
451
                                                        } else {
455
452
                                                                echo "c.moveTo( ".$params[$j].",".$params[$j+1].");\n";                                                 
456
453
                                                        }
457
454
                                                } else {
458
455
                                                        if( $defsmode ) {
459
 
                                                                $defsstring. = "c.lineTo( ".$params[$j].",".$params[$j+1].");\n";
 
456
                                                                $defsstring .= "c.lineTo( ".$params[$j].",".$params[$j+1].");\n";
460
457
                                                        } else {
461
458
                                                                echo "c.lineTo( ".$params[$j].",".$params[$j+1].");\n";
462
459
                                                        }
465
462
                                        // If a polygon close path if not i.e. polyline keep it open
466
463
                                        if( $noparams >= 2 && $graphelement -> getName() == "polygon" ) {
467
464
                                                if( $defsmode ) {
468
 
                                                        $defsstring. = "c.lineTo( ".$params[0].",".$params[1]." );\n";
 
465
                                                        $defsstring .= "c.lineTo( ".$params[0].",".$params[1]." );\n";
469
466
                                                } else {
470
467
                                                        echo "c.lineTo( ".$params[0].",".$params[1]." );\n";
471
468
                                                }
494
491
                                                }
495
492
                                        }
496
493
                                        if( $defsmode ) {
497
 
                                                $defsstring. = "c.clip();\n\n";
 
494
                                                $defsstring .= "c.clip();\n\n";
498
495
                                        }
499
496
                        } else if ( $key == "d" ) {
500
497
                                $dval=$val;