konva 10.0.9 → 10.0.10
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/konva.js +90 -44
- package/konva.min.js +4 -4
- package/package.json +1 -1
- package/lib/Animation.d.ts +0 -24
- package/lib/Animation.js +0 -142
- package/lib/BezierFunctions.d.ts +0 -6
- package/lib/BezierFunctions.js +0 -784
- package/lib/Canvas.d.ts +0 -33
- package/lib/Canvas.js +0 -137
- package/lib/Container.d.ts +0 -54
- package/lib/Container.js +0 -316
- package/lib/Context.d.ts +0 -95
- package/lib/Context.js +0 -561
- package/lib/Core.d.ts +0 -3
- package/lib/Core.js +0 -3
- package/lib/DragAndDrop.d.ts +0 -17
- package/lib/DragAndDrop.js +0 -110
- package/lib/Factory.d.ts +0 -22
- package/lib/Factory.js +0 -123
- package/lib/FastLayer.d.ts +0 -4
- package/lib/FastLayer.js +0 -12
- package/lib/Global.d.ts +0 -37
- package/lib/Global.js +0 -66
- package/lib/Group.d.ts +0 -9
- package/lib/Group.js +0 -13
- package/lib/Layer.d.ts +0 -62
- package/lib/Layer.js +0 -305
- package/lib/Node.d.ts +0 -323
- package/lib/Node.js +0 -1532
- package/lib/PointerEvents.d.ts +0 -11
- package/lib/PointerEvents.js +0 -37
- package/lib/Shape.d.ts +0 -196
- package/lib/Shape.js +0 -548
- package/lib/Stage.d.ts +0 -86
- package/lib/Stage.js +0 -715
- package/lib/Tween.d.ts +0 -90
- package/lib/Tween.js +0 -531
- package/lib/Util.d.ts +0 -133
- package/lib/Util.js +0 -866
- package/lib/Validators.d.ts +0 -11
- package/lib/Validators.js +0 -178
- package/lib/_CoreInternals.d.ts +0 -220
- package/lib/_CoreInternals.js +0 -34
- package/lib/_FullInternals.d.ts +0 -302
- package/lib/_FullInternals.js +0 -80
- package/lib/canvas-backend.d.ts +0 -2
- package/lib/canvas-backend.js +0 -27
- package/lib/filters/Blur.d.ts +0 -2
- package/lib/filters/Blur.js +0 -235
- package/lib/filters/Brighten.d.ts +0 -2
- package/lib/filters/Brighten.js +0 -12
- package/lib/filters/Brightness.d.ts +0 -2
- package/lib/filters/Brightness.js +0 -8
- package/lib/filters/Contrast.d.ts +0 -2
- package/lib/filters/Contrast.js +0 -35
- package/lib/filters/Emboss.d.ts +0 -2
- package/lib/filters/Emboss.js +0 -101
- package/lib/filters/Enhance.d.ts +0 -2
- package/lib/filters/Enhance.js +0 -84
- package/lib/filters/Grayscale.d.ts +0 -2
- package/lib/filters/Grayscale.js +0 -9
- package/lib/filters/HSL.d.ts +0 -2
- package/lib/filters/HSL.js +0 -24
- package/lib/filters/HSV.d.ts +0 -2
- package/lib/filters/HSV.js +0 -23
- package/lib/filters/Invert.d.ts +0 -2
- package/lib/filters/Invert.js +0 -8
- package/lib/filters/Kaleidoscope.d.ts +0 -2
- package/lib/filters/Kaleidoscope.js +0 -133
- package/lib/filters/Mask.d.ts +0 -2
- package/lib/filters/Mask.js +0 -151
- package/lib/filters/Noise.d.ts +0 -2
- package/lib/filters/Noise.js +0 -12
- package/lib/filters/Pixelate.d.ts +0 -2
- package/lib/filters/Pixelate.js +0 -60
- package/lib/filters/Posterize.d.ts +0 -2
- package/lib/filters/Posterize.js +0 -10
- package/lib/filters/RGB.d.ts +0 -2
- package/lib/filters/RGB.js +0 -38
- package/lib/filters/RGBA.d.ts +0 -2
- package/lib/filters/RGBA.js +0 -49
- package/lib/filters/Sepia.d.ts +0 -2
- package/lib/filters/Sepia.js +0 -11
- package/lib/filters/Solarize.d.ts +0 -2
- package/lib/filters/Solarize.js +0 -14
- package/lib/filters/Threshold.d.ts +0 -2
- package/lib/filters/Threshold.js +0 -10
- package/lib/index.d.ts +0 -2
- package/lib/index.js +0 -2
- package/lib/shapes/Arc.d.ts +0 -27
- package/lib/shapes/Arc.js +0 -60
- package/lib/shapes/Arrow.d.ts +0 -27
- package/lib/shapes/Arrow.js +0 -99
- package/lib/shapes/Circle.d.ts +0 -15
- package/lib/shapes/Circle.js +0 -33
- package/lib/shapes/Ellipse.d.ts +0 -18
- package/lib/shapes/Ellipse.js +0 -37
- package/lib/shapes/Image.d.ts +0 -29
- package/lib/shapes/Image.js +0 -131
- package/lib/shapes/Label.d.ts +0 -39
- package/lib/shapes/Label.js +0 -173
- package/lib/shapes/Line.d.ts +0 -29
- package/lib/shapes/Line.js +0 -156
- package/lib/shapes/Path.d.ts +0 -50
- package/lib/shapes/Path.js +0 -670
- package/lib/shapes/Rect.d.ts +0 -11
- package/lib/shapes/Rect.js +0 -22
- package/lib/shapes/RegularPolygon.d.ts +0 -26
- package/lib/shapes/RegularPolygon.js +0 -72
- package/lib/shapes/Ring.d.ts +0 -17
- package/lib/shapes/Ring.js +0 -33
- package/lib/shapes/Sprite.d.ts +0 -32
- package/lib/shapes/Sprite.js +0 -108
- package/lib/shapes/Star.d.ts +0 -19
- package/lib/shapes/Star.js +0 -38
- package/lib/shapes/Text.d.ts +0 -90
- package/lib/shapes/Text.js +0 -461
- package/lib/shapes/TextPath.d.ts +0 -72
- package/lib/shapes/TextPath.js +0 -268
- package/lib/shapes/Transformer.d.ts +0 -130
- package/lib/shapes/Transformer.js +0 -1009
- package/lib/shapes/Wedge.d.ts +0 -19
- package/lib/shapes/Wedge.js +0 -38
- package/lib/skia-backend.d.ts +0 -2
- package/lib/skia-backend.js +0 -24
- package/lib/types.d.ts +0 -56
- package/lib/types.js +0 -21
package/lib/shapes/Rect.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Factory } from "../Factory.js";
|
|
2
|
-
import { Shape } from "../Shape.js";
|
|
3
|
-
import { _registerNode } from "../Global.js";
|
|
4
|
-
import { Util } from "../Util.js";
|
|
5
|
-
import { getNumberOrArrayOfNumbersValidator } from "../Validators.js";
|
|
6
|
-
export class Rect extends Shape {
|
|
7
|
-
_sceneFunc(context) {
|
|
8
|
-
const cornerRadius = this.cornerRadius(), width = this.width(), height = this.height();
|
|
9
|
-
context.beginPath();
|
|
10
|
-
if (!cornerRadius) {
|
|
11
|
-
context.rect(0, 0, width, height);
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
Util.drawRoundedRectPath(context, width, height, cornerRadius);
|
|
15
|
-
}
|
|
16
|
-
context.closePath();
|
|
17
|
-
context.fillStrokeShape(this);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
Rect.prototype.className = 'Rect';
|
|
21
|
-
_registerNode(Rect);
|
|
22
|
-
Factory.addGetterSetter(Rect, 'cornerRadius', 0, getNumberOrArrayOfNumbersValidator(4));
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { ShapeConfig } from '../Shape.ts';
|
|
2
|
-
import { Shape } from '../Shape.ts';
|
|
3
|
-
import type { GetSet, Vector2d } from '../types.ts';
|
|
4
|
-
import type { Context } from '../Context.ts';
|
|
5
|
-
export interface RegularPolygonConfig extends ShapeConfig {
|
|
6
|
-
sides: number;
|
|
7
|
-
radius: number;
|
|
8
|
-
cornerRadius?: number | number[];
|
|
9
|
-
}
|
|
10
|
-
export declare class RegularPolygon extends Shape<RegularPolygonConfig> {
|
|
11
|
-
_sceneFunc(context: Context): void;
|
|
12
|
-
_getPoints(): Vector2d[];
|
|
13
|
-
getSelfRect(): {
|
|
14
|
-
x: number;
|
|
15
|
-
y: number;
|
|
16
|
-
width: number;
|
|
17
|
-
height: number;
|
|
18
|
-
};
|
|
19
|
-
getWidth(): number;
|
|
20
|
-
getHeight(): number;
|
|
21
|
-
setWidth(width: number): void;
|
|
22
|
-
setHeight(height: number): void;
|
|
23
|
-
radius: GetSet<number, this>;
|
|
24
|
-
sides: GetSet<number, this>;
|
|
25
|
-
cornerRadius: GetSet<number | number[], this>;
|
|
26
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { Factory } from "../Factory.js";
|
|
2
|
-
import { Shape } from "../Shape.js";
|
|
3
|
-
import { getNumberOrArrayOfNumbersValidator, getNumberValidator, } from "../Validators.js";
|
|
4
|
-
import { _registerNode } from "../Global.js";
|
|
5
|
-
import { Util } from "../Util.js";
|
|
6
|
-
export class RegularPolygon extends Shape {
|
|
7
|
-
_sceneFunc(context) {
|
|
8
|
-
const points = this._getPoints(), radius = this.radius(), sides = this.sides(), cornerRadius = this.cornerRadius();
|
|
9
|
-
context.beginPath();
|
|
10
|
-
if (!cornerRadius) {
|
|
11
|
-
context.moveTo(points[0].x, points[0].y);
|
|
12
|
-
for (let n = 1; n < points.length; n++) {
|
|
13
|
-
context.lineTo(points[n].x, points[n].y);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
Util.drawRoundedPolygonPath(context, points, sides, radius, cornerRadius);
|
|
18
|
-
}
|
|
19
|
-
context.closePath();
|
|
20
|
-
context.fillStrokeShape(this);
|
|
21
|
-
}
|
|
22
|
-
_getPoints() {
|
|
23
|
-
const sides = this.attrs.sides;
|
|
24
|
-
const radius = this.attrs.radius || 0;
|
|
25
|
-
const points = [];
|
|
26
|
-
for (let n = 0; n < sides; n++) {
|
|
27
|
-
points.push({
|
|
28
|
-
x: radius * Math.sin((n * 2 * Math.PI) / sides),
|
|
29
|
-
y: -1 * radius * Math.cos((n * 2 * Math.PI) / sides),
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
return points;
|
|
33
|
-
}
|
|
34
|
-
getSelfRect() {
|
|
35
|
-
const points = this._getPoints();
|
|
36
|
-
let minX = points[0].x;
|
|
37
|
-
let maxX = points[0].x;
|
|
38
|
-
let minY = points[0].y;
|
|
39
|
-
let maxY = points[0].y;
|
|
40
|
-
points.forEach((point) => {
|
|
41
|
-
minX = Math.min(minX, point.x);
|
|
42
|
-
maxX = Math.max(maxX, point.x);
|
|
43
|
-
minY = Math.min(minY, point.y);
|
|
44
|
-
maxY = Math.max(maxY, point.y);
|
|
45
|
-
});
|
|
46
|
-
return {
|
|
47
|
-
x: minX,
|
|
48
|
-
y: minY,
|
|
49
|
-
width: maxX - minX,
|
|
50
|
-
height: maxY - minY,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
getWidth() {
|
|
54
|
-
return this.radius() * 2;
|
|
55
|
-
}
|
|
56
|
-
getHeight() {
|
|
57
|
-
return this.radius() * 2;
|
|
58
|
-
}
|
|
59
|
-
setWidth(width) {
|
|
60
|
-
this.radius(width / 2);
|
|
61
|
-
}
|
|
62
|
-
setHeight(height) {
|
|
63
|
-
this.radius(height / 2);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
RegularPolygon.prototype.className = 'RegularPolygon';
|
|
67
|
-
RegularPolygon.prototype._centroid = true;
|
|
68
|
-
RegularPolygon.prototype._attrsAffectingSize = ['radius'];
|
|
69
|
-
_registerNode(RegularPolygon);
|
|
70
|
-
Factory.addGetterSetter(RegularPolygon, 'radius', 0, getNumberValidator());
|
|
71
|
-
Factory.addGetterSetter(RegularPolygon, 'sides', 0, getNumberValidator());
|
|
72
|
-
Factory.addGetterSetter(RegularPolygon, 'cornerRadius', 0, getNumberOrArrayOfNumbersValidator(4));
|
package/lib/shapes/Ring.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { ShapeConfig } from '../Shape.ts';
|
|
2
|
-
import { Shape } from '../Shape.ts';
|
|
3
|
-
import type { GetSet } from '../types.ts';
|
|
4
|
-
import type { Context } from '../Context.ts';
|
|
5
|
-
export interface RingConfig extends ShapeConfig {
|
|
6
|
-
innerRadius: number;
|
|
7
|
-
outerRadius: number;
|
|
8
|
-
}
|
|
9
|
-
export declare class Ring extends Shape<RingConfig> {
|
|
10
|
-
_sceneFunc(context: Context): void;
|
|
11
|
-
getWidth(): number;
|
|
12
|
-
getHeight(): number;
|
|
13
|
-
setWidth(width: number): void;
|
|
14
|
-
setHeight(height: number): void;
|
|
15
|
-
outerRadius: GetSet<number, this>;
|
|
16
|
-
innerRadius: GetSet<number, this>;
|
|
17
|
-
}
|
package/lib/shapes/Ring.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Factory } from "../Factory.js";
|
|
2
|
-
import { Shape } from "../Shape.js";
|
|
3
|
-
import { getNumberValidator } from "../Validators.js";
|
|
4
|
-
import { _registerNode } from "../Global.js";
|
|
5
|
-
const PIx2 = Math.PI * 2;
|
|
6
|
-
export class Ring extends Shape {
|
|
7
|
-
_sceneFunc(context) {
|
|
8
|
-
context.beginPath();
|
|
9
|
-
context.arc(0, 0, this.innerRadius(), 0, PIx2, false);
|
|
10
|
-
context.moveTo(this.outerRadius(), 0);
|
|
11
|
-
context.arc(0, 0, this.outerRadius(), PIx2, 0, true);
|
|
12
|
-
context.closePath();
|
|
13
|
-
context.fillStrokeShape(this);
|
|
14
|
-
}
|
|
15
|
-
getWidth() {
|
|
16
|
-
return this.outerRadius() * 2;
|
|
17
|
-
}
|
|
18
|
-
getHeight() {
|
|
19
|
-
return this.outerRadius() * 2;
|
|
20
|
-
}
|
|
21
|
-
setWidth(width) {
|
|
22
|
-
this.outerRadius(width / 2);
|
|
23
|
-
}
|
|
24
|
-
setHeight(height) {
|
|
25
|
-
this.outerRadius(height / 2);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
Ring.prototype.className = 'Ring';
|
|
29
|
-
Ring.prototype._centroid = true;
|
|
30
|
-
Ring.prototype._attrsAffectingSize = ['innerRadius', 'outerRadius'];
|
|
31
|
-
_registerNode(Ring);
|
|
32
|
-
Factory.addGetterSetter(Ring, 'innerRadius', 0, getNumberValidator());
|
|
33
|
-
Factory.addGetterSetter(Ring, 'outerRadius', 0, getNumberValidator());
|
package/lib/shapes/Sprite.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { Context } from '../Context.ts';
|
|
2
|
-
import type { ShapeConfig } from '../Shape.ts';
|
|
3
|
-
import { Shape } from '../Shape.ts';
|
|
4
|
-
import { Animation } from '../Animation.ts';
|
|
5
|
-
import type { GetSet } from '../types.ts';
|
|
6
|
-
export interface SpriteConfig extends ShapeConfig {
|
|
7
|
-
animation: string;
|
|
8
|
-
animations: any;
|
|
9
|
-
frameIndex?: number;
|
|
10
|
-
image: HTMLImageElement;
|
|
11
|
-
frameRate?: number;
|
|
12
|
-
}
|
|
13
|
-
export declare class Sprite extends Shape<SpriteConfig> {
|
|
14
|
-
_updated: boolean;
|
|
15
|
-
anim: Animation;
|
|
16
|
-
interval: any;
|
|
17
|
-
constructor(config: SpriteConfig);
|
|
18
|
-
_sceneFunc(context: Context): void;
|
|
19
|
-
_hitFunc(context: Context): void;
|
|
20
|
-
_useBufferCanvas(): boolean;
|
|
21
|
-
_setInterval(): void;
|
|
22
|
-
start(): void;
|
|
23
|
-
stop(): void;
|
|
24
|
-
isRunning(): boolean;
|
|
25
|
-
_updateIndex(): void;
|
|
26
|
-
frameIndex: GetSet<number, this>;
|
|
27
|
-
animation: GetSet<string, this>;
|
|
28
|
-
image: GetSet<CanvasImageSource, this>;
|
|
29
|
-
animations: GetSet<any, this>;
|
|
30
|
-
frameOffsets: GetSet<any, this>;
|
|
31
|
-
frameRate: GetSet<number, this>;
|
|
32
|
-
}
|
package/lib/shapes/Sprite.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { Factory } from "../Factory.js";
|
|
2
|
-
import { Shape } from "../Shape.js";
|
|
3
|
-
import { Animation } from "../Animation.js";
|
|
4
|
-
import { getNumberValidator } from "../Validators.js";
|
|
5
|
-
import { _registerNode } from "../Global.js";
|
|
6
|
-
export class Sprite extends Shape {
|
|
7
|
-
constructor(config) {
|
|
8
|
-
super(config);
|
|
9
|
-
this._updated = true;
|
|
10
|
-
this.anim = new Animation(() => {
|
|
11
|
-
const updated = this._updated;
|
|
12
|
-
this._updated = false;
|
|
13
|
-
return updated;
|
|
14
|
-
});
|
|
15
|
-
this.on('animationChange.konva', function () {
|
|
16
|
-
this.frameIndex(0);
|
|
17
|
-
});
|
|
18
|
-
this.on('frameIndexChange.konva', function () {
|
|
19
|
-
this._updated = true;
|
|
20
|
-
});
|
|
21
|
-
this.on('frameRateChange.konva', function () {
|
|
22
|
-
if (!this.anim.isRunning()) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
clearInterval(this.interval);
|
|
26
|
-
this._setInterval();
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
_sceneFunc(context) {
|
|
30
|
-
const anim = this.animation(), index = this.frameIndex(), ix4 = index * 4, set = this.animations()[anim], offsets = this.frameOffsets(), x = set[ix4 + 0], y = set[ix4 + 1], width = set[ix4 + 2], height = set[ix4 + 3], image = this.image();
|
|
31
|
-
if (this.hasFill() || this.hasStroke()) {
|
|
32
|
-
context.beginPath();
|
|
33
|
-
context.rect(0, 0, width, height);
|
|
34
|
-
context.closePath();
|
|
35
|
-
context.fillStrokeShape(this);
|
|
36
|
-
}
|
|
37
|
-
if (image) {
|
|
38
|
-
if (offsets) {
|
|
39
|
-
const offset = offsets[anim], ix2 = index * 2;
|
|
40
|
-
context.drawImage(image, x, y, width, height, offset[ix2 + 0], offset[ix2 + 1], width, height);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
context.drawImage(image, x, y, width, height, 0, 0, width, height);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
_hitFunc(context) {
|
|
48
|
-
const anim = this.animation(), index = this.frameIndex(), ix4 = index * 4, set = this.animations()[anim], offsets = this.frameOffsets(), width = set[ix4 + 2], height = set[ix4 + 3];
|
|
49
|
-
context.beginPath();
|
|
50
|
-
if (offsets) {
|
|
51
|
-
const offset = offsets[anim];
|
|
52
|
-
const ix2 = index * 2;
|
|
53
|
-
context.rect(offset[ix2 + 0], offset[ix2 + 1], width, height);
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
context.rect(0, 0, width, height);
|
|
57
|
-
}
|
|
58
|
-
context.closePath();
|
|
59
|
-
context.fillShape(this);
|
|
60
|
-
}
|
|
61
|
-
_useBufferCanvas() {
|
|
62
|
-
return super._useBufferCanvas(true);
|
|
63
|
-
}
|
|
64
|
-
_setInterval() {
|
|
65
|
-
const that = this;
|
|
66
|
-
this.interval = setInterval(function () {
|
|
67
|
-
that._updateIndex();
|
|
68
|
-
}, 1000 / this.frameRate());
|
|
69
|
-
}
|
|
70
|
-
start() {
|
|
71
|
-
if (this.isRunning()) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
const layer = this.getLayer();
|
|
75
|
-
this.anim.setLayers(layer);
|
|
76
|
-
this._setInterval();
|
|
77
|
-
this.anim.start();
|
|
78
|
-
}
|
|
79
|
-
stop() {
|
|
80
|
-
this.anim.stop();
|
|
81
|
-
clearInterval(this.interval);
|
|
82
|
-
}
|
|
83
|
-
isRunning() {
|
|
84
|
-
return this.anim.isRunning();
|
|
85
|
-
}
|
|
86
|
-
_updateIndex() {
|
|
87
|
-
const index = this.frameIndex(), animation = this.animation(), animations = this.animations(), anim = animations[animation], len = anim.length / 4;
|
|
88
|
-
if (index < len - 1) {
|
|
89
|
-
this.frameIndex(index + 1);
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
this.frameIndex(0);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
Sprite.prototype.className = 'Sprite';
|
|
97
|
-
_registerNode(Sprite);
|
|
98
|
-
Factory.addGetterSetter(Sprite, 'animation');
|
|
99
|
-
Factory.addGetterSetter(Sprite, 'animations');
|
|
100
|
-
Factory.addGetterSetter(Sprite, 'frameOffsets');
|
|
101
|
-
Factory.addGetterSetter(Sprite, 'image');
|
|
102
|
-
Factory.addGetterSetter(Sprite, 'frameIndex', 0, getNumberValidator());
|
|
103
|
-
Factory.addGetterSetter(Sprite, 'frameRate', 17, getNumberValidator());
|
|
104
|
-
Factory.backCompat(Sprite, {
|
|
105
|
-
index: 'frameIndex',
|
|
106
|
-
getIndex: 'getFrameIndex',
|
|
107
|
-
setIndex: 'setFrameIndex',
|
|
108
|
-
});
|
package/lib/shapes/Star.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { Context } from '../Context.ts';
|
|
2
|
-
import type { ShapeConfig } from '../Shape.ts';
|
|
3
|
-
import { Shape } from '../Shape.ts';
|
|
4
|
-
import type { GetSet } from '../types.ts';
|
|
5
|
-
export interface StarConfig extends ShapeConfig {
|
|
6
|
-
numPoints: number;
|
|
7
|
-
innerRadius: number;
|
|
8
|
-
outerRadius: number;
|
|
9
|
-
}
|
|
10
|
-
export declare class Star extends Shape<StarConfig> {
|
|
11
|
-
_sceneFunc(context: Context): void;
|
|
12
|
-
getWidth(): number;
|
|
13
|
-
getHeight(): number;
|
|
14
|
-
setWidth(width: number): void;
|
|
15
|
-
setHeight(height: number): void;
|
|
16
|
-
outerRadius: GetSet<number, this>;
|
|
17
|
-
innerRadius: GetSet<number, this>;
|
|
18
|
-
numPoints: GetSet<number, this>;
|
|
19
|
-
}
|
package/lib/shapes/Star.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Factory } from "../Factory.js";
|
|
2
|
-
import { Shape } from "../Shape.js";
|
|
3
|
-
import { getNumberValidator } from "../Validators.js";
|
|
4
|
-
import { _registerNode } from "../Global.js";
|
|
5
|
-
export class Star extends Shape {
|
|
6
|
-
_sceneFunc(context) {
|
|
7
|
-
const innerRadius = this.innerRadius(), outerRadius = this.outerRadius(), numPoints = this.numPoints();
|
|
8
|
-
context.beginPath();
|
|
9
|
-
context.moveTo(0, 0 - outerRadius);
|
|
10
|
-
for (let n = 1; n < numPoints * 2; n++) {
|
|
11
|
-
const radius = n % 2 === 0 ? outerRadius : innerRadius;
|
|
12
|
-
const x = radius * Math.sin((n * Math.PI) / numPoints);
|
|
13
|
-
const y = -1 * radius * Math.cos((n * Math.PI) / numPoints);
|
|
14
|
-
context.lineTo(x, y);
|
|
15
|
-
}
|
|
16
|
-
context.closePath();
|
|
17
|
-
context.fillStrokeShape(this);
|
|
18
|
-
}
|
|
19
|
-
getWidth() {
|
|
20
|
-
return this.outerRadius() * 2;
|
|
21
|
-
}
|
|
22
|
-
getHeight() {
|
|
23
|
-
return this.outerRadius() * 2;
|
|
24
|
-
}
|
|
25
|
-
setWidth(width) {
|
|
26
|
-
this.outerRadius(width / 2);
|
|
27
|
-
}
|
|
28
|
-
setHeight(height) {
|
|
29
|
-
this.outerRadius(height / 2);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
Star.prototype.className = 'Star';
|
|
33
|
-
Star.prototype._centroid = true;
|
|
34
|
-
Star.prototype._attrsAffectingSize = ['innerRadius', 'outerRadius'];
|
|
35
|
-
_registerNode(Star);
|
|
36
|
-
Factory.addGetterSetter(Star, 'numPoints', 5, getNumberValidator());
|
|
37
|
-
Factory.addGetterSetter(Star, 'innerRadius', 0, getNumberValidator());
|
|
38
|
-
Factory.addGetterSetter(Star, 'outerRadius', 0, getNumberValidator());
|
package/lib/shapes/Text.d.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import type { Context } from '../Context.ts';
|
|
2
|
-
import type { ShapeConfig } from '../Shape.ts';
|
|
3
|
-
import { Shape } from '../Shape.ts';
|
|
4
|
-
import type { GetSet } from '../types.ts';
|
|
5
|
-
export interface CharRenderProps {
|
|
6
|
-
char: string;
|
|
7
|
-
index: number;
|
|
8
|
-
x: number;
|
|
9
|
-
y: number;
|
|
10
|
-
lineIndex: number;
|
|
11
|
-
column: number;
|
|
12
|
-
isLastInLine: boolean;
|
|
13
|
-
width: number;
|
|
14
|
-
context: Context;
|
|
15
|
-
}
|
|
16
|
-
export declare function stringToArray(string: string): string[];
|
|
17
|
-
export interface TextConfig extends ShapeConfig {
|
|
18
|
-
direction?: string;
|
|
19
|
-
text?: string;
|
|
20
|
-
fontFamily?: string;
|
|
21
|
-
fontSize?: number;
|
|
22
|
-
fontStyle?: string;
|
|
23
|
-
fontVariant?: string;
|
|
24
|
-
textDecoration?: string;
|
|
25
|
-
align?: string;
|
|
26
|
-
verticalAlign?: string;
|
|
27
|
-
padding?: number;
|
|
28
|
-
lineHeight?: number;
|
|
29
|
-
letterSpacing?: number;
|
|
30
|
-
wrap?: string;
|
|
31
|
-
ellipsis?: boolean;
|
|
32
|
-
}
|
|
33
|
-
export declare class Text extends Shape<TextConfig> {
|
|
34
|
-
textArr: Array<{
|
|
35
|
-
text: string;
|
|
36
|
-
width: number;
|
|
37
|
-
lastInParagraph: boolean;
|
|
38
|
-
}>;
|
|
39
|
-
_partialText: string;
|
|
40
|
-
_partialTextX: number;
|
|
41
|
-
_partialTextY: number;
|
|
42
|
-
textWidth: number;
|
|
43
|
-
textHeight: number;
|
|
44
|
-
constructor(config?: TextConfig);
|
|
45
|
-
_sceneFunc(context: Context): void;
|
|
46
|
-
_hitFunc(context: Context): void;
|
|
47
|
-
setText(text: string): this;
|
|
48
|
-
getWidth(): any;
|
|
49
|
-
getHeight(): any;
|
|
50
|
-
getTextWidth(): number;
|
|
51
|
-
getTextHeight(): number;
|
|
52
|
-
measureSize(text: string): {
|
|
53
|
-
actualBoundingBoxAscent: number;
|
|
54
|
-
actualBoundingBoxDescent: number;
|
|
55
|
-
actualBoundingBoxLeft: number;
|
|
56
|
-
actualBoundingBoxRight: number;
|
|
57
|
-
alphabeticBaseline: number;
|
|
58
|
-
emHeightAscent: number;
|
|
59
|
-
emHeightDescent: number;
|
|
60
|
-
fontBoundingBoxAscent: number;
|
|
61
|
-
fontBoundingBoxDescent: number;
|
|
62
|
-
hangingBaseline: number;
|
|
63
|
-
ideographicBaseline: number;
|
|
64
|
-
width: number;
|
|
65
|
-
height: number;
|
|
66
|
-
};
|
|
67
|
-
_getContextFont(): string;
|
|
68
|
-
_addTextLine(line: string): number;
|
|
69
|
-
_getTextWidth(text: string): number;
|
|
70
|
-
_setTextData(): void;
|
|
71
|
-
_shouldHandleEllipsis(currentHeightPx: number): boolean;
|
|
72
|
-
_tryToAddEllipsisToLastLine(): void;
|
|
73
|
-
getStrokeScaleEnabled(): boolean;
|
|
74
|
-
_useBufferCanvas(): boolean;
|
|
75
|
-
direction: GetSet<string, this>;
|
|
76
|
-
fontFamily: GetSet<string, this>;
|
|
77
|
-
fontSize: GetSet<number, this>;
|
|
78
|
-
fontStyle: GetSet<string, this>;
|
|
79
|
-
fontVariant: GetSet<string, this>;
|
|
80
|
-
align: GetSet<string, this>;
|
|
81
|
-
letterSpacing: GetSet<number, this>;
|
|
82
|
-
verticalAlign: GetSet<string, this>;
|
|
83
|
-
padding: GetSet<number, this>;
|
|
84
|
-
lineHeight: GetSet<number, this>;
|
|
85
|
-
textDecoration: GetSet<string, this>;
|
|
86
|
-
text: GetSet<string, this>;
|
|
87
|
-
wrap: GetSet<string, this>;
|
|
88
|
-
ellipsis: GetSet<boolean, this>;
|
|
89
|
-
charRenderFunc: GetSet<null | ((props: CharRenderProps) => void), this>;
|
|
90
|
-
}
|