konva 10.9.0 → 10.10.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.
- package/README.md +22 -10
- package/konva.js +18996 -18838
- package/konva.min.js +50 -50
- package/lib/Animation.js +3 -3
- package/lib/Canvas.js +11 -3
- package/lib/Container.js +3 -3
- package/lib/Context.d.ts +2 -2
- package/lib/Context.js +17 -20
- package/lib/Core.js +2 -2
- package/lib/DragAndDrop.js +1 -1
- package/lib/Factory.js +2 -2
- package/lib/FastLayer.js +3 -3
- package/lib/Global.d.ts +0 -1
- package/lib/Global.js +13 -7
- package/lib/Group.js +5 -5
- package/lib/Layer.d.ts +1 -1
- package/lib/Layer.js +8 -8
- package/lib/Node.d.ts +2 -0
- package/lib/Node.js +76 -76
- package/lib/PointerEvents.js +1 -1
- package/lib/Shape.d.ts +5 -1
- package/lib/Shape.js +37 -43
- package/lib/Stage.js +8 -8
- package/lib/Tween.js +4 -4
- package/lib/Util.d.ts +67 -3
- package/lib/Util.js +124 -41
- package/lib/Validators.js +2 -2
- package/lib/_CoreInternals.d.ts +15 -11
- package/lib/_CoreInternals.js +16 -14
- package/lib/_FullInternals.d.ts +14 -10
- package/lib/_FullInternals.js +38 -38
- package/lib/canvas-backend.js +6 -15
- package/lib/filters/Blur.js +27 -3
- package/lib/filters/Brighten.js +3 -3
- package/lib/filters/Brightness.js +9 -3
- package/lib/filters/Contrast.js +9 -5
- package/lib/filters/Emboss.js +17 -9
- package/lib/filters/Enhance.js +3 -3
- package/lib/filters/HSL.js +3 -3
- package/lib/filters/HSV.js +3 -3
- package/lib/filters/Kaleidoscope.js +3 -3
- package/lib/filters/Mask.js +3 -3
- package/lib/filters/Noise.js +3 -3
- package/lib/filters/Pixelate.js +4 -4
- package/lib/filters/Posterize.js +3 -3
- package/lib/filters/RGB.js +3 -3
- package/lib/filters/RGBA.js +3 -3
- package/lib/filters/Threshold.js +3 -3
- package/lib/index.js +1 -1
- package/lib/napi-backend.d.ts +2 -0
- package/lib/napi-backend.js +15 -0
- package/lib/shapes/Arc.js +5 -5
- package/lib/shapes/Arrow.js +5 -5
- package/lib/shapes/Circle.js +4 -4
- package/lib/shapes/Ellipse.js +4 -4
- package/lib/shapes/Image.js +5 -5
- package/lib/shapes/Label.js +7 -7
- package/lib/shapes/Line.js +6 -6
- package/lib/shapes/Path.js +5 -5
- package/lib/shapes/Rect.js +5 -5
- package/lib/shapes/RegularPolygon.js +5 -5
- package/lib/shapes/Ring.js +4 -4
- package/lib/shapes/Sprite.js +5 -5
- package/lib/shapes/Star.js +4 -4
- package/lib/shapes/Text.d.ts +0 -1
- package/lib/shapes/Text.js +36 -34
- package/lib/shapes/TextPath.d.ts +3 -2
- package/lib/shapes/TextPath.js +71 -46
- package/lib/shapes/Transformer.js +12 -11
- package/lib/shapes/Wedge.js +5 -5
- package/lib/skia-backend.js +17 -25
- package/package.json +31 -34
package/README.md
CHANGED
|
@@ -128,20 +128,17 @@ import { Blur } from 'konva/lib/filters/Blur';
|
|
|
128
128
|
|
|
129
129
|
### 4 NodeJS env
|
|
130
130
|
|
|
131
|
-
In order to run `konva` in nodejs environment you also need to install `canvas` or
|
|
131
|
+
In order to run `konva` in nodejs environment you also need to install `canvas`, `skia-canvas` or `@napi-rs/canvas` package manually for rendering backend.
|
|
132
132
|
|
|
133
133
|
```bash
|
|
134
|
-
#
|
|
135
|
-
npm install konva canvas
|
|
136
|
-
# skia-canvas backend
|
|
137
|
-
npm install konva skia-canvas
|
|
134
|
+
npm install konva canvas # or skia-canvas, or @napi-rs/canvas
|
|
138
135
|
```
|
|
139
136
|
|
|
140
137
|
Use the same scene graph API for server-side rendering and omit the stage's `container` attribute. DOM events require a browser, and canvas feature support depends on the selected backend.
|
|
141
138
|
|
|
142
139
|
```js
|
|
143
140
|
import Konva from 'konva';
|
|
144
|
-
import 'konva/canvas-backend'; // or
|
|
141
|
+
import 'konva/canvas-backend'; // or 'konva/skia-backend', or 'konva/napi-backend'
|
|
145
142
|
|
|
146
143
|
const stage = new Konva.Stage({
|
|
147
144
|
width: 500,
|
|
@@ -150,6 +147,25 @@ const stage = new Konva.Stage({
|
|
|
150
147
|
// Add shapes and export the stage with the usual Konva drawing API.
|
|
151
148
|
```
|
|
152
149
|
|
|
150
|
+
A backend module also sets the global `DOMMatrix` and `Path2D`. To leave globals alone, or to use another canvas library, pass it to `Konva.setCanvasBackend()`. `Konva.getCanvasBackend()` returns the name of the active one, or `null` before one is set:
|
|
151
|
+
|
|
152
|
+
```js
|
|
153
|
+
import { Canvas, Image, Path2D } from '@napi-rs/canvas';
|
|
154
|
+
|
|
155
|
+
Konva.setCanvasBackend({
|
|
156
|
+
name: 'my-canvas',
|
|
157
|
+
createCanvas: () => new Canvas(300, 150),
|
|
158
|
+
createImage: () => new Image(), // optional, to load images
|
|
159
|
+
createPath2D: (path) => new Path2D(path), // optional, for Konva.Util.createPath2D()
|
|
160
|
+
});
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Create stages and nodes again after the call: ones created before keep the canvases, gradients and patterns of the old library.
|
|
164
|
+
|
|
165
|
+
### 5 Web Worker
|
|
166
|
+
|
|
167
|
+
Konva draws on `OffscreenCanvas` in a Web Worker without setup. Export with `toBlob()`, since `toDataURL()` is not available there, and pass images as `ImageBitmap`. DOM events do not reach a worker; forward them from the page.
|
|
168
|
+
|
|
153
169
|
# Backers
|
|
154
170
|
|
|
155
171
|
Konva is maintained by the team behind [Polotno](https://polotno.com/?utm_source=konvajs&utm_medium=readme&utm_content=konva-backers), a commercial design editor SDK built on Konva, which sponsors ongoing development.
|
|
@@ -178,10 +194,6 @@ Konva uses Mocha for testing.
|
|
|
178
194
|
Konva is covered with hundreds of tests and well over a thousand assertions.
|
|
179
195
|
For each feature or bug fix, write a failing test first, implement the behavior, then verify that the test passes (test-driven development).
|
|
180
196
|
|
|
181
|
-
## Generate documentation
|
|
182
|
-
|
|
183
|
-
Run `npm run build`, then `npx gulp api` to generate documentation from the current bundle in the `api` folder.
|
|
184
|
-
|
|
185
197
|
# Pull Requests
|
|
186
198
|
|
|
187
199
|
I'd be happy to review any pull requests that may better the Konva project,
|