paper 0.14.0 → 0.15.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 (57) hide show
  1. package/CHANGELOG.md +252 -0
  2. package/README.md +3 -1
  3. package/dist/docs/assets/js/paper.js +6997 -1658
  4. package/dist/docs/classes/AreaText.html +8658 -0
  5. package/dist/docs/classes/ChangeFlag.html +2 -1
  6. package/dist/docs/classes/Color.html +2 -1
  7. package/dist/docs/classes/CompoundPath.html +152 -67
  8. package/dist/docs/classes/Curve.html +2 -1
  9. package/dist/docs/classes/CurveLocation.html +2 -1
  10. package/dist/docs/classes/Event.html +5 -4
  11. package/dist/docs/classes/Gradient.html +2 -1
  12. package/dist/docs/classes/GradientStop.html +2 -1
  13. package/dist/docs/classes/Group.html +117 -15
  14. package/dist/docs/classes/HitResult.html +2 -1
  15. package/dist/docs/classes/HostItem.html +80 -15
  16. package/dist/docs/classes/Item.html +137 -15
  17. package/dist/docs/classes/Key.html +2 -1
  18. package/dist/docs/classes/KeyEvent.html +5 -4
  19. package/dist/docs/classes/Layer.html +114 -15
  20. package/dist/docs/classes/Matrix.html +2 -1
  21. package/dist/docs/classes/MouseEvent.html +5 -4
  22. package/dist/docs/classes/PaperScope.html +4 -2
  23. package/dist/docs/classes/PaperScript.html +5 -2
  24. package/dist/docs/classes/Path.html +126 -67
  25. package/dist/docs/classes/PathItem.html +270 -185
  26. package/dist/docs/classes/PathText.html +8528 -0
  27. package/dist/docs/classes/Point.html +13 -2
  28. package/dist/docs/classes/PointText.html +1346 -59
  29. package/dist/docs/classes/Project.html +40 -7
  30. package/dist/docs/classes/Raster.html +80 -15
  31. package/dist/docs/classes/Rectangle.html +3 -2
  32. package/dist/docs/classes/Segment.html +2 -1
  33. package/dist/docs/classes/Shape.html +80 -15
  34. package/dist/docs/classes/Size.html +4 -2
  35. package/dist/docs/classes/Style.html +767 -14
  36. package/dist/docs/classes/SymbolDefinition.html +2 -1
  37. package/dist/docs/classes/SymbolItem.html +80 -15
  38. package/dist/docs/classes/TextItem.html +1469 -179
  39. package/dist/docs/classes/TextRange.html +186 -0
  40. package/dist/docs/classes/TextStory.html +355 -0
  41. package/dist/docs/classes/Tool.html +2 -1
  42. package/dist/docs/classes/ToolEvent.html +57 -4
  43. package/dist/docs/classes/Tween.html +17 -1
  44. package/dist/docs/classes/View.html +9 -8
  45. package/dist/docs/classes/global.html +2 -1
  46. package/dist/docs/classes/index.html +2 -2
  47. package/dist/docs/index.html +1 -1
  48. package/dist/paper-core.js +6832 -1637
  49. package/dist/paper-core.min.js +3 -3
  50. package/dist/paper-full.js +6997 -1658
  51. package/dist/paper-full.min.js +3 -3
  52. package/dist/{paper-sourced.js → paper-hosted.js} +7109 -1682
  53. package/dist/paper.d.ts +1727 -163
  54. package/examples/Scripts/AreaText.html +65 -0
  55. package/examples/Scripts/PathText.html +48 -0
  56. package/examples/Scripts/TextRanges.html +51 -0
  57. package/package.json +3 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,257 @@
1
1
  # Change Log
2
2
 
