Commit graph

151 commits

Author SHA1 Message Date
asturur
12f5c6356e Update parser.js 2014-07-18 20:42:21 +02:00
asturur
a52e081c25 Update parser.js
I forgot to delete one piece.
2014-07-18 20:07:24 +02:00
asturur
56b4caebbe Update parser.js 2014-07-18 16:37:55 +02:00
kangax
3df3c396a2 Fix unit tests 2014-07-18 13:11:18 +02:00
Juriy Zaytsev
2c6cafe34f Merge pull request #1496 from Kienz/jsdocFixes
JSDoc + JSCS tweaks - Part 1
2014-07-17 18:52:54 +02:00
asturur
5ca64ad636 Update parser.js 2014-07-17 16:25:59 +02:00
Stefan Kienzle
b34387d10e JSDoc + JSCS tweaks - Part 1 2014-07-17 16:18:57 +02:00
asturur
bd4c7a0c4d Update parser.js 2014-07-16 18:56:10 +02:00
asturur
0d4320c018 Update parser.js
Use parseUnit to normalize pt,pc,mm,in,cm to px.
2014-07-16 15:34:54 +02:00
kangax
69fdc220e1 Add JSDoc validation in JSCS. Few style/doc fixes. 2014-07-16 11:45:50 +02:00
Paul Kaplan
bbd1dd2d99 Simplify point parsing logic
The SVG spec basically allows delimiting numbers and pairs of numbers
with either whitespace or commas, so convert all commas to whitespace,
split on whitespace and remove the `asPairs` logic
2014-07-14 09:59:03 -05:00
Paul Kaplan
112dce71a3 Allow whitespace around commas in point parsing
Per the SVG spec:

