skia-canvas 0.9.25 → 0.9.29
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.
- package/CHANGELOG.md +216 -0
- package/README.md +186 -97
- package/lib/index.d.ts +234 -0
- package/lib/index.js +82 -36
- package/package.json +15 -10
- package/Makefile +0 -60
- package/src/canvas.rs +0 -417
- package/src/context/api.rs +0 -1056
- package/src/context/mod.rs +0 -830
- package/src/gradient.rs +0 -174
- package/src/image.rs +0 -99
- package/src/lib.rs +0 -219
- package/src/path.rs +0 -520
- package/src/pattern.rs +0 -130
- package/src/texture.rs +0 -124
- package/src/typography.rs +0 -624
- package/src/utils.rs +0 -701
- package/test/assets/AmstelvarAlpha-VF.ttf +0 -0
- package/test/assets/blend-bg.png +0 -0
- package/test/assets/blend-fg.png +0 -0
- package/test/assets/checkers.png +0 -0
- package/test/assets/globe.jpg +0 -0
- package/test/assets/grayscale.jpg +0 -0
- package/test/assets/halved-1.jpeg +0 -0
- package/test/assets/halved-2.jpeg +0 -0
- package/test/assets/image/format.bmp +0 -0
- package/test/assets/image/format.gif +0 -0
- package/test/assets/image/format.ico +0 -0
- package/test/assets/image/format.jpg +0 -0
- package/test/assets/image/format.pdf +5 -1322
- package/test/assets/image/format.png +0 -0
- package/test/assets/path/effect-interpolate@2x.png +0 -0
- package/test/assets/path/effect-jitter@2x.png +0 -0
- package/test/assets/path/effect-points@2x.png +0 -0
- package/test/assets/path/effect-round@2x.png +0 -0
- package/test/assets/path/effect-simplify@2x.png +0 -0
- package/test/assets/path/effect-trim@2x.png +0 -0
- package/test/assets/path/effect-unwind@2x.png +0 -0
- package/test/assets/path/lineDashMarker@2x.png +0 -0
- package/test/assets/path/operation-none.svg +0 -6
- package/test/assets/path/operations@2x.png +0 -0
- package/test/assets/path/outlineText@2x.png +0 -0
- package/test/assets/pentagon-cmyk.jpg +0 -0
- package/test/assets/pentagon-grayscale.jpg +0 -0
- package/test/assets/pentagon.png +0 -0
- package/test/assets/quadrants.png +0 -0
- package/test/assets/star.png +0 -0
- package/test/assets/state.png +0 -0
- package/test/canvas.test.js +0 -490
- package/test/context2d.test.js +0 -747
- package/test/media.test.js +0 -204
- package/test/path2d.test.js +0 -614
- package/test/visual/index.html +0 -193
- package/test/visual/index.js +0 -68
- package/test/visual/tests.js +0 -2669
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
<!-- ## 🥚 ⟩ [Unreleased] -->
|
|
4
|
+
|
|
5
|
+
## 📦 ⟩ [v0.9.29] ⟩ Feb 7, 2022
|
|
6
|
+
|
|
7
|
+
### New Features
|
|
8
|
+
- PDF exports now support the optional [`matte`][matte] argument.
|
|
9
|
+
|
|
10
|
+
### Breaking Changes
|
|
11
|
+
- When the [`drawImage()`][mdn_drawImage] function is passed a **Canvas** object as its image source it will now rasterize the canvas before drawing. The prior behavior (in which it is drawn as a vector graphic) can now be accessed through the new [`drawCanvas()`][drawCanvas] method which supports the same numerical arguments as `drawImage` but requires that its first argument be a **Canvas**.
|
|
12
|
+
|
|
13
|
+
### Bugfixes
|
|
14
|
+
- Regions erased using [`clearRect()`][mdn_clearRect] are now properly antialiased
|
|
15
|
+
- The [`clip()`][mdn_clip] method now interprets the current translate/scale/rotate state correctly when combining clipping masks
|
|
16
|
+
|
|
17
|
+
### Misc. Improvements
|
|
18
|
+
- Upgraded Skia to milestone 97
|
|
19
|
+
|
|
20
|
+
[drawCanvas]: https://github.com/samizdatco/skia-canvas#drawcanvascanvas-x-y-
|
|
21
|
+
[mdn_clip]: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/clip
|
|
22
|
+
[mdn_clearRect]: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/clearRect
|
|
23
|
+
|
|
24
|
+
## 📦 ⟩ [v0.9.28] ⟩ Jan 12, 2022
|
|
25
|
+
|
|
26
|
+
### New Features
|
|
27
|
+
- Added TypeScript definitions for extensions to the DOM spec (contributed by [@cprecioso](https://github.com/cprecioso))
|
|
28
|
+
- Added 3D-perspective transformations via the new [createProjection()](https://github.com/samizdatco/skia-canvas#createprojectionquad-basis) context method
|
|
29
|
+
- Colors can now use the [hwb()](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/hwb()) model
|
|
30
|
+
|
|
31
|
+
### Breaking Changes
|
|
32
|
+
- The **Canvas** [`.async`](https://github.com/samizdatco/skia-canvas#async) property has been **deprecated** and will be removed in a future release.
|
|
33
|
+
- The `saveAs`, `toBuffer`, and `toDataURL` methods will now be async-only (likewise the [shorthand properties](https://github.com/samizdatco/skia-canvas#pdf-svg-jpg-and-png)).
|
|
34
|
+
- Use their synchronous counterparts (`saveAsSync`, `toBufferSync`, and `toDataURLSync`) if you want to block execution while exporting images.
|
|
35
|
+
- The [ImageData](https://developer.mozilla.org/en-US/docs/Web/API/ImageData/ImageData) constructor now orders its arguments properly: the optional buffer/array argument now comes first
|
|
36
|
+
|
|
37
|
+
### Bugfixes
|
|
38
|
+
- Fixed a stack overflow that was occurring when images became too deeply nested for the default deallocator to handle (primarily due to many thousands of image exports from the same canvas)
|
|
39
|
+
- The `source-in`, `source-out`, `destination-atop`, and `copy` composite operations now work correctly for paths rather than rendering shapes without color (contributed by [@meihuanyu](https://github.com/meihuanyu))
|
|
40
|
+
- Shape primitives now behave consistently with browsers when being added to a non-empty path:
|
|
41
|
+
- `rect()` now issues an initial `moveTo` rather than extending the path, then leaves the ‘current’ point in its upper left corner
|
|
42
|
+
- `ellipse()` extends the current path rather than implicitly closing it (contributed by [@meihuanyu](https://github.com/meihuanyu))
|
|
43
|
+
- `arc()` also extends the current path rather than closing it
|
|
44
|
+
|
|
45
|
+
### Misc. Improvements
|
|
46
|
+
- Upgraded Skia to milestone 96
|
|
47
|
+
- Added workflow for creating docker build environments
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
## 📦 ⟩ [v0.9.27] ⟩ Oct 23, 2021
|
|
51
|
+
|
|
52
|
+
### New Features
|
|
53
|
+
- Added pre-compiled binaries for Alpine Linux using the [musl](https://musl.libc.org) C library
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
## 📦 ⟩ [v0.9.26] ⟩ Oct 18, 2021
|
|
57
|
+
|
|
58
|
+
### New Features
|
|
59
|
+
- Added pre-compiled binaries for 32-bit and 64-bit ARM on Linux (a.k.a. Raspberry Pi)
|
|
60
|
+
|
|
61
|
+
### Bugfixes
|
|
62
|
+
- Windows text rendering has been restored after failing due to changes involving the `icudtl.dat` file
|
|
63
|
+
- `FontLibrary.use` now reports an error if the specified font file doesn't exist
|
|
64
|
+
- Fixed a crash that could result from calling `measureText` with various unicode escapes
|
|
65
|
+
|
|
66
|
+
### Misc. Improvements
|
|
67
|
+
- Upgraded Skia to milestone 94
|
|
68
|
+
- Now embedding a more recent version of the FreeType library on Linux with support for more font formats
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
## 📦 ⟩ [v0.9.25] ⟩ Aug 22, 2021
|
|
72
|
+
|
|
73
|
+
### Bugfixes
|
|
74
|
+
- Improved image scaling when a larger image is being shrunk down to a smaller size via [`drawImage()`][mdn_drawImage]
|
|
75
|
+
- modified [`imageSmoothingQuality`](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/imageSmoothingQuality) settings to provide a more meaningful range across `low`, `medium`, and `high`
|
|
76
|
+
- [`measureText()`](https://github.com/samizdatco/skia-canvas#measuretextstr-width) now returns correct metrics regardless of current `textAlign` setting
|
|
77
|
+
- Rolled back `icudtl.dat` changes on Windows (which suppressed the misleading warning message but required running as Administrator)
|
|
78
|
+
|
|
79
|
+
### Misc. Improvements
|
|
80
|
+
- Now using [Neon](https://github.com/neon-bindings/neon) v0.9 (with enhanced async event scheduling)
|
|
81
|
+
|
|
82
|
+
[mdn_drawImage]: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/drawImage
|
|
83
|
+
|
|
84
|
+
## 📦 ⟩ [v0.9.24] ⟩ Aug 18, 2021
|
|
85
|
+
|
|
86
|
+
### New Features
|
|
87
|
+
- **Path2D** objects now have a read/write [`d`](https://github.com/samizdatco/skia-canvas/#d) property with an [SVG representation](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#path_commands) of the path’s contours and an [`unwind()`](https://github.com/samizdatco/skia-canvas/#unwind) method for converting from even-odd to non-zero winding rules
|
|
88
|
+
- The [`createTexture()`](https://github.com/samizdatco/skia-canvas#createtexturespacing-path-line-color-angle-offset0) context method returns **CanvasTexture** objects which can be assigned to `fillStyle` or `strokeStyle`
|
|
89
|
+
- Textures draw either a parallel-lines pattern or one derived from the provided **Path2D** object and positioning parameters
|
|
90
|
+
- The marker used when `setLineDash` is active can now be customized by assigning a **Path2D** to the context’s [`lineDashMarker`](https://github.com/samizdatco/skia-canvas#linedashmarker) property (default dashing can be restored by assigning `null`)
|
|
91
|
+
- The marker’s orientation & shape relative to the path being stroked can be controlled by the [`lineDashFit`](https://github.com/samizdatco/skia-canvas#linedashfit) property which defaults to `"turn"` but can be set to `"move"` (which preserves orientation) or `"follow"` (which distorts the marker’s shape to match the contour)
|
|
92
|
+
|
|
93
|
+
### Bugfixes
|
|
94
|
+
|
|
95
|
+
- Removed use of the `??` operator which is unavailable prior to Node 14
|
|
96
|
+
- Prevented a spurious warning on windows incorrectly claiming that the `icudtl.dat` file could not be found
|
|
97
|
+
|
|
98
|
+
### Misc. Improvements
|
|
99
|
+
|
|
100
|
+
- The **Path2D** [`simplify()`](https://github.com/samizdatco/skia-canvas/#simplifyrulenonzero) method now takes an optional fill-rule argument
|
|
101
|
+
- Added support for versions of macOS starting with 10.13 (High Sierra)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
## 📦 ⟩ [v0.9.23] ⟩ Jul 12, 2021
|
|
105
|
+
|
|
106
|
+
### New Features
|
|
107
|
+
|
|
108
|
+
- [Conic béziers][conic_bezier] can now be drawn to the context or a Path2D with the [`conicCurveTo()`][conic_curveto] method
|
|
109
|
+
- Text can be converted to a Path2D using the context’s new [`outlineText()`][outline_text] method
|
|
110
|
+
- Path2D objects can now report back on their internal geometry with:
|
|
111
|
+
- the [`edges`][edges] property which contains an array of line-drawing commands describing the path’s individual contours
|
|
112
|
+
- the [`contains()`][contains] method which tests whether a given point is on/within the path
|
|
113
|
+
- the [`points()`][points] method which returns an array of `[x, y]` pairs at the requested spacing along the curve’s periphery
|
|
114
|
+
- A modified copy of a source Path2D can now be created using:
|
|
115
|
+
- [`offset()`][offset] or [`transform()`][transform] to shift position or apply a DOMMatrix respectively
|
|
116
|
+
- [`jitter()`][jitter] to break the path into smaller sections and apply random noise to the segments’ positions
|
|
117
|
+
- [`round()`][round] to round off every sharp corner in a path to a particular radius
|
|
118
|
+
- [`trim()`][trim] to select a percentage-based subsection of the path
|
|
119
|
+
- Two similar paths can be ‘tweened’ into a proportional combination of their coordinates using the [`interpolate()`][interpolate] method
|
|
120
|
+
|
|
121
|
+
### Bugfixes
|
|
122
|
+
|
|
123
|
+
- Passing a Path2D argument to the `fill()` or `stroke()` method no longer disturbs the context’s ‘current’ path (if one has been created using `beginPath()`)
|
|
124
|
+
- The `filter` property will now accept percentage values greater than 999%
|
|
125
|
+
|
|
126
|
+
### Misc. Improvements
|
|
127
|
+
|
|
128
|
+
- The `newPage()` and `saveAs()` methods now work in the browser, including the ability to save image sequences to a zip archive. The browser’s canvas is still doing all the drawing however, so file export formats will be limited to PNG and JPEG and none of the other Skia-specific extensions will be available.
|
|
129
|
+
- The file-export methods now accept a [`matte`][matte] value in their options object which can be used to set the background color for any portions of the canvas that were left semi-transparent
|
|
130
|
+
- Canvas dimensions are no longer rounded-off to integer values (at least until a bitmap needs to be generated for export)
|
|
131
|
+
- Linux builds will now run on some older systems going back to glibc 2.24
|
|
132
|
+
|
|
133
|
+
[conic_bezier]: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/graphics/skiasharp/curves/beziers#the-conic-bézier-curve
|
|
134
|
+
[conic_curveto]: https://github.com/samizdatco/skia-canvas#coniccurvetocpx-cpy-x-y-weight
|
|
135
|
+
[outline_text]: https://github.com/samizdatco/skia-canvas#outlinetextstr
|
|
136
|
+
[matte]: https://github.com/samizdatco/skia-canvas#matte
|
|
137
|
+
|
|
138
|
+
[edges]: https://github.com/samizdatco/skia-canvas#edges
|
|
139
|
+
[contains]: https://github.com/samizdatco/skia-canvas#containsx-y
|
|
140
|
+
[points]: https://github.com/samizdatco/skia-canvas#pointsstep1
|
|
141
|
+
[offset]: https://github.com/samizdatco/skia-canvas#offsetdx-dy
|
|
142
|
+
[transform]: https://github.com/samizdatco/skia-canvas#transformmatrix-or-transforma-b-c-d-e-f
|
|
143
|
+
|
|
144
|
+
[interpolate]: https://github.com/samizdatco/skia-canvas#interpolateotherpath-weight
|
|
145
|
+
[jitter]: https://github.com/samizdatco/skia-canvas#jittersegmentlength-amount-seed0
|
|
146
|
+
[round]: https://github.com/samizdatco/skia-canvas#roundradius
|
|
147
|
+
[simplify]: https://github.com/samizdatco/skia-canvas#simplify
|
|
148
|
+
[trim]: https://github.com/samizdatco/skia-canvas#trimstart-end-inverted
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
## 📦 ⟩ [v0.9.22] ⟩ Jun 09, 2021
|
|
152
|
+
|
|
153
|
+
### New Features
|
|
154
|
+
|
|
155
|
+
- Rasterization and file i/o are now handled asynchronously in a background thread. See the discussion of Canvas’s new [`async`](https://github.com/samizdatco/skia-canvas#async) property for details.
|
|
156
|
+
- Output files can now be generated at pixel-ratios > 1 for High-DPI screens. `SaveAs` and the other canvas output functions all accept an optional [`density`](https://github.com/samizdatco/skia-canvas#density) argument which is an integer ≥1 and will upscale the image accordingly. The density can also be passed using the `filename` argument by ending the name with an ‘@’ suffix like `some-image@2x.png`.
|
|
157
|
+
- SVG exports can optionally convert text to paths by setting the [`outline`](https://github.com/samizdatco/skia-canvas#outline) argument to `true`.
|
|
158
|
+
|
|
159
|
+
### Breaking Changes
|
|
160
|
+
|
|
161
|
+
- The canvas functions dealing with rasterization (`toBuffer`, `toDataURL`, `png`, `jpg`, `pdf`, and `svg`) and file i/o (`saveAs`) are now asynchronous and return `Promise` objects. The old, synchronous behavior is still available on a canvas-by-canvas basis by setting its `async` property to `false`.
|
|
162
|
+
- The optional `quality` argument accepted by the output methods is now a float in the range 0–1 rather than an integer from 0–100. This is consistent with the [encoderOptions](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL) arg in the spec. Quality now defaults to 0.92 (again, as per the spec) rather than lossless.
|
|
163
|
+
|
|
164
|
+
### Bugfixes
|
|
165
|
+
|
|
166
|
+
- `measureText` was reporting zero when asked to measure a string that was entirely made of whitespace. This is still the case for ‘blank‘ lines when `textWrap` is set to `true` but in the default, single-line mode the metrics will now report the width of the whitespace.
|
|
167
|
+
- Changed the way text rendering was staged so that SVG exports didn’t *entirely omit(!)* text from their output. As a result, `Context2D`s now use an external `Typesetter` struct to manage layout and rendering.
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
## 📦 ⟩ [v0.9.21] ⟩ May 22, 2021
|
|
171
|
+
|
|
172
|
+
### New Features
|
|
173
|
+
- Now runs on Windows and Apple Silicon Macs.
|
|
174
|
+
- Precompiled binaries support Node 10, 12, 14+.
|
|
175
|
+
- Image objects can be initialized from PNG, JPEG, GIF, BMP, or ICO data.
|
|
176
|
+
- Path2D objects can now be combined using [boolean operators](https://github.com/samizdatco/skia-canvas/#complement-difference-intersect-union-and-xor) and can measure their own [bounding boxes](https://github.com/samizdatco/skia-canvas/#bounds).
|
|
177
|
+
- Context objects now support [`createConicGradient()`](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/createConicGradient).
|
|
178
|
+
- Image objects now return a promise from their [`decode()`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/decode) method allowing for async loading without the [`loadImage`](https://github.com/samizdatco/skia-canvas/#loadimage) helper.
|
|
179
|
+
|
|
180
|
+
### Bugfixes
|
|
181
|
+
- Calling `drawImage` with a `Canvas` object as the argument now uses a Skia `Pict` rather than a `Drawable` as the interchange format, meaning it can actually respect the canvas's current `globalAlpha` and `globalCompositeOperation` state (fixed #6).
|
|
182
|
+
- Improved some spurious error messages when trying to generate a graphics file from a canvas whose width and/or height was set to zero (fixed #5).
|
|
183
|
+
- `CanvasPattern`s now respect the `imageSmoothingEnabled` setting
|
|
184
|
+
- The `counterclockwise` arg to `ellipse` and `arc` is now correctly treated as optional.
|
|
185
|
+
|
|
186
|
+
### Misc. Improvements
|
|
187
|
+
- Made the `console.log` representations of the canvas-related objects friendlier.
|
|
188
|
+
- Added new test suites for `Path2D`, `Image`, and `Canvas`’s format support.
|
|
189
|
+
- Created [workflows](https://github.com/samizdatco/skia-canvas/tree/master/.github/workflows) to automate precompiled binary builds, testing, and npm package updating.
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
## 📦 ⟩ [v0.9.20] ⟩ Mar 27, 2021
|
|
193
|
+
|
|
194
|
+
### Bugfixes
|
|
195
|
+
- The `loadImage` helper can now handle `Buffer` arguments
|
|
196
|
+
|
|
197
|
+
### Misc. Improvements
|
|
198
|
+
- Improved documentation of compilation steps and use of line height with `ctx.font`
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
## 📦 ⟩ [v0.9.19] ⟩ Aug 30, 2020
|
|
202
|
+
|
|
203
|
+
**Initial public release** 🎉
|
|
204
|
+
|
|
205
|
+
[unreleased]: https://github.com/samizdatco/skia-canvas/compare/v0.9.29...HEAD
|
|
206
|
+
[v0.9.29]: https://github.com/samizdatco/skia-canvas/compare/v0.9.28...v0.9.29
|
|
207
|
+
[v0.9.28]: https://github.com/samizdatco/skia-canvas/compare/v0.9.27...v0.9.28
|
|
208
|
+
[v0.9.27]: https://github.com/samizdatco/skia-canvas/compare/v0.9.26...v0.9.27
|
|
209
|
+
[v0.9.26]: https://github.com/samizdatco/skia-canvas/compare/v0.9.25...v0.9.26
|
|
210
|
+
[v0.9.25]: https://github.com/samizdatco/skia-canvas/compare/v0.9.24...v0.9.25
|
|
211
|
+
[v0.9.24]: https://github.com/samizdatco/skia-canvas/compare/v0.9.23...v0.9.24
|
|
212
|
+
[v0.9.23]: https://github.com/samizdatco/skia-canvas/compare/v0.9.22...v0.9.23
|
|
213
|
+
[v0.9.22]: https://github.com/samizdatco/skia-canvas/compare/v0.9.21...v0.9.22
|
|
214
|
+
[v0.9.21]: https://github.com/samizdatco/skia-canvas/compare/v0.9.20...v0.9.21
|
|
215
|
+
[v0.9.20]: https://github.com/samizdatco/skia-canvas/compare/v0.9.19...v0.9.20
|
|
216
|
+
[v0.9.19]: https://github.com/samizdatco/skia-canvas/compare/v0.9.15...v0.9.19
|