paper 0.15.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/CHANGELOG.md +158 -0
  2. package/README.md +24 -16
  3. package/dist/docs/assets/js/paper.js +4811 -808
  4. package/dist/docs/classes/AreaText.html +771 -243
  5. package/dist/docs/classes/ChangeFlag.html +1 -1
  6. package/dist/docs/classes/Color.html +218 -21
  7. package/dist/docs/classes/CompoundPath.html +1174 -274
  8. package/dist/docs/classes/Curve.html +2 -2
  9. package/dist/docs/classes/CurveLocation.html +1 -1
  10. package/dist/docs/classes/DrawEvent.html +69 -0
  11. package/dist/docs/classes/Effect.html +434 -0
  12. package/dist/docs/classes/EffectInstance.html +304 -0
  13. package/dist/docs/classes/Event.html +1 -1
  14. package/dist/docs/classes/Gradient.html +1 -1
  15. package/dist/docs/classes/GradientStop.html +1 -1
  16. package/dist/docs/classes/Group.html +842 -243
  17. package/dist/docs/classes/HitResult.html +1 -1
  18. package/dist/docs/classes/HostItem.html +770 -242
  19. package/dist/docs/classes/Item.html +827 -242
  20. package/dist/docs/classes/Key.html +1 -1
  21. package/dist/docs/classes/KeyEvent.html +1 -1
  22. package/dist/docs/classes/Layer.html +784 -185
  23. package/dist/docs/classes/Matrix.html +1 -1
  24. package/dist/docs/classes/MouseEvent.html +1 -1
  25. package/dist/docs/classes/PaperScope.html +1 -1
  26. package/dist/docs/classes/PaperScript.html +4 -2
  27. package/dist/docs/classes/Path.html +1366 -352
  28. package/dist/docs/classes/PathItem.html +1198 -298
  29. package/dist/docs/classes/PathText.html +772 -244
  30. package/dist/docs/classes/PatternDefinition.html +367 -0
  31. package/dist/docs/classes/Point.html +33 -5
  32. package/dist/docs/classes/PointText.html +771 -243
  33. package/dist/docs/classes/Project.html +251 -9
  34. package/dist/docs/classes/Raster.html +770 -242
  35. package/dist/docs/classes/Rectangle.html +50 -8
  36. package/dist/docs/classes/Segment.html +79 -2
  37. package/dist/docs/classes/Shape.html +770 -242
  38. package/dist/docs/classes/Size.html +31 -3
  39. package/dist/docs/classes/StrokeProfileStop.html +346 -0
  40. package/dist/docs/classes/Style.html +67 -6
  41. package/dist/docs/classes/SymbolDefinition.html +28 -2
  42. package/dist/docs/classes/SymbolItem.html +807 -242
  43. package/dist/docs/classes/TextItem.html +771 -243
  44. package/dist/docs/classes/TextRange.html +1 -1
  45. package/dist/docs/classes/TextStory.html +1 -1
  46. package/dist/docs/classes/Tool.html +2 -2
  47. package/dist/docs/classes/ToolEvent.html +1 -1
  48. package/dist/docs/classes/Tween.html +1 -1
  49. package/dist/docs/classes/View.html +2 -2
  50. package/dist/docs/classes/global.html +1 -1
  51. package/dist/docs/classes/index.html +2 -2
  52. package/dist/docs/index.html +1 -1
  53. package/dist/node/browser.js +15 -0
  54. package/dist/paper-core.js +4701 -728
  55. package/dist/paper-core.min.js +3 -3
  56. package/dist/paper-full.js +4811 -808
  57. package/dist/paper-full.min.js +3 -3
  58. package/dist/paper-hosted.js +5389 -892
  59. package/dist/paper.d.ts +1058 -69
  60. package/examples/Paperjs.org/LiveEffects.html +366 -0
  61. package/examples/Paperjs.org/Offsetting.html +379 -0
  62. package/examples/Paperjs.org/StrokeProfiles.html +706 -0
  63. package/examples/Scripts/Patterns.html +57 -0
  64. package/package.json +21 -11