http://www.w3.org/TR/SVG/shapes.html#PointsBNF
2014-07-12 18:08:03 -05:00
Juriy Zaytsev
0f2e306a64 Merge pull request #1425 from asturur/use-tag-use
Support use tag
2014-06-25 12:25:06 +02:00
asturur
b21820cc6b Update parser.js
Changed getElementsByTagName with queryselectorall, allow to go just on "use" node , but all of them ( getElementsByTagName doesn't , it select just first level of child.
Removed tagname check now useless.
2014-06-25 08:02:42 +02:00
asturur
4ccc2c83ba Update parser.js
Moved in a separate function.
Tried to fix sneaky tabs and spaces.
2014-06-24 15:17:59 +02:00
kangax
492253e5ca JSCS tweaks. Down to 114 failures. 2014-06-24 14:12:17 +02:00
asturur
52c9792e15 Use of tag use
Deep cloning nodes that should be used before normal document parsing.
2014-06-24 13:12:27 +02:00
asturur
049259cc09 style parsing fix
code style should be ok this time
2014-06-22 20:51:04 +02:00
asturur
35eebc0376 Update parser.js 2014-06-21 14:22:10 +02:00
asturur
54f5cf11e5 Update parser.js
Get rid of error stopping the parser for elements that doesn't have a parent with visible defined.
2014-06-21 14:19:31 +02:00
Jim Rodovich
74b0329abd Fix error when parsing empty SVG document.
And don't forget to call the callback.
2014-05-15 16:31:01 -05:00
Juriy Zaytsev
a20e329213 Merge pull request #1317 from rodovich/leading-decimal
Be able to parse numbers with no digits before the decimal point.
2014-05-09 00:31:46 +02:00
Jim Rodovich
5b54f83548 Be able to parse viewbox numbers with no digits before the decimal. 2014-05-08 11:28:11 -05:00
Jim Rodovich
ed0b91109d Be able to parse numbers with no digits before the decimal point.
Per the [SVG spec](http://www.w3.org/TR/SVG11/types.html#DataTypeNumber), non-integer number values do not necessarily have any digits before the decimal point.
2014-05-08 11:20:56 -05:00
Jim Rodovich
95fd97fa63 Perform imported SVG rotations in degrees, per the SVG spec.
http://www.w3.org/TR/SVG11/coords.html#TransformAttribute
2014-05-08 10:56:32 -05:00
kangax
314e06db6d Fix fontWeight parsing 2014-04-18 16:07:59 -04:00
kangax
b3600e62a4 Add support for text-anchor's 2014-04-18 16:07:49 -04:00
kangax
c8164959c8 Add support for SVG "visibility: hidden" 2014-04-16 14:05:34 -04:00
kangax
a48ed5b31b Add support for display=none. Closes #1256 2014-04-10 17:47:36 -04:00
kangax
cfd71e9550 Fix viewBox parsing 2014-04-10 13:57:24 -04:00
kangax
2acdc7e85b Fix few bracketless statements. Down to 257 failures on JSCS. 2014-02-27 15:00:42 -05:00
Michael Sievers
179ad93dc5 Make ElementsParser a constructor function and create instances in fabric.parseElements 2014-02-18 13:43:19 +01:00
kangax
d2f6a9033e Add JSCS validation & change bunch of things for conformance. Down to 333 failures from ~1000. 2014-02-16 16:36:14 -05:00
Marco Miltenburg
b97f850bbb Added check to make sure xml is defined and exit if undefined. 2013-12-18 13:44:04 +01:00
kangax
ec8a920081 Reorganize parser.js 2013-11-21 18:00:29 +01:00
kangax
f91dd30dc7 Better line length in parser 2013-11-05 11:59:48 +01:00
kangax
6cb941c116 Extract elements parsing into a separate object (ElementsParser) 2013-11-04 17:12:05 +01:00
kangax
ce8fe3447d Break parseStyleAttribute apart 2013-11-04 16:41:26 +01:00
Kienz
5017bc6626 [BACK_INCOMPAT] fabric.StaticCanvas#backgroundImage and fabric.StaticCanvas#overlayImage are fabric.Image instances. fabric.StaticCanvas#backgroundImageOpacity, fabric.StaticCanvas#backgroundImageStretch, fabric.StaticCanvas#overlayImageLeft and fabric.StaticCanvas#overlayImageTop were removed.
`backgroundImage` and `overlayImage` are now `fabric.Image` instances
New property `overlayColor` (analog to `backgroundColor`) - should be set with `canvas.setOverlayColor`
`backgroundImageOpacity` was removed => use `fabric.Image#opacity`
`overlayImageLeft ` was removed => use `fabric.Image#left`
`overlayImageTop ` was removed => use `fabric.Image#top`
`backgroundImageStretch` was removed => use `fabric.Image#width` and `fabric.Image#height`. If you scale your canvas you have to adjust the backgroundImage width/height manually.
Update SVG output.
Add 2nd parameter `firstLetterOnly` to `fabric.util.string.capitalize` => only first letter is transformed to uppercase (other letters stay untouched)
Add `preserveAspectRatio="none"` to `fabric.Image#toSVG` (otherwise streched backgroundImage and overlayImage didn't work as expected)
Update examples - TODO: Update jsfiddles for `setBackgroundImage` and `setOverlayImage`
Add unit test

Closes issue #270
2013-11-03 13:09:49 +01:00
kangax
167f2fa089 Move shared attributes out of parser since it's needed by many "classes" 2013-10-28 14:01:44 +01:00
kangax
5717df817b Fix error when parsing gradient-based fill attribute. Closes #749 2013-08-07 13:51:59 +02:00
kangax
72ef6c67fa Parse lineHeight in style attribute. This fixes IE11's only failing test. 2013-07-11 20:39:45 +02:00
kangax
be8e921e57 Fix nested matrix multiplication. Closes #705 2013-06-13 23:10:33 +02:00
kangax
2223b1b61f Remove more functions in distribution when SVG import (parser) is not included. Always include stateful mixin. Closes #662 2013-05-30 21:55:26 +02:00
Kienz
2c29c0cfab Fix typo, add hsl/hsla (with whitespaces) unit tests and move stuff outside of functions 2013-05-25 19:42:31 +02:00
Kienz
66fc8f4d4b Parse SVG stroke-opacity and fill-opacity
- SVG attribute opacity is now used for object's opacity
- fill-opacity and stroke-opacity are added to stroke and fill color value
- Add hsl/hsla support (e.g. hsl(270, 80%, 10%), hsla(320, 10%, 66%, 0.5))
- Add support for rgb/rgba values with whitespaces around values (e.g. rgba( 255 , 100 , 50 , 0.1 )) and percentage values (e.g. rgb(100%, 67%, 15%, 0.8))
- Delete stroke and strokeWidth from fabric.Text (defined in fabric.Object)
- New unit test for parse stroke-opacity and fill-opacity
- Update unit tests (new tests for hsl/hsla and rgb/rgba (whitespaces and percentage values))
- Change equal and deepEqual parameter order (e.g. equal(actualValue, expectedValue, message))
- Doc additions
2013-05-25 11:03:09 +02:00
kangax
1ed4e40bdf Move brushes to /brushes and mixins to /mixins. Organize ATTRIBUTE_NAMES to use fabric.SHARED_ATTRIBUTES. 2013-05-18 16:43:49 +02:00
Kienz
d80fec5df1 Better strokeDashArray support + Fixes
- fabric.Text has now strokeDashArray support (only native support)
- fabric.Text.fill = null should now work
- Fix save/restore context in render methods => setLineDash affected drawBorder/drawControls
- Add strokeLineCap (default "butt"), strokeLineJoin (default "miter") and strokeMiterLimit (default 10)
- Add support for fabric.Object#fromElement for strokeDashArray (and other stroke properties)
- Add @default tag to properties (JSDoc 3)
- strokeDashArray now only works if stroke property is defined
- Add trokeLineCap (default "round"), strokeLineJoin (default "round") to fabric.BaseBrush
- Updated unit tests
2013-05-18 13:01:34 +02:00
kangax
c65b1f5e7d Add support for parsing shorthand font declaration in styles, such as "font: italic 12px Arial,Helvetica,sans-serif" 2013-05-12 13:01:23 -04:00
kangax
eeecde62a8 Normalize style values. Closes #598 2013-05-01 02:58:59 -04:00
kangax
c16dcf88a4 Change inline docs to conform to jsdoc3 2013-04-24 12:58:04 -04:00
kangax
e56d37d9da Fix text and line rendering in path group. Add support for multiple declarations in "transform" attribute. Fix stroke color of line. Version 1.1.7 2013-04-18 21:42:46 -04:00
Tim Andres
3950298c75 Changed nestTransformMatrices to mutilplyTransformMatrices 2013-04-17 13:54:11 -04:00
Tim Andres
e2bba99e98 Fixed path translation bug with SVG parsing 2013-04-16 01:49:42 -04:00
Stefan Kienzle
9c76ba0f92 Add svg element to async objects (reviver)
If async objects parsed (image), the reviver svg element is undefined.
You can see it here:
http://jsfiddle.net/Kienz/nhYww/
2013-04-05 19:06:02 +03:00
kangax
4c5df5ea0c Specify that loadSVGFromURL uses XHR and conforms to SOP 2013-04-02 13:47:47 +02:00
kangax
5a91472bdc Remove trailing comma 2013-02-17 13:26:45 +01:00
Kienz
5e81f7ab09 Add backgroundColor to svg output
Add backgroundColorPattern to svg output
Bugfix backgroundImage in sag output - width/height are depend on backgroundImageStretch
Bugfix in setBackgroundColor - rename pattern to repeat
2013-02-14 22:06:01 +01:00
kangax
8b04e286a8 Log full errors instead of just its messages 2013-02-04 20:49:05 +01:00
kangax
c11abb377f Fix tests. Build distribution. Version 0.9.35. 2012-12-23 15:28:08 +01:00
kangax
a7a6c38384 Fix incorrect parsing of fontSize which made text not appear when loaded from SVG. Closes #331. 2012-12-23 15:18:46 +01:00
kangax
c8172be31d Final doc additions. Every public method is now documented! 2012-12-16 20:44:26 +01:00
kangax
3416d8a090 Documentation additions. 2012-12-13 15:46:06 +01:00
kangax
f0b5329157 Doc additions, fixes. 2012-11-23 13:38:26 +01:00
kangax
84a956c4b6 Lint everything with JSHint. Version 0.9.14. 2012-10-14 02:53:12 +02:00
kangax
9a7d40d7d7 Change the way gradients are initialized.
They no longer need `ctx` property, which is now taken from object directly during rendering time.
Add unit tests for gradients.
2012-08-20 18:23:53 +02:00
joshpearce
5923e008f7 Update src/parser.js 2012-08-19 21:36:37 -03:00
Josh Pearce
cf7a6d1482 Added reviver method in parser
The optional method is used when asking fabric to
load an SVG file and parse it, instantiating fabric objects.
After each fabric object is created, reviver(ele, obj) is
called so you can parse our custom attributes, or do
anything else custom.
2012-08-19 16:07:28 -04:00
kangax
3ce8507932 Implement fabric.Text.fromElement. Closes #182. 2012-08-11 18:59:53 +02:00
kangax
b701627f42 Fix "stroke-width" being ignored in style attribute. 2012-06-10 12:13:12 +02:00
Tim de Koning
804de6094c Why shouldn't we allow GET parameters? Dynamicly generated SVG files (based on GET params) should be supported to 2012-01-20 11:29:51 +01:00
Tim de Koning
f71f634afd IE8 and lower now actually render and show any loaded SVG 2012-01-18 10:44:03 +01:00
Tim de Koning
364e76713c fabric.loadSVGFromString should work on IE8 and lower... 2012-01-17 17:29:45 +01:00
Tim de Koning
da9c75c073 improved doctype removal regex 2012-01-17 16:30:23 +01:00
Tim de Koning
17931fb764 fix for unittest "fabric.Parser.parseStyleAttribute" compliance in < IE8 2012-01-17 15:24:25 +01:00
Tim de Koning
26d6176928 fix for unittest fabric.util.loadSVGFromString in < IE8 2012-01-17 14:41:58 +01:00
kangax
d870410a7d First (and almost complete) implementation of fabric.Canvas#toSVG. 2012-01-02 16:14:20 -05:00
kangax
f3a3e81ea2 [BACK_INCOMPAT] Fix JS error when calling fabric.Image#toDataURL. toDataURL is now asynchronous, and passes data url to callback (first argument) instead of returning it. Closes #79. 2011-11-18 10:44:53 -05:00
kangax
48da79220f Fix fabric parser to workaround o3-xml bug with gEBTN("*") 2011-08-16 19:05:17 -04:00
kangax
b53d794af6 [BACK_INCOMPAT] Custom fabric build is now created with node.js and is much more flexible. Sprockets is no longer required to build fabric. Parser and node are now optional modules, which means that parseSVGDocument is no longer included in default fabric build. 2011-08-14 17:35:36 -04:00
kangax
35ad4bf6e3 Preparing fabric to run on node.js 2011-08-05 19:00:26 -04:00
kangax
628efcdc70 fabric.Element is renamed to fabric.Canvas, which makes more sense. fabric.Element is kept for compatibility reasons (but is deprecated). Bump version to 0.3. 2011-06-28 19:14:40 -04:00
kangax
ef425d18c5 Fix some of the parser.js unit tests by making resolveGradients more lenient. 2011-02-11 01:44:08 -05:00
kangax
ca11620451 Replace map with for loop for perf. reasons (as this method is likely to be called thousands of times). 2011-02-09 01:03:04 -05:00
kangax
ba4486e5be Use Array.prototype.slice to convert nodelist to an array (slice is usually faster; it makes sense in this context where nodelists (i.e. shapes) could consist of thousands of elements). 2011-02-09 00:14:12 -05:00
kangax
580c0680f0 First stab at parsing + applying css rules to SVG elements. Needs unit tests! 2011-01-19 02:30:35 -05:00
kangax
b35ebd0bb2 Reorganize SVG gradients parsing in such way so that during parsing, objects (to apply those gradients to) were available; we need this to be able to apply percent-based values properly (e.g. x2="100%" should be translated to an object's width, y2="50%" -- to object's height / 2, etc.). 2011-01-09 02:09:28 -05:00
kangax
a40e9cd610 Initial implementation of gradients. Work in progress (but demo page now has working "gradientify" button). Still need to add tests, and make sure gradient-based fills on SVG elements are parsed/set properly. 2011-01-09 01:38:54 -05:00
kangax
80148361f3 Add support for parsing <image> SVG elements and creating fabric.Image instances out of them. Backwards-compatibility note: fabric.parseElements changed signature from (elements, options) to (elements, callback, options) and is now an "asynchronous" method -- doesn't return a value, but instead passes it to a callback function (second argument). 2011-01-07 19:53:19 -05:00
kangax
2eea8d4468 Fix style attribute parsing + tests. Add one more shape to the demo (which utilizes style attribute). 2011-01-06 17:13:07 -05:00
kangax
b550020024 Elements that are descendants of <defs> elements are no longer rendered (as per spec). 2011-01-06 15:20:56 -05:00
kangax
f497327131 Fabric now runs fully under ES5 strict mode (except certain 3rd party dependencies, like cufon.js and json2.js). 2010-10-21 22:54:00 -04:00
kangax
948d3998c8 A couple more doc fixes and build distribution + minified. 2010-10-19 16:31:39 -04:00
kangax
f052a067ef More documentation. 2010-10-19 16:27:24 -04:00
kangax
415205d3f2 Document bunch of API (still incomplete, but getting there). 2010-10-14 17:42:39 -04:00
kangax
e70830f7d6 Introduce fabric.log and fabric.warn methods, as simple wrappers around console.log and console.warn (instead of declaring those methods right on console). This makes it easier to mock them when testing, and is generally safer due to less tinkering with host objects. 2010-10-11 14:45:06 -04:00
kangax
e9fd7c6166 Fix bug in Polyline and Polygon points attribute parsing (thanks to unit tests). 2010-09-09 17:10:21 -04:00
kangax
652712601e Canvas.Polygon.prototype._toOrigin is not used and is not needed, so remove it;
`parsePointsAttribute` can now parse values like "a b c d", not only "a,b c,d".
2010-09-08 16:35:06 -04:00
kangax
ad679a6f87 Create local aliases of some of the "long" methods. 2010-07-26 19:20:19 -04:00
kangax
9f77d3a0a5 Add google closure compiler and explain how to minify fabric.js with it. Fix few omissions in jsdoc comments. 2010-07-26 00:48:26 -04:00