skarab42 / lw.svg-parser Goto Github PK
View Code? Open in Web Editor NEWSVG parser for LaserWeb.
License: MIT License
SVG parser for LaserWeb.
License: MIT License
Implementing pattern support for complex drawings.
The parser transforms this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<!-- Creator: CorelDRAW X7 -->
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="457.285mm" height="135.043mm" version="1.0" shape-rendering="geometricPrecision" text-rendering="geometricPrecision" image-rendering="optimizeQuality" fill-rule="evenodd" clip-rule="evenodd"
viewBox="0 0 38014 11224"
xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="Layer1">
<metadata id="CorelCorpID_0Corel-Layer"/>
<polygon fill="none" stroke="yellow" stroke-width="6.33459" points="3,3 38011,3 38011,11221 3,11221 "/>
</g>
</svg>
To this:
{x: 0.12789526521816735, y: 0.12789526521816735}
{x: 1620.475642069253, y: 0.12789526521816735}
{x: 1620.475642069253, y: 478.37092367101855}
{x: 0.12789526521816735, y: 478.37092367101855}
{x: 0.12789526521816735, y: 0.12789526521816735}
What units are these? They don't match mm, inches, or the original PX units (83.1 px/mm).
It's called with default options:
let parser = new Parser({});
parser.parse(reader.result).then(...).catch(...);
Hi!
I get users complaining that the SVGs I generate with Boxes.py (https://github.com/florianfesti/boxes) cannot be rendered with Laserweb. A quick look into the code raised the suspicion that the viewBox calculation may be off. Especially those two lines in tagparser.js seem to be in the wrong order. Swapping them out at least shows something:
this.tag.scale(scaleX, scaleY)
this.tag.translate(-translateX, -translateY)
Test with any SVG with has a viewBox not starting at 0 0 - like all Boxes.py artifacts.
Sorry, for not submitting a proper PR.
When opening the attached SVG, the paths seem to open at random locations rather than adhering to the placement in the SVG file.
Example of functionality in LaserWeb can be seen here: https://plus.google.com/105504973000570609199/posts/NbrpcwhKSR5?sfc=true
SVG file here: https://www.dropbox.com/s/xo7ad5e1bdtznpp/LW-Test.svg?dl=0
Should be as simple as treat it like a "defs" child (https://developer.mozilla.org/es/docs/Web/SVG/Element/symbol) despite the viewport usage. :)
Just to keep trace of this request LaserWeb/LaserWeb4#58 (comment)
Repported on LaserWeb/LaserWeb4#58 (comment)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.