package/CHANGELOG.md CHANGED
@@ -1,5 +1,163 @@
1
1
  # Change Log
2
2
 
3
+ ## `0.17.0`
4
+
5
+ ### Added
6
+
7
+ - Add `PathItem#offset(distance, options)`, which grows, shrinks or offsets
8
+ paths and compound paths with miter, round or bevel corners (#371).
9
+ - Add `PathItem#outline(options)`, which turns the stroke of a path item into a
10
+ filled path item, with its joins, caps and dashes (#371).
11
+ - Add `PathItem#dash(options)`, which cuts a stroke into its dashes as the
12
+ canvas draws them, as a group of open paths.
13
+ - Add stroke profiles, `Path#strokeProfile`: stops along a path that change
14
+ the width, aspect and angle of the pen that draws its stroke, see
15
+ `StrokeProfileStop`. Not yet supported: compound paths, `strokeScaling` off,
16
+ and `offset()`, boolean operations, `interpolate()` and SVG (#2505, #2506,
17
+ #2507).
18
+ - Add live effects, `Item#effects`, which change what an item draws without
19
+ changing the item, starting with `offset` and `outline`. `Effect` defines new
20
+ ones, and `Item#previewBounds` measures what they draw.
21
+ - Add pattern colors from a `PatternDefinition`, which tiles a raster or any
22
+ other item, for fills and strokes, also in SVG and JSON (#829).
23
+ - Add `Color#aspect` for elliptical radial gradients, and transform gradients
24
+ exactly with their items, also when these scale unevenly or shear (#1744).
25
+ - Add `Group#buffered`, which keeps a group's drawing in a canvas until the
26
+ group changes, for large groups that rarely do (#377).
27
+ - Add `Item#onDraw` and `Item#onDrawSelection`, which draw beneath an item or
28
+ its selection, or replace them, also as class-level handlers such as
29
+ `Path.onDraw`.
30
+ - Add `PathItem#arcAround(center, angle)` and `PathItem#arcTowards(to)`
31
+ (#1052).
32
+ - Support `options` in `PathItem#simplify()`, with `tolerance` and a range of
33
+ segments through `from` and `to`, as in `PathItem#smooth()` (#2501).
34
+ - Export and import the names and data of segments in SVG, as a
35
+ `data-paper-segments` attribute (#2398).
36
+ - Add `Project#onActivate` and `Project#onDeactivate`, also as
37
+ `Project.onActivate` and `Project.onDeactivate` for all projects.
38
+ - Pass the import attributes of `import … with { … }` in PaperScript on to the
39
+ loader in `options.load` of `PaperScript.execute()`.
40
+ - Hosted projects, see `Project#host`:
41
+ - Share symbol and pattern definitions between items, referred to by their
42
+ keys in JSON, and let scripts create new ones.
43
+ - Load the pixels of rasters from the host on first access.
44
+ - Load items in full when they move into a project with another host.
45
+ - Call `Item#onDraw` and `Item#onDrawSelection`, through `Project#draw()`.
46
+
47
+ ### Changed
48
+
49
+ - Run the library in strict mode, which makes `Path#getNearestPoint()` about
50
+ 14% and `Item#hitTest()` about 6% faster. PaperScript still runs in sloppy
51
+ mode.
52
+ - Draw items with opacity, blend modes or shadows about twice as fast (#377).
53
+ - Make `PaperScope#project` an accessor, so that PaperScript's `project`
54
+ follows the active project, as `view` does.
55
+ - Emit `deactivate` when the active project or tool is removed.
56
+ - Write the definition of symbol items to JSON as `definition` instead of
57
+ `symbol`, which still loads.
58
+ - Let hosted linked text that moves into a project with another host bring a
59
+ copy of its story along (#2462, #2463).
60
+
61
+ ### Fixed
62
+
63
+ - Fix boolean operations that could lose areas or whole results, at straight
64
+ curves, near-coincident crossings, curves running back and forth along a
65
+ line, shallow crossings and merged vertices.
66
+ - Measure curve lengths precisely near cusps, where `Curve#getLength()` and
67
+ `Path#getPointAt()` were off by up to 6%.
68
+ - Find the nearest point on curves that cover a lot of ground between their
69
+ samples, in `#getNearestPoint()` and the methods using it.
70
+ - Fix `PathItem#smooth()` with a negative `to` on closed paths, which threw.
71
+ - Fix `PathItem#arcTo()` with tiny arcs, which missed their end point.
72
+ - Keep the attributes of compound paths in `CompoundPath#reduce()` when a
73
+ single child is left.
74
+ - Return `false` from `CompoundPath#simplify()` without children.
75
+ - Keep the stripes of linear gradients across them when transforming them
76
+ unevenly (#1744).
77
+ - Export the gradients of items that keep their matrix to SVG in the
78
+ coordinates of their elements (#2410).
79
+ - Honor the `bounds` and `matrix` options of `Item#exportSVG()`.
80
+ - Keep `Group#isolated` and `Group#buffered` in clones.
81
+ - Keep the content of rasters when setting `Raster#size`.
82
+ - Load `new Raster(source)` from a string where there is no document, as in
83
+ workers.
84
+ - Draw the segments of selected paths again by default (#1899).
85
+ - Count the duration of `Item#tween()` from the first frame.
86
+ - PaperScript: compile `++` and `--` correctly wherever they appear, keep
87
+ keywords apart from replaced expressions in minified code, report the right
88
+ lines in stack traces on V8, and return an object from `compile()` for empty
89
+ code.
90
+ - Hosted projects: leave items that moved away out of `Project#takeChanges()`,
91
+ and turn off `View#autoUpdate` when setting `Project#host`.
92
+ - Let Angular's esbuild builder bundle Paper.js for browsers (#2035).
93
+
94
+ ## `0.16.0`
95
+
96
+ ### Added
97
+
98
+ - Add the `processNode` option to `#exportSVG()` and the `processItem` option
99
+ to `#importSVG()`: callbacks that receive `{ item, node }` for each exported
100
+ item with its SVG node and each imported SVG element with its item, and can
101
+ return a replacement, e.g. to keep the SVG `class` attribute in `Item#data`
102
+ (#1843).
103
+ - Let `Rectangle#scale()` take a center point to scale from, as
104
+ `Item#scale()` does, and normalize rectangles scaled by negative amounts
105
+ (#1352).
106
+ - Add `Segment#name` and `Segment#data`, stored in JSON but not in SVG. Named
107
+ segments can be accessed by name through `Path#segments`, as named items
108
+ through `Item#children` (#1459).
109
+ - Add `Style#paintOrder` and `Item#paintOrder`: `'stroke'` paints the stroke
110
+ before the fill of paths, shapes and text, as in SVG's `paint-order`, which
111
+ is exported and imported (#1731).
112
+ - Lay out right-to-left text in the order it reads: the pieces of the lines of
113
+ paragraphs whose `direction` is `'rtl'` are placed, hit and exported from the
114
+ right, path text runs from the path's end towards its start, and canvas
115
+ measures and draws text in its paragraph's direction (#2389).
116
+ - Export layers to SVG with a `data-paper-layer` attribute, and import the
117
+ groups that carry it as `Layer` items again, inside the imported group
118
+ (#483).
119
+ - Add `SymbolItem#embed()`, which replaces a symbol item with a copy of its
120
+ definition's item, transformed by the symbol item's matrix and combined with
121
+ its opacity, visibility, blend mode and other attributes (#953).
122
+ - `Project#currentTextStyle` in hosted projects: the style new text items take
123
+ in place of `Project#currentStyle` when the host sets one, for hosts whose
124
+ new text has defaults of its own, such as a black fill without a stroke.
125
+ - Add `Point#values`, `Size#values` and `Rectangle#values`, which give their
126
+ numbers as an array, as `Matrix#values` does.
127
+ - Add `options.evaluate` to `PaperScript.execute()`, for hosts whose engine
128
+ doesn't name code from `Function()` in stack traces, such as JavaScriptCore.
129
+
130
+ ### Changed
131
+
132
+ - Apply the `data-*` attributes of imported SVG elements to `Item#data` before
133
+ calling the `processItem` callback of `#importSVG()`, so that it can extend
134
+ the data, instead of after it, which replaced the data that it stored. Items
135
+ that the callback returns as replacements no longer receive the data.
136
+
137
+ ### Deprecated
138
+
139
+ - The undocumented `onExport(item, node, options)` and
140
+ `onImport(node, item, options)` options of `#exportSVG()` and
141
+ `#importSVG()`, replaced by `processNode` and `processItem`.
142
+
143
+ ### Fixed
144
+
145
+ - Only call the import callback of `#importSVG()` for SVG elements, not also
146
+ for the document of SVG strings, which received the item of its root element
147
+ a second time.
148
+ - Leave out the item itself and its ancestors when inserting children, which
149
+ created a cycle in the scene graph and overflowed the stack, e.g. in
150
+ `new Group({ children: [new Layer()] })`, and return `null` from
151
+ `Item#insertChildren()` when none of the items can be inserted (#2406).
152
+ - Keep the text path of hosted `PathText` and `AreaText` items when the host
153
+ changes them: `Project#invalidate()` loads its new geometry into the path
154
+ that scripts hold, which it replaced before.
155
+ - Hit-test the strokes of shapes as those of their paths, which `Shape` only
156
+ approximated for ellipses and rounded corners, and for non-scaling strokes
157
+ under non-uniform matrices (#2334).
158
+ - Name PaperScript's url in stack traces also without source maps, and in the
159
+ location of its syntax errors.
160
+
3
161
  ## `0.15.0`
4
162
 
5
163
  ### Added
package/README.md CHANGED
@@ -277,28 +277,36 @@ Your docs will then be located at `dist/docs`.
277
277
 
278
278
  ### Testing
279
279
 
280
- Paper.js was developed and tested from day 1 using proper unit testing through
281
- jQuery's [Qunit](https://qunitjs.com/). To run the tests after any
282
- change to the library's source, simply open `index.html` inside the `test`
283
- folder in your web browser. There should be a green bar at the top, meaning all
284
- tests have passed. If the bar is red, some tests have not passed. These will be
285
- highlighted and become visible when scrolling down.
286
-
287
- If you are testing on Chrome, some of the tests will fail due to the browser's
288
- CORS restrictions. In order to run the browser based tests on Chrome, you need
289
- to run a local web-server through Gulp.js. The following command will handle it
290
- for you, and will also open the browser at the right address straight away:
280
+ The tests run with [Vitest](https://vitest.dev/), on Node.js and in Chromium
281
+ through [Playwright](https://playwright.dev/), against the library built from
282
+ the sources:
291
283
 
284
+ pnpm test
285
+
286
+ To run them only on Node.js, or only in the browser:
287
+
288
+ pnpm test:node
292
289
  pnpm test:browser
293
290
 
294
- To run them in headless Chrome instead, as CI does, and report the result in the
295
- terminal:
291
+ The browser tests need Chromium for Playwright, which this installs once:
296
292
 
297
- pnpm test:chrome
293
+ pnpm exec playwright install chromium
298
294
 
299
- To test the Node.js version of Paper.js, use this command:
295
+ Once the library is built in `dist`, the tests run against that instead. Select
296
+ another build than `paper-full.js` with `PAPER_BUILD`, e.g.
297
+ `PAPER_BUILD=hosted pnpm test:node`. Vitest also runs single files, and watches
298
+ for changes with `pnpm exec vitest`.
300
299
 
301
- pnpm test
300
+ The screenshot tests in `test/screenshots` compare what the library draws with
301
+ reference images. Rendering differs between systems, so they run in Playwright's
302
+ Docker image, which needs [Docker](https://www.docker.com/):
303
+
304
+ pnpm test:screenshots
305
+
306
+ To write new reference images, after adding a test or changing what it draws,
307
+ and review them in `test/screenshots/__screenshots__` before committing:
308
+
309
+ pnpm test:screenshots --update
302
310
 
303
311
  ### Contributing [![Open Source Helpers](https://www.codetriage.com/paperjs/paper.js/badges/users.svg)](https://www.codetriage.com/paperjs/paper.js)
304
312