Commit graph

2540 commits

Author SHA1 Message Date
a-puzo
66547a4442 Correct view centering
Fixed bad centering when `view.center` and `view.zoom` are changed
2013-02-13 06:35:19 +04:00
Jürg Lehni
66c491a8fd Minor code clean up. 2013-02-12 17:23:56 -08:00
Jürg Lehni
7df4338ef5 Fix linear gradient orientation when shape substitution is applied. 2013-02-12 17:22:31 -08:00
Jürg Lehni
f554bdce2a Fix issues with SVG gradient export. 2013-02-12 17:05:54 -08:00
Jürg Lehni
e9fef8a53c Fix a couple of newly introduced bugs through CanvasProvider change. 2013-02-12 16:23:30 -08:00
Jürg Lehni
ea1e7fccb9 clearRect() needs + 1 for size. 2013-02-12 16:07:24 -08:00
Jürg Lehni
ca3cc7f46d Define CanvasProvider.getContext() next to getCanvas(), and support both types in release(). 2013-02-12 16:06:24 -08:00
Jürg Lehni
51150cb20d Support CanvasProvider.get(width, height) arguments. 2013-02-12 15:57:02 -08:00
Jürg Lehni
9600fdb512 Fix a recently introduce but in Raster#getCanvas(). 2013-02-12 15:54:56 -08:00
Jürg Lehni
357b7dbc54 Shorten CanvasProvider method names. 2013-02-12 15:53:27 -08:00
Jürg Lehni
24d467e292 Implement support for native dash strokes, through both setLineDash() and mozDash. 2013-02-12 15:32:21 -08:00
Jürg Lehni
fdd15e675f Add options argument to #toJson() methods, and use to implement optional fractional digit precision control. 2013-02-12 14:57:54 -08:00
Jürg Lehni
053aa15ded Rename Raster's ImageData code from *Data to *ImageData, to avoid clash with future Item#data. 2013-02-12 14:40:55 -08:00
Jürg Lehni
22218e0db0 Simplify Base.serialize(). 2013-02-12 14:16:25 -08:00
Jürg Lehni
80ffd41560 Add optional precision argument to Base.formatFloat(). 2013-02-12 14:16:06 -08:00
Jürg Lehni
85d2700eb1 Implement namespaces for SVG properties in SvgExport. 2013-02-11 19:46:05 -08:00
Jürg Lehni
ee73b4e15b Add some explaining comments to dictionary code. 2013-02-11 19:35:11 -08:00
Jürg Lehni
15554b8bf2 Simplify adding / referencing of JSON dictionary entries. 2013-02-11 19:31:58 -08:00
Jürg Lehni
366524d0a7 Implement JSON serialization for Gradient and GradientColor. 2013-02-11 19:22:18 -08:00
Jürg Lehni
e7bb334c6a Use JSON dictionary support to serialize Symbols and PlacedSymbol references. 2013-02-11 18:59:49 -08:00
Jürg Lehni
00dcd05549 Implement support for dictionary definitions and references in JSON serialization. 2013-02-11 18:59:05 -08:00
Jürg Lehni
aa6e2fae09 Improve Base#equals(). 2013-02-11 18:24:08 -08:00
Jürg Lehni
629e16144a Define #_type property for both Symbol and Gradient and use it in SvgExport. 2013-02-11 18:23:41 -08:00
Jürg Lehni
224563d5f7 Include more Item attributes for serialization. 2013-02-11 17:13:44 -08:00
Jürg Lehni
a043feae76 Implement serialization for TextItem. 2013-02-11 17:08:39 -08:00
Jürg Lehni
489a785171 Override Item.extend() to merge the subclass' _serializeFields with the parent class' _serializeFields.
And have style fields always serialized in non-compact form for Color.
2013-02-11 17:08:23 -08:00
Jürg Lehni
6d39a91c87 Implement simple Project serialization. 2013-02-11 16:43:31 -08:00
Jürg Lehni
e829440803 Have Raster serialize itself.
The source property either contains the link to the external source, or the data url.
2013-02-11 16:43:10 -08:00
Jürg Lehni
e5180e6929 Implement Raster#getElement(), returning either the internal native canvas or image element.
And use it internally in various places.
2013-02-11 16:42:36 -08:00
Jürg Lehni
080a9b220a Handle Raster#onLoad() callback for inlined images.
Code can now switch back and forth between inlined images and external sources.
2013-02-11 16:35:46 -08:00
Jürg Lehni
cf6ba30258 Have Raster#image only return an image, not a canvas element. 2013-02-11 16:34:59 -08:00
Jürg Lehni
0954dc3823 Better deal with security exceptions and missing image data in Raster. 2013-02-11 16:34:31 -08:00
Jürg Lehni
435341f30b Fix name clash due to recent renaming. 2013-02-11 14:36:44 -08:00
Jürg Lehni
efaae62799 Reuse attrs variable. 2013-02-10 19:40:44 -08:00
Jürg Lehni
20011d912a Fix typo. 2013-02-10 19:40:15 -08:00
Jürg Lehni
e0d0eb175a Implement exporting of Gradients to SVG. 2013-02-10 19:38:35 -08:00
Jürg Lehni
199fc046bf Rename 'svg' variables to more meaningful 'node'. 2013-02-10 19:37:19 -08:00
Jürg Lehni
de4e928045 Clean up SvgExport code. 2013-02-10 19:02:53 -08:00
Jürg Lehni
f06701055d Implement exporting of Symbols to SVG. 2013-02-10 10:23:49 -08:00
Jürg Lehni
565fb86430 Give any item / object that needs to be exported as a definition / symbol its own unique id.
This will be useful in SVG and JSON exporter.
2013-02-10 09:37:40 -08:00
Jürg Lehni
49728665e6 Clear definitions lookup at the end of SVG import. 2013-02-09 13:59:04 -08:00
Jürg Lehni
0f846098c4 Support CompoundPath in SvgExport. 2013-02-09 13:38:22 -08:00
Jürg Lehni
b10454a83c Rename Matrix#createInverse() to #inverted() and #createShiftless() to #shiftless(). 2013-02-09 12:18:40 -08:00
Jürg Lehni
d70fdb69d3 Adapt to recent changes to Matrix#decompose() in SvgExport code. 2013-02-09 12:11:56 -08:00
Jürg Lehni
be3b257175 Restructure Matrix code sequence. 2013-02-09 12:11:19 -08:00
Jürg Lehni
0cf290ff2d More work on Matrix decomposition.
Have Matrix#decompose() return null if decomposition is not possible, separate Matrix#translation from decomposition code as it's always defined, and document methods and properties.
2013-02-09 12:09:55 -08:00
Jürg Lehni
2bb9153810 Fix TODO in Matrix#scale(). 2013-02-09 11:52:31 -08:00
Jürg Lehni
cd9fc39f54 Rename Matrix#setIdentity() to #reset() and document it. 2013-02-09 11:45:33 -08:00
Jürg Lehni
9aaa864f81 Streamline Matrix by removing unnecessary Matrix#setTo*() and Matrix.get*Instance() methods.
Use (new Matrix().*()) instead.
2013-02-09 11:42:55 -08:00
Jürg Lehni
3930a40c7e Implement Matrix#rotate() without relying on Matrix#getRotateInstance(). 2013-02-09 11:40:49 -08:00
Jürg Lehni
53474aa5c0 Put decomposed matrix values in sequence in which they would have to be applied again. 2013-02-09 11:21:16 -08:00
Jürg Lehni
15c8652747 Add support for Raster to SvgExport. 2013-02-09 09:44:25 -08:00
Jürg Lehni
aec13ffd43 Fix all tests for Matrix decomposition. 2013-02-08 23:25:10 -08:00
Jürg Lehni
e438ac8223 Implement proper matrix decomposition and use it in SvgExport. 2013-02-08 23:02:20 -08:00
Jürg Lehni
aec87f4ed1 Fix issues with matrix decomposition.
Work in progress...
2013-02-08 22:17:32 -08:00
Jürg Lehni
bc5826d324 Clean up code. 2013-02-08 18:46:22 -08:00
Jürg Lehni
dc35fdbd02 Move named inner functions out of nested scopes, to prepare for 'use strict;' transition. 2013-02-08 18:23:33 -08:00
Jürg Lehni
d793d8a43d Clean up code. 2013-02-08 18:17:51 -08:00
Jürg Lehni
bd62b4b819 Do not export paper.load() any more.
Use paper.PaperScript.load() instead.
2013-02-08 18:17:37 -08:00
Jürg Lehni
1ee29d56ac Improve comment about JavaScriptCore bug. 2013-02-08 16:35:33 -08:00
Jürg Lehni
b6d2d83af5 Fix the strangest JavaScriptCore bug that I've encountered in ages.
Closes #168. Read comment for more details.
2013-02-08 16:32:47 -08:00
Jürg Lehni
02ca95eb46 Avoid accidental global leakage. 2013-02-08 16:12:57 -08:00
Jürg Lehni
75adbd0adc Disable transformation detection for now, until issues with Matrix#getRotation() and Matrix#getScaling() are solved. 2013-02-08 14:36:49 -08:00
Ian Spivey
0df86550e6 Update getView to handle DOM elements without getAttribute, e.g. SVGDocument 2013-01-28 19:08:25 -08:00
Jürg Lehni
6c9c16ad3d Update copyright information comments, and year. 2013-01-28 18:03:27 -08:00
Jürg Lehni
b0deda9445 Add missing documentation for various location related functions on Curve. 2013-01-28 16:47:45 -08:00
Jürg Lehni
c7d8aebb9e Swap Curve's bounds scope with point evaluation scope, for proximity to bounds related methods in scope before. 2013-01-28 16:32:04 -08:00
Jürg Lehni
1a438b8b9b Change Curve#[getPoint / getTangent / getNormal](t) to #[getPoint / getTangent / getNormal](offset, isParamter).
Keep deprecated versions around for now.
2013-01-28 16:30:28 -08:00
Jürg Lehni
e75ee18de1 Restructure code a bit. 2013-01-22 14:58:34 -08:00
Jürg Lehni
a5bfa9e5d3 Remove debug logging for Segment / Curve insertion, deletion and splitting. 2013-01-22 14:54:19 -08:00
Jürg Lehni
f09bc84a12 Implement correct handling of Curves / Segments synchronization, improve CurveLocation linking to Curves through their linked Segments, and preserve Curves in Path#split() calls. 2013-01-22 14:46:49 -08:00
Jürg Lehni
8bab10cb5f Define Item#sendToBack() and #bringToFront(). 2013-01-20 17:08:49 -08:00
Jürg Lehni
e4d98f7865 Add internal _cloning parameter to all insertion methods. 2013-01-20 16:14:30 -08:00
Jürg Lehni
1cc3adfd64 Deselect symbol definitions when setting them, to follow unit tests. 2013-01-20 15:58:15 -08:00
Jürg Lehni
18572276c5 Fix a bug with new _drawCount code.
Make sure items are considered selected right away if they are part of the DOM, even before they are getting drawn for the first time.
2013-01-20 15:56:58 -08:00
Jürg Lehni
677ea374c5 Only change #clockwise on closed Paths when inserting into CompoundPaths. 2013-01-20 15:48:06 -08:00
Jürg Lehni
c5ede2e955 Add support for _setProperties() to CompoundPath constructor. 2013-01-20 15:20:10 -08:00
Jürg Lehni
ba5aa86411 Include Roger Willcocks in the thanks regarding isSufficentlyFlat. 2013-01-20 14:28:02 -08:00
Jürg Lehni
50ee598bca Introduce Project#_drawCount mechanism as a better and more efficient way to filter out selected items that are not currently part of the DOM. 2013-01-20 14:01:43 -08:00
Jürg Lehni
e22b3292ed Define a fallback for #drawSelected(), for classes that don't have it yet. 2013-01-20 14:01:43 -08:00
Jürg Lehni
7756e90ff9 Make sure cloned items do not receive the same name when placed inside the same parent, use numbered versions instead. 2013-01-20 14:01:43 -08:00
Jürg Lehni
4346563fe4 No need to merge Path#_serializeFields, simply keep in sync with Item#_serializeFields (excluding #children). 2013-01-20 14:01:43 -08:00
Jürg Lehni
b05a21d6c9 Fix bug in Curve#getLocationOf(). 2013-01-20 14:01:42 -08:00
Jürg Lehni
49c8f8b6b5 A couple of improvements on Path#split(). 2013-01-20 14:01:42 -08:00
Yuval Greenfield
a3a211eead Late load of paperjs should still run paperscripts
See this problem html http://stackoverflow.com/questions/14110205/dynamically-loading-a-script-changes-its-behaviour/14114337 and note how jquery handle this at https://github.com/jquery/jquery/blob/master/src/core.js#L768
2013-01-02 01:57:30 +02:00
Jürg Lehni
b04eb2b98f Implement Path#split() and Curve#split(). 2012-12-31 22:28:41 +01:00
Jürg Lehni
d2b799f4db Fix various issues with Path#curves synchronization. 2012-12-31 22:21:50 +01:00
Jürg Lehni
f0038465cc Fix clearing of removed segments. 2012-12-31 21:45:30 +01:00
Jürg Lehni
a10e44d601 Minor code clean-up. 2012-12-31 21:43:43 +01:00
Jürg Lehni
8cea919dbd Calculate CurveLocation#parameter uncached when dealing with dividing or splitting, since these commands alter the underlying Path. 2012-12-31 21:42:55 +01:00
Jürg Lehni
5a2be6d545 No need for chainable functions on Item types. 2012-12-31 21:42:14 +01:00
Jürg Lehni
d509f86e1a Fix issue where removing segments from open paths would correct curves wrongly. 2012-12-31 21:19:55 +01:00
Jürg Lehni
5da4e89672 Return 'this' in more places to facilitate chained calls inside the library. 2012-12-31 20:07:28 +01:00
Jürg Lehni
8ec8af4dc5 Define CurveLocation#divide(). 2012-12-30 19:53:09 +01:00
Jürg Lehni
e066db4577 Implement Curve#divide(). 2012-12-30 19:49:17 +01:00
Jürg Lehni
4185b63d99 Und recent renaming of #getNearest*() methods. 2012-12-30 19:43:35 +01:00
Jürg Lehni
4ab9a942b0 Clean up Path.Constructor code. 2012-12-30 18:33:46 +01:00
Jürg Lehni
a1fc86b19e Add forgotten passing on of arguments._filtered. 2012-12-30 18:29:01 +01:00
Jürg Lehni
4e20a5794f Remove debug logging. 2012-12-30 18:27:42 +01:00
Jürg Lehni
3319488f5a Fix reading of center point in Rectangle constructor. 2012-12-30 18:26:53 +01:00
Jürg Lehni
8bed8cb15d Define mechanism for flexible reading of named arguments through Base.readNamed() and Base.hasNamed(), and use it to implement property object literal versions of Path.Constructor code. 2012-12-30 18:24:33 +01:00
Jürg Lehni
d0fff09bb0 Allow creation of rectangles from {point, size} and {center, size} object literals. 2012-12-30 18:17:09 +01:00
Jürg Lehni
24b5f870bd Change Base.isObject() to also check for instances of plain Base objects, and rename it to Base.isPlainObject(). 2012-12-30 17:30:13 +01:00
Jürg Lehni
2abefee336 Merge Base.readValue() with Base.read() and rename Base.peekValue() to Base.peek().
When called directly on Base, read() reads values, otherwise the specific type of the subclass it is called on.
2012-12-30 16:07:20 +01:00
Jürg Lehni
1b539301ad Find a better naming convention for the various getLocation* methods (*At for offsets / parameters, *Of for points), implement the missing methods on Curve and use them in Path. 2012-12-27 21:08:03 +01:00
Jürg Lehni
231369fa01 Shorten code a bit, using loops. 2012-12-27 20:46:12 +01:00
Jürg Lehni
cb8f3291d3 Clean up some comments. 2012-12-27 20:19:23 +01:00
Jürg Lehni
5b9d33f32e Fix imprecision in intersection code by re-introducing tolerance parameter in Curve#isFlatEnough(). 2012-12-27 20:13:45 +01:00
Jürg Lehni
3c4978eb04 Rename Curve#getParameter(point) to Curve#getParameterOf(point), to better distinguish from Curve#getParameterAt(length). 2012-12-27 20:09:21 +01:00
Jürg Lehni
00898908d3 Write documentation for PathItem#getIntersections(). 2012-12-27 19:26:40 +01:00
Jürg Lehni
68ad4bb5ba Implement PathItem#getIntersections(path) and Curve#getIntersections(curve) using divide-and-conquer approach, and new Curve.getBounds(). 2012-12-27 19:23:03 +01:00
Jürg Lehni
fdb4bab479 Improve arguments reading in Line constructors.
Avoid parameter overriding.
2012-12-27 19:12:30 +01:00
Jürg Lehni
03b5d58e79 Merge branch 'refs/heads/master' into intersection 2012-12-27 18:43:43 +01:00
Jürg Lehni
75596e1d03 Move a part of Path.getBounds() code into Curve._addBounds(), and use it to also define Curve.getBounds(). 2012-12-27 18:38:55 +01:00
Jürg Lehni
57a9f4fc91 Use constant substitution for Numerical constants as well. 2012-12-27 18:36:59 +01:00
Jürg Lehni
050ca1dcb1 Further clean up Path.getBounds() code. 2012-12-27 17:43:21 +01:00
Jürg Lehni
3a1f2eec3f Restructure Path#getBounds() code so Curve bounds calculations can be moved to Curve. 2012-12-27 15:19:42 +01:00
Jürg Lehni
2673991620 Have Path#_serializeFields inherit from Item#_serializeFields. 2012-12-27 13:04:38 +01:00
Jürg Lehni
8c33e5be88 Fix null exception in Matrix#equals(). 2012-12-27 13:04:21 +01:00
Jürg Lehni
f45c04a359 Remove overridden Path#matrix getters and setters, since we now control behavior through #applyMatrix. 2012-12-27 13:04:07 +01:00
Jürg Lehni
4f83e0eee6 Commit first version of serialization / deserialization mechanism.
It appears to work fine already for Paths and Groups.
2012-12-27 12:45:55 +01:00
Jürg Lehni
ae4e5d4be5 Rename Item#setProperties() to hidden #_setProperties() and add public Item#set() to use same functionality from outside. 2012-12-27 00:52:09 +01:00
Jürg Lehni
0fb89bd3e0 Rename Color#_colorType to #_type, to prepare for serialization mechanism. 2012-12-27 00:48:56 +01:00
Jürg Lehni
3b88bffff1 Document #setProperties() method. 2012-12-26 13:29:40 +01:00
Jürg Lehni
3ac039bd66 Implement properties object literal initialization for all Item constructors. 2012-12-25 22:12:25 +01:00
Jürg Lehni
6b0b6911b4 Clean up code a bit. 2012-12-25 18:09:42 +01:00
Jürg Lehni
ded73142a9 Simplify pointOrMatrix parameters and only allow points. Also remove internal _point cache from PointText and directly link #point to #matrix. 2012-12-25 17:57:04 +01:00
Jürg Lehni
623bed4c4a Also clone the applyMatrix property. 2012-12-25 17:08:17 +01:00
Jürg Lehni
947afe85f0 Simplify Path#initialize() code. 2012-12-25 16:59:05 +01:00
Jürg Lehni
8f093f6dd7 Remove all PORT comments, since we won't port back features to Scriptographer. 2012-12-25 16:07:48 +01:00
Jürg Lehni
b54bdadaff Rename Item#transformContent to #applyMatrix. 2012-12-24 17:39:24 +01:00
Jürg Lehni
9d47bfcf0b Suppress weird JSdoc warnings. 2012-12-24 17:20:00 +01:00
Jürg Lehni
4731a8909d Update copyright / library information. 2012-12-24 16:50:10 +01:00
Jürg Lehni
1e283fe113 Implement Raster#source and clean up #initialize() 2012-12-24 01:12:41 +01:00
Jürg Lehni
d6fceb928f Implement Item#transformContent property, which controls wether Item#transform() directly applies transformations to contents, or simply stores them in Item#matrix. 2012-12-24 00:39:42 +01:00
Jürg Lehni
e21ea457a7 Remove Item#apply() and clean up #applyMatrix() and simplify handling. 2012-12-24 00:29:09 +01:00
Peter
1bb7c9f1aa Use Item.draw in rasterize 2012-12-23 17:52:43 +01:00
Jürg Lehni
1046e440e8 Improve documentation. 2012-12-23 16:01:53 +01:00
Jürg Lehni
734cc1cc61 Undo commit 4445376c0204cb5a2e408c64b77a5b6fa09305ba since it clashes with magnification. 2012-12-21 16:41:57 +01:00
Jürg Lehni
c025c41ec0 Start implementing PathItem#getIntersections(). 2012-12-21 16:13:38 +01:00
Jürg Lehni
d43cc28aac Optimise Curve constructors that construct from 4 arguments (points) and 8 (coordinate values). 2012-12-20 18:03:11 +01:00
Jürg Lehni
e10ef4dba3 Fix comment. 2012-12-19 03:22:57 +01:00
Jürg Lehni
22ddd7a37e Implement CompoundPath#curves. 2012-12-18 14:53:38 +01:00
Jürg Lehni
29a2bc781b Implement the various bounds getter on Curve too, using caching and the new static Path.get*Bounds methods. 2012-12-18 14:35:21 +01:00
Jürg Lehni
4de5f30f72 Improve documentation. 2012-12-18 14:19:22 +01:00
Jürg Lehni
c63e2c8f79 Clean up bounds scope indentation. 2012-12-18 14:19:13 +01:00
Jürg Lehni
9a8dddd7df Move Item#isEmpty() out of bounds scope and define documentation for it. 2012-12-18 14:18:53 +01:00
Jürg Lehni
05ab8910ea Optimise GradientStop constructor for better minification. 2012-12-18 13:49:29 +01:00
Jürg Lehni
15824e7aaf Fix isEmpty for TextItems.
Closes #133.
2012-12-18 05:29:03 +01:00
Jürg Lehni
9022bb232b Simplify getGlobalMatrix(). 2012-12-18 00:22:39 +01:00