3
+ ## `0.15.0`
4
+
5
+ ### Added
6
+
7
+ - Load text items from the host of a hosted project, see `Project#host`, with
8
+ their stories, and the paths and settings of path and area text, and let
9
+ hosts lay them out as their documents do, through `host.layOut()`, given
10
+ their JSON as the script holds them, also before the host has its changes,
11
+ or `null` for text the script didn't change, which the host has as it is.
12
+ - Add text ranges: `TextRange`, a part of a text whose style properties read
13
+ what its letters and paragraphs share and set them, from
14
+ `TextItem#range(start, end)`, `#runs`, `#paragraphs`, `#words`, `#letters`
15
+ and `#lines`, which ranges have too, and `#replace(content, start, end)`, and
16
+ `TextStory`, a text's content, runs and paragraphs, as `TextItem#story`.
17
+ - Add text linking: `TextItem#link()`, `#unlink()`, `#isLinked()`,
18
+ `#nextTextItem`, `#previousTextItem` and `#visibleRange`, by which a story
19
+ flows through several text items, which `TextStory#textItems` lists.
20
+ - Add `PathText`, text along a path between `startOffset` and `endOffset`, each
21
+ letter turned to the path, which it takes as `TextItem#textPath`.
22
+ - Add `AreaText`, text inside any path as its `textPath`, holes too, in
23
+ columns and rows, with lines breaking between words and at soft hyphens,
24
+ `verticalAlign`, `fitHeight()`, and `lineWrap`, a paragraph property that
25
+ balances the lines.
26
+ - Add `Item#textWrap`, by which items push aside the text of the area texts
27
+ below them in their layer, or let it flow inside them.
28
+ - Export area text, text on paths and text with mixed styles to SVG: point text
29
+ keeps a `<tspan>` per line, with one per run where styles are mixed, and area
30
+ text and text on paths are placed piece by piece, as they are laid out.
31
+ - Add character style properties: `fontStyle`, `lineHeight`, `letterKerning`,
32
+ `letterScaling`, `letterRotation`, `baselineShift`, `baselinePosition`,
33
+ `capitals`, `underline` and `strikethrough`, and `fontVariations` and
34
+ `features` for hosts.
35
+ - Add paragraph style properties: `justifyLast`, `startIndent`, `endIndent`,
36
+ `firstLineIndent`, `spaceBefore`, `spaceAfter` and `direction`, the
37
+ justifications `'start'`, `'end'` and `'justify'`, and `justifySpacing`,
38
+ `hyphenation`, `composer` and `tabs` for hosts.
39
+ - Let `Item#strokeBounds` be selected and set, as `Item#bounds` can:
40
+ `item.strokeBounds.selected` draws the stroke bounds and their handles,
41
+ independently of `item.bounds.selected`, and setting them scales the item so
42
+ its stroke bounds match, also where its stroke's extent changes with its
43
+ proportions, as with miters (#1030).
44
+ - Import the `data-*` attributes of SVG elements into `item.data`, with their
45
+ names camelized as in `dataset`, next to `data-paper-data` (#1227).
46
+ - Export shadows to SVG as SVG 1.1 filters, which both browsers and editors
47
+ such as Illustrator render, except for items without width or height, and
48
+ import them back, along with CSS `drop-shadow()` (#1003).
49
+ - Import SVG masks as clip masks, which is exact for masks of solid white
50
+ shapes, or of opaque shapes with `mask-type="alpha"`, and warns that other
51
+ masks are approximated (#1916).
52
+ - Add `Group#ungroup()`, which replaces a group with its children, applying its
53
+ matrix to them, and let `Item#replaceWith()` take several items (#1026).
54
+ - Add `settings.segmentSize`, the size of the segments when drawing selections,
55
+ next to `settings.handleSize` for their handles, which it defaults to
56
+ (#1899).
57
+ - Add `angleInRadians` to the object literals that create points, next to
58
+ `angle`, e.g. `new Point({ length: 10, angleInRadians: Math.PI / 2 })` (#562).
59
+ - Add `Project#hasChanges()`, which tells whether changes were logged since the
60
+ last `Project#takeChanges()`, without taking them.
61
+ - Add dynamic `import(specifier)` to PaperScript, which resolves to the module's
62
+ namespace through the loader in `options.load`, which may return a Promise.
63
+ - Add static `import` to PaperScript, through a loader that hosts pass as
64
+ `options.load` to `PaperScript.execute()`, together with `export … from`. It
65
+ needs a current Acorn as `self.acorn`.
66
+ - Add `Item.getBounds(items[, options])`, the bounds of a list of items in
67
+ project coordinates as if they were grouped, e.g. of the selection (#2252).
68
+ - Add `ToolEvent#velocity` and `#elapsed`, the velocity of the mouse since the
69
+ last tool event in points per second, and the time since then in seconds,
70
+ which stay even when the system misses a mouse report.
71
+ - Add `Event#time`, the time of the event in seconds, as frame events have it,
72
+ and `options.time` to `View#dispatchMouseEvent()` and `#dispatchKeyEvent()`.
73
+ - Add a setter to `View#bounds`, which fits the view to the given rectangle, as
74
+ `View#fitBounds()` does.
75
+ - Let `PathItem#unite()`, `#intersect()`, `#subtract()` and `#exclude()` take
76
+ an array of paths, which they combine in one call: unite, intersect and
77
+ subtract in a balanced tree, exclude in one even-odd pass. Uniting 500 paths
78
+ takes 0.22 s instead of 2.9 s chained, excluding them 0.45 s instead of
79
+ minutes (#2094, #2303, #2304).
80
+ - Load hosted text that the host links into one story, which `host.getStory()`
81
+ gives once for all of its items, whichever of them loads first.
82
+
83
+ ### Changed
84
+
85
+ - Lay out text by the ascent and descent of its fonts: the bounds of
86
+ `PointText` are its lines' line heights, with the leading split around their
87
+ ascent and descent, instead of 3/4 of the first above its baseline and 1/4 of
88
+ the last below.
89
+ - Replace `leading` by `lineHeight`, `'auto'` (1.2) or another factor of the
90
+ font size, or a fixed length; `leading` still sets and reads a fixed line
91
+ height in pixels. Rename `tracking` to `letterTracking`, which `tracking`
92
+ still sets and reads.
93
+ - Make `Style#getFontStyle()` return the CSS font style, `'normal'`,
94
+ `'italic'` or `'oblique'`, instead of the font as canvas takes it, and remove
95
+ `Style#getTrackingStyle()`.
96
+ - Only go into the children that items show in `Item#getItems()`, and log the
97
+ changes of children that their parent doesn't show, such as a text's path, as
98
+ the parent's.
99
+ - Make `Item#intersects()` check whether the items overlap, also when one
100
+ contains the other, as `Rectangle#intersects()` does, instead of only whether
101
+ their outlines cross, and use it in `getItems({ overlapping })` for items
102
+ whose bounds contain the rectangle (#1751).
103
+ - Use `settings.hitTolerance` for the mouse events of items, such as
104
+ `mouseenter` and `click`, which always hit-tested with a tolerance of 0
105
+ (#1971).
106
+ - Keep the named exports of PaperScript modules with a default export:
107
+ `export default x` now sets `module.exports.default` instead of replacing the
108
+ exports, and such modules are marked with `__esModule`. `import x` receives
109
+ the default export, or the whole exports of CommonJS-style modules, and
110
+ `import * as m` all exports, with CommonJS-style ones also as `m.default`.
111
+ So `PaperScript.execute()` returns `{ default: x }` for `export default x`.
112
+ - Deprecate `Event#timeStamp` in milliseconds, and the `options.timeStamp` of
113
+ `View#dispatchMouseEvent()` and `#dispatchKeyEvent()`, for the new `time`
114
+ in seconds.
115
+ - Rename the `paper-sourced.js` build to `paper-hosted.js`, and `Project#source`
116
+ to `Project#host`, to match `HostItem` and the host document that backs the
117
+ items.
118
+ - Draw dashes with `setLineDash()`, which every canvas supports, and remove
119
+ the dash emulation for canvases without it, along with the undocumented
120
+ `paper.support.nativeDash` (#2350).
121
+ - Trace the results of boolean operations through a planar graph of the
122
+ operands' curves, which each operation builds within one geometric
123
+ tolerance: intersections within it merge into one vertex, curves that pass
124
+ within it of a vertex are cut there, and coincident curves become one edge.
125
+ Results are correct to within about five times that tolerance, under a
126
+ thousandth of a unit on a drawing of 1,000 units, and stable under tiny
127
+ moves of the operands. They can differ from before in where their contours
128
+ start and how they are divided, but not in their areas. Holes come out
129
+ oriented opposite to their outlines, and islands like outlines (#2292).
130
+ - `PathItem#resolveCrossings()` returns the filled outline of a path, without
131
+ the inner loops that its fill rule covers (#2292).
132
+ - Make boolean operations faster than in 0.14.0 on all inputs measured, from
133
+ about 15% on small operations up to 5.7× on large polygons (#2293, #2296,
134
+ #2297, #2299, #2300, #2301, #2302, #2305).
135
+ - Draw the CSS blend modes as `'normal'` in old browsers whose canvas doesn't
136
+ support them, such as Internet Explorer and the old Edge, instead of
137
+ emulating them pixel by pixel. Paper.js's own modes, such as `'add'`, are
138
+ still emulated (#2350).
139
+ - Remove the undocumented statics `Curve.getBounds(values)`, a leftover of
140
+ old intersection code, and `Curve.getCurveLineIntersections()`, which
141
+ nothing in the library calls.
142
+ - Drop the code for browsers without current DOM APIs, which only old IE, Edge
143
+ and WebKit needed: MS pointer events, `srcElement`, `toElement`,
144
+ `keyIdentifier`, `backingStorePixelRatio`, and the exception of
145
+ `getBoundingClientRect()` for nodes outside the DOM (#2350).
146
+
147
+ ### Fixed
148
+
149
+ - Hit-test strokes with `'miter'` and `'bevel'` joins next to smooth segments,
150
+ which are joined round, as the stroke bounds already treat them (#2342).
151
+ - Update `Item#strokeBounds` after changing the stroke of items without a
152
+ parent, such as shapes, texts, symbol items and groups, which kept the old
153
+ stroke bounds (#2343).
154
+ - Fix `Path#handleBounds` of empty paths, which were infinite: they are an
155
+ empty rectangle, as their `bounds` (#2345).
156
+ - Import the paragraphs of text items after their content, also from JSON that
157
+ lists them first, as JSON written by other tools may.
158
+ - Keep gradients in the runs of text items through `#exportJSON()` and
159
+ `#importJSON()`, and round their style values and those of their paragraphs
160
+ to the `precision` of the export (#2348).
161
+ - Keep what scripts write to hosted items before they load, such as their
162
+ `pivot` or an area text's `columns`, which loading replaced.
163
+ - Fix the stroke bounds of non-scaling strokes under non-uniform matrices,
164
+ whose miters, bevels and square caps followed the untransformed angles.
165
+ - Fix `Item#strokeBounds` after scaling items that apply their matrix, such
166
+ as paths and groups, when they were read before: the cached stroke bounds
167
+ were scaled along, including the width of the stroke, which doesn't scale.
168
+ - Fix SVG export of `opacity` and `blendMode`, which aren't inherited, so
169
+ children with the same values as their group lost them, and the defaults
170
+ were written where the group differed.
171
+ - Fix the shadows of items that are both filled and stroked, which only cast
172
+ the shadow of their fill, partly covered by the stroke (#892).
173
+ - Fix the shadows of text items, which only text with both a fill and a
174
+ stroke drew (#2347).
175
+ - Fix the points at offsets of `PathFlattener` on straight curves, such as
176
+ lines without handles, whose curve-time doesn't follow their length, which
177
+ placed them off everywhere but at the ends.
178
+ - Fix SVG import of `<use>` elements, which now pass their styles and those of
179
+ their parents on to the referenced element, as in SVG, instead of the styles
180
+ of the place where it is defined, and skip circular references (#2090).
181
+ - Divide the operands of boolean operations at all their intersections, also
182
+ where they only touch, which makes the results of near-coincident geometry
183
+ more stable, and ends the endless loop of #1849.
184
+ - Fix `Curve#getTimeOf()` for points near the ends of straight curves, which it
185
+ solved to times far from the ends, as it only tested the ends exactly.
186
+ - Fix boolean operations that backtracked while tracing their result, which could
187
+ give a curve of it the handle of a dead end and make it bulge.
188
+ - Measure text in views without a canvas of their own, such as in workers, with a
189
+ canvas from `CanvasProvider`, e.g. an `OffscreenCanvas`, so `PointText` has
190
+ bounds there too.
191
+ - Fix PaperScript's exported variable declarations without semicolons, such as
192
+ `export const a = 1`, which compiled to invalid code.
193
+ - Fix `Curve#classify()` reporting points of inflection, cusps and loops at the
194
+ very ends of curves, which made boolean operations miss crossings at those
195
+ vertices (#1879, #1387).
196
+ - Fix PaperScript's compound assignments of properties, such as
197
+ `array[index()] += 1`, which evaluated their object and key twice.
198
+ - Fix PaperScript with a current Acorn provided as `self.acorn`, which parses
199
+ all current syntax now, and its exports: of functions and classes, of renamed
200
+ names (`export { a as b }`), of several declarations in a row, and of
201
+ variables, which stay usable in the script itself.
202
+ - Fix intersections of curves and lines at the curves' ends, which were lost
203
+ when the curve touched the line there, e.g. at a zero-length handle (#1848).
204
+ - Fix the orientation of the results of `PathItem#exclude()` and
205
+ `#subtract()`, whose parts of the second path kept its reversed orientation,
206
+ giving them negative areas (#2064).
207
+ - Fix `PathItem#interiorPoint` returning points on the path itself, such as a
208
+ vertex shared with another path, which made boolean operations of paths that
209
+ only touch keep or drop the wrong parts (#1837, #1979).
210
+ - Fix intersections and boolean operations of curves and paths that only touch,
211
+ at coordinates beyond 16384, where the tolerance of their bounds checks got
212
+ lost in floating point (#1940, #1882).
213
+ - Fix boolean operations on open paths that end where they start, which lost
214
+ the curve between their ends (#1929, #1973, #1989, #2018).
215
+ - Fix boolean operations with `{ trace: false }` on closed paths, which could
216
+ keep or drop the wrong parts depending on where the path started, and on
217
+ compound paths, which threw an error (#1540, #1541, #1746, #1998, #2046).
218
+ - Document `Item#fullySelected`, which all items have, not only paths (#1687).
219
+ - Type options objects from their documented options, such as those of
220
+ `Item#hitTest()`, `#exportSVG()` and `#rasterize()`, so misspelled options are
221
+ errors in TypeScript (#1666).
222
+ - Type the setters of point, size, rectangle and color properties with the
223
+ values they accept, such as `item.position = [10, 20]` and
224
+ `item.fillColor = 'red'`. The typings now need TypeScript 4.3 (#1665).
225
+ - Handle the mouse events of `View#dispatchMouseEvent()` also outside the
226
+ view's bounds, since the host decides which events belong to its drawing
227
+ surface.
228
+ - Fix boolean operations on paths that touch or overlap along their edges,
229
+ run close to each other, or cross near their vertices, which lost or added
230
+ parts of their results (#1285, #1362, #1867, #1917, #1943, #1961, #2002,
231
+ #2036, #2096, #2099).
232
+ - Fix `PathItem#resolveCrossings()` on paths with both overlaps and crossings,
233
+ which lost parts of their outlines (#2290).
234
+ - Fix `Curve.getTimeOf()` at coordinates beyond about 2e8, where it didn't
235
+ recognize points on the curve (#2291).
236
+ - Hit-test non-scaling strokes under non-uniform matrices where they're drawn,
237
+ also next to corners, joins and caps, and with skewed or rotated matrices
238
+ (#2334).
239
+ - Fix `Curve#strokeBounds` of curves without a path, which threw: without a
240
+ path, there is no stroke, so they are the curve's bounds (#2344).
241
+ - Give `View#dispatchKeyEvent()` the characters of space, enter and tab, as the
242
+ DOM's key events have them, instead of empty ones (#2346).
243
+ - Fix `paper.support.nativeBlendModes`, which listed the blend modes canvas
244
+ accepted as `170` instead of `true`, and only knew the CSS blend modes where
245
+ a canvas was available when Paper.js loaded. It lists the canvas composite
246
+ modes and the CSS blend modes as native, and Paper.js's own modes as not,
247
+ without testing canvas (#2349).
248
+ - Hit-test strokes at segments where the curves meet in the same direction,
249
+ such as where a line runs into a curve, whatever the join, also across
250
+ curves without length, as in rectangles rounded to half their height.
251
+ - Calculate `Curve#getTimesWithTangent()`, `#length` and `Curve.getPeaks()`
252
+ precisely also far from the origin, from the curve's polynomial
253
+ coefficients, which take the differences of the points first.
254
+
3
255
  ## `0.14.0`
4
256
 
5
257
  ### Added
package/README.md CHANGED
@@ -350,7 +350,9 @@ As mentioned above, we prefer that you send a
350
350
  worry about the perfect name though -- you can change this name at any time
351
351
  later on.
352
352
 
353
- 4. Hack! Make your changes, additions, etc., commit them then push them to your
353
+ 4. Hack! Make your changes, additions, etc., and describe them for the
354
+ changelog in a file of their own in `changelog/unreleased`, see its
355
+ [README](changelog/unreleased/README.md). Commit them then push them to your
354
356
  GitHub fork: `git push origin name-of-my-patch`
355
357
 
356
358
  5. Send a pull request to the upstream repository's owner by visiting your