konva 10.0.8 → 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.
Files changed (127) hide show
  1. package/konva.js +95 -48
  2. package/konva.min.js +4 -4
  3. package/package.json +1 -1
  4. package/lib/Animation.d.ts +0 -24
  5. package/lib/Animation.js +0 -142
  6. package/lib/BezierFunctions.d.ts +0 -6
  7. package/lib/BezierFunctions.js +0 -784
  8. package/lib/Canvas.d.ts +0 -33
  9. package/lib/Canvas.js +0 -137
  10. package/lib/Container.d.ts +0 -54
  11. package/lib/Container.js +0 -316
  12. package/lib/Context.d.ts +0 -95
  13. package/lib/Context.js +0 -561
  14. package/lib/Core.d.ts +0 -3
  15. package/lib/Core.js +0 -3
  16. package/lib/DragAndDrop.d.ts +0 -17
  17. package/lib/DragAndDrop.js +0 -110
  18. package/lib/Factory.d.ts +0 -22
  19. package/lib/Factory.js +0 -123
  20. package/lib/FastLayer.d.ts +0 -4
  21. package/lib/FastLayer.js +0 -12
  22. package/lib/Global.d.ts +0 -37
  23. package/lib/Global.js +0 -66
  24. package/lib/Group.d.ts +0 -9
  25. package/lib/Group.js +0 -13
  26. package/lib/Layer.d.ts +0 -62
  27. package/lib/Layer.js +0 -305
  28. package/lib/Node.d.ts +0 -323
  29. package/lib/Node.js +0 -1532
  30. package/lib/PointerEvents.d.ts +0 -11
  31. package/lib/PointerEvents.js +0 -37
  32. package/lib/Shape.d.ts +0 -196
  33. package/lib/Shape.js +0 -548
  34. package/lib/Stage.d.ts +0 -86
  35. package/lib/Stage.js +0 -715
  36. package/lib/Tween.d.ts +0 -90
  37. package/lib/Tween.js +0 -531
  38. package/lib/Util.d.ts +0 -133
  39. package/lib/Util.js +0 -866
  40. package/lib/Validators.d.ts +0 -11
  41. package/lib/Validators.js +0 -178
  42. package/lib/_CoreInternals.d.ts +0 -220
  43. package/lib/_CoreInternals.js +0 -34
  44. package/lib/_FullInternals.d.ts +0 -302
  45. package/lib/_FullInternals.js +0 -80
  46. package/lib/canvas-backend.d.ts +0 -2
  47. package/lib/canvas-backend.js +0 -27
  48. package/lib/filters/Blur.d.ts +0 -2
  49. package/lib/filters/Blur.js +0 -235
  50. package/lib/filters/Brighten.d.ts +0 -2
  51. package/lib/filters/Brighten.js +0 -12
  52. package/lib/filters/Brightness.d.ts +0 -2
  53. package/lib/filters/Brightness.js +0 -8
  54. package/lib/filters/Contrast.d.ts +0 -2
  55. package/lib/filters/Contrast.js +0 -35
  56. package/lib/filters/Emboss.d.ts +0 -2
  57. package/lib/filters/Emboss.js +0 -101
  58. package/lib/filters/Enhance.d.ts +0 -2
  59. package/lib/filters/Enhance.js +0 -84
  60. package/lib/filters/Grayscale.d.ts +0 -2
  61. package/lib/filters/Grayscale.js +0 -9
  62. package/lib/filters/HSL.d.ts +0 -2
  63. package/lib/filters/HSL.js +0 -24
  64. package/lib/filters/HSV.d.ts +0 -2
  65. package/lib/filters/HSV.js +0 -23
  66. package/lib/filters/Invert.d.ts +0 -2
  67. package/lib/filters/Invert.js +0 -8
  68. package/lib/filters/Kaleidoscope.d.ts +0 -2
  69. package/lib/filters/Kaleidoscope.js +0 -133
  70. package/lib/filters/Mask.d.ts +0 -2
  71. package/lib/filters/Mask.js +0 -151
  72. package/lib/filters/Noise.d.ts +0 -2
  73. package/lib/filters/Noise.js +0 -12
  74. package/lib/filters/Pixelate.d.ts +0 -2
  75. package/lib/filters/Pixelate.js +0 -60
  76. package/lib/filters/Posterize.d.ts +0 -2
  77. package/lib/filters/Posterize.js +0 -10
  78. package/lib/filters/RGB.d.ts +0 -2
  79. package/lib/filters/RGB.js +0 -38
  80. package/lib/filters/RGBA.d.ts +0 -2
  81. package/lib/filters/RGBA.js +0 -49
  82. package/lib/filters/Sepia.d.ts +0 -2
  83. package/lib/filters/Sepia.js +0 -11
  84. package/lib/filters/Solarize.d.ts +0 -2
  85. package/lib/filters/Solarize.js +0 -14
  86. package/lib/filters/Threshold.d.ts +0 -2
  87. package/lib/filters/Threshold.js +0 -10
  88. package/lib/index.d.ts +0 -2
  89. package/lib/index.js +0 -2
  90. package/lib/shapes/Arc.d.ts +0 -27
  91. package/lib/shapes/Arc.js +0 -60
  92. package/lib/shapes/Arrow.d.ts +0 -27
  93. package/lib/shapes/Arrow.js +0 -99
  94. package/lib/shapes/Circle.d.ts +0 -15
  95. package/lib/shapes/Circle.js +0 -33
  96. package/lib/shapes/Ellipse.d.ts +0 -18
  97. package/lib/shapes/Ellipse.js +0 -37
  98. package/lib/shapes/Image.d.ts +0 -29
  99. package/lib/shapes/Image.js +0 -131
  100. package/lib/shapes/Label.d.ts +0 -39
  101. package/lib/shapes/Label.js +0 -173
  102. package/lib/shapes/Line.d.ts +0 -29
  103. package/lib/shapes/Line.js +0 -156
  104. package/lib/shapes/Path.d.ts +0 -50
  105. package/lib/shapes/Path.js +0 -670
  106. package/lib/shapes/Rect.d.ts +0 -11
  107. package/lib/shapes/Rect.js +0 -22
  108. package/lib/shapes/RegularPolygon.d.ts +0 -26
  109. package/lib/shapes/RegularPolygon.js +0 -72
  110. package/lib/shapes/Ring.d.ts +0 -17
  111. package/lib/shapes/Ring.js +0 -33
  112. package/lib/shapes/Sprite.d.ts +0 -32
  113. package/lib/shapes/Sprite.js +0 -108
  114. package/lib/shapes/Star.d.ts +0 -19
  115. package/lib/shapes/Star.js +0 -38
  116. package/lib/shapes/Text.d.ts +0 -90
  117. package/lib/shapes/Text.js +0 -460
  118. package/lib/shapes/TextPath.d.ts +0 -72
  119. package/lib/shapes/TextPath.js +0 -268
  120. package/lib/shapes/Transformer.d.ts +0 -130
  121. package/lib/shapes/Transformer.js +0 -1009
  122. package/lib/shapes/Wedge.d.ts +0 -19
  123. package/lib/shapes/Wedge.js +0 -38
  124. package/lib/skia-backend.d.ts +0 -2
  125. package/lib/skia-backend.js +0 -24
  126. package/lib/types.d.ts +0 -56
  127. package/lib/types.js +0 -21
@@ -1,60 +0,0 @@
1
- import { Factory } from "../Factory.js";
2
- import { Util } from "../Util.js";
3
- import { Node } from "../Node.js";
4
- import { getNumberValidator } from "../Validators.js";
5
- export const Pixelate = function (imageData) {
6
- let pixelSize = Math.ceil(this.pixelSize()), width = imageData.width, height = imageData.height, nBinsX = Math.ceil(width / pixelSize), nBinsY = Math.ceil(height / pixelSize), data = imageData.data;
7
- if (pixelSize <= 0) {
8
- Util.error('pixelSize value can not be <= 0');
9
- return;
10
- }
11
- for (let xBin = 0; xBin < nBinsX; xBin += 1) {
12
- for (let yBin = 0; yBin < nBinsY; yBin += 1) {
13
- let red = 0;
14
- let green = 0;
15
- let blue = 0;
16
- let alpha = 0;
17
- const xBinStart = xBin * pixelSize;
18
- const xBinEnd = xBinStart + pixelSize;
19
- const yBinStart = yBin * pixelSize;
20
- const yBinEnd = yBinStart + pixelSize;
21
- let pixelsInBin = 0;
22
- for (let x = xBinStart; x < xBinEnd; x += 1) {
23
- if (x >= width) {
24
- continue;
25
- }
26
- for (let y = yBinStart; y < yBinEnd; y += 1) {
27
- if (y >= height) {
28
- continue;
29
- }
30
- const i = (width * y + x) * 4;
31
- red += data[i + 0];
32
- green += data[i + 1];
33
- blue += data[i + 2];
34
- alpha += data[i + 3];
35
- pixelsInBin += 1;
36
- }
37
- }
38
- red = red / pixelsInBin;
39
- green = green / pixelsInBin;
40
- blue = blue / pixelsInBin;
41
- alpha = alpha / pixelsInBin;
42
- for (let x = xBinStart; x < xBinEnd; x += 1) {
43
- if (x >= width) {
44
- continue;
45
- }
46
- for (let y = yBinStart; y < yBinEnd; y += 1) {
47
- if (y >= height) {
48
- continue;
49
- }
50
- const i = (width * y + x) * 4;
51
- data[i + 0] = red;
52
- data[i + 1] = green;
53
- data[i + 2] = blue;
54
- data[i + 3] = alpha;
55
- }
56
- }
57
- }
58
- }
59
- };
60
- Factory.addGetterSetter(Node, 'pixelSize', 8, getNumberValidator(), Factory.afterSetFilter);
@@ -1,2 +0,0 @@
1
- import type { Filter } from '../Node.ts';
2
- export declare const Posterize: Filter;
@@ -1,10 +0,0 @@
1
- import { Factory } from "../Factory.js";
2
- import { Node } from "../Node.js";
3
- import { getNumberValidator } from "../Validators.js";
4
- export const Posterize = function (imageData) {
5
- const levels = Math.round(this.levels() * 254) + 1, data = imageData.data, len = data.length, scale = 255 / levels;
6
- for (let i = 0; i < len; i += 1) {
7
- data[i] = Math.floor(data[i] / scale) * scale;
8
- }
9
- };
10
- Factory.addGetterSetter(Node, 'levels', 0.5, getNumberValidator(), Factory.afterSetFilter);
@@ -1,2 +0,0 @@
1
- import type { Filter } from '../Node.ts';
2
- export declare const RGB: Filter;
@@ -1,38 +0,0 @@
1
- import { Factory } from "../Factory.js";
2
- import { Node } from "../Node.js";
3
- import { RGBComponent } from "../Validators.js";
4
- export const RGB = function (imageData) {
5
- const data = imageData.data, nPixels = data.length, red = this.red(), green = this.green(), blue = this.blue();
6
- for (let i = 0; i < nPixels; i += 4) {
7
- const brightness = (0.34 * data[i] + 0.5 * data[i + 1] + 0.16 * data[i + 2]) / 255;
8
- data[i] = brightness * red;
9
- data[i + 1] = brightness * green;
10
- data[i + 2] = brightness * blue;
11
- data[i + 3] = data[i + 3];
12
- }
13
- };
14
- Factory.addGetterSetter(Node, 'red', 0, function (val) {
15
- this._filterUpToDate = false;
16
- if (val > 255) {
17
- return 255;
18
- }
19
- else if (val < 0) {
20
- return 0;
21
- }
22
- else {
23
- return Math.round(val);
24
- }
25
- });
26
- Factory.addGetterSetter(Node, 'green', 0, function (val) {
27
- this._filterUpToDate = false;
28
- if (val > 255) {
29
- return 255;
30
- }
31
- else if (val < 0) {
32
- return 0;
33
- }
34
- else {
35
- return Math.round(val);
36
- }
37
- });
38
- Factory.addGetterSetter(Node, 'blue', 0, RGBComponent, Factory.afterSetFilter);
@@ -1,2 +0,0 @@
1
- import type { Filter } from '../Node.ts';
2
- export declare const RGBA: Filter;
@@ -1,49 +0,0 @@
1
- import { Factory } from "../Factory.js";
2
- import { Node } from "../Node.js";
3
- import { RGBComponent } from "../Validators.js";
4
- export const RGBA = function (imageData) {
5
- const data = imageData.data, nPixels = data.length, red = this.red(), green = this.green(), blue = this.blue(), alpha = this.alpha();
6
- for (let i = 0; i < nPixels; i += 4) {
7
- const ia = 1 - alpha;
8
- data[i] = red * alpha + data[i] * ia;
9
- data[i + 1] = green * alpha + data[i + 1] * ia;
10
- data[i + 2] = blue * alpha + data[i + 2] * ia;
11
- }
12
- };
13
- Factory.addGetterSetter(Node, 'red', 0, function (val) {
14
- this._filterUpToDate = false;
15
- if (val > 255) {
16
- return 255;
17
- }
18
- else if (val < 0) {
19
- return 0;
20
- }
21
- else {
22
- return Math.round(val);
23
- }
24
- });
25
- Factory.addGetterSetter(Node, 'green', 0, function (val) {
26
- this._filterUpToDate = false;
27
- if (val > 255) {
28
- return 255;
29
- }
30
- else if (val < 0) {
31
- return 0;
32
- }
33
- else {
34
- return Math.round(val);
35
- }
36
- });
37
- Factory.addGetterSetter(Node, 'blue', 0, RGBComponent, Factory.afterSetFilter);
38
- Factory.addGetterSetter(Node, 'alpha', 1, function (val) {
39
- this._filterUpToDate = false;
40
- if (val > 1) {
41
- return 1;
42
- }
43
- else if (val < 0) {
44
- return 0;
45
- }
46
- else {
47
- return val;
48
- }
49
- });
@@ -1,2 +0,0 @@
1
- import type { Filter } from '../Node.ts';
2
- export declare const Sepia: Filter;
@@ -1,11 +0,0 @@
1
- export const Sepia = function (imageData) {
2
- const data = imageData.data, nPixels = data.length;
3
- for (let i = 0; i < nPixels; i += 4) {
4
- const r = data[i + 0];
5
- const g = data[i + 1];
6
- const b = data[i + 2];
7
- data[i + 0] = Math.min(255, r * 0.393 + g * 0.769 + b * 0.189);
8
- data[i + 1] = Math.min(255, r * 0.349 + g * 0.686 + b * 0.168);
9
- data[i + 2] = Math.min(255, r * 0.272 + g * 0.534 + b * 0.131);
10
- }
11
- };
@@ -1,2 +0,0 @@
1
- import type { Filter } from '../Node.ts';
2
- export declare const Solarize: Filter;
@@ -1,14 +0,0 @@
1
- export const Solarize = function (imageData) {
2
- const threshold = 128;
3
- const d = imageData.data;
4
- for (let i = 0; i < d.length; i += 4) {
5
- const r = d[i], g = d[i + 1], b = d[i + 2];
6
- const L = 0.2126 * r + 0.7152 * g + 0.0722 * b;
7
- if (L >= threshold) {
8
- d[i] = 255 - r;
9
- d[i + 1] = 255 - g;
10
- d[i + 2] = 255 - b;
11
- }
12
- }
13
- return imageData;
14
- };
@@ -1,2 +0,0 @@
1
- import type { Filter } from '../Node.ts';
2
- export declare const Threshold: Filter;
@@ -1,10 +0,0 @@
1
- import { Factory } from "../Factory.js";
2
- import { Node } from "../Node.js";
3
- import { getNumberValidator } from "../Validators.js";
4
- export const Threshold = function (imageData) {
5
- const level = this.threshold() * 255, data = imageData.data, len = data.length;
6
- for (let i = 0; i < len; i += 1) {
7
- data[i] = data[i] < level ? 0 : 255;
8
- }
9
- };
10
- Factory.addGetterSetter(Node, 'threshold', 0.5, getNumberValidator(), Factory.afterSetFilter);
package/lib/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { Konva } from './_FullInternals.ts';
2
- export default Konva;
package/lib/index.js DELETED
@@ -1,2 +0,0 @@
1
- import { Konva } from "./_FullInternals.js";
2
- export default Konva;
@@ -1,27 +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 ArcConfig extends ShapeConfig {
6
- angle: number;
7
- innerRadius: number;
8
- outerRadius: number;
9
- clockwise?: boolean;
10
- }
11
- export declare class Arc extends Shape<ArcConfig> {
12
- _sceneFunc(context: Context): void;
13
- getWidth(): number;
14
- getHeight(): number;
15
- setWidth(width: number): void;
16
- setHeight(height: number): void;
17
- getSelfRect(): {
18
- x: number;
19
- y: number;
20
- width: number;
21
- height: number;
22
- };
23
- innerRadius: GetSet<number, this>;
24
- outerRadius: GetSet<number, this>;
25
- angle: GetSet<number, this>;
26
- clockwise: GetSet<boolean, this>;
27
- }
package/lib/shapes/Arc.js DELETED
@@ -1,60 +0,0 @@
1
- import { Factory } from "../Factory.js";
2
- import { Shape } from "../Shape.js";
3
- import { Konva } from "../Global.js";
4
- import { getNumberValidator, getBooleanValidator } from "../Validators.js";
5
- import { _registerNode } from "../Global.js";
6
- export class Arc extends Shape {
7
- _sceneFunc(context) {
8
- const angle = Konva.getAngle(this.angle()), clockwise = this.clockwise();
9
- context.beginPath();
10
- context.arc(0, 0, this.outerRadius(), 0, angle, clockwise);
11
- context.arc(0, 0, this.innerRadius(), angle, 0, !clockwise);
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
- getSelfRect() {
28
- const innerRadius = this.innerRadius();
29
- const outerRadius = this.outerRadius();
30
- const clockwise = this.clockwise();
31
- const angle = Konva.getAngle(clockwise ? 360 - this.angle() : this.angle());
32
- const boundLeftRatio = Math.cos(Math.min(angle, Math.PI));
33
- const boundRightRatio = 1;
34
- const boundTopRatio = Math.sin(Math.min(Math.max(Math.PI, angle), (3 * Math.PI) / 2));
35
- const boundBottomRatio = Math.sin(Math.min(angle, Math.PI / 2));
36
- const boundLeft = boundLeftRatio * (boundLeftRatio > 0 ? innerRadius : outerRadius);
37
- const boundRight = boundRightRatio * (boundRightRatio > 0 ? outerRadius : innerRadius);
38
- const boundTop = boundTopRatio * (boundTopRatio > 0 ? innerRadius : outerRadius);
39
- const boundBottom = boundBottomRatio * (boundBottomRatio > 0 ? outerRadius : innerRadius);
40
- return {
41
- x: boundLeft,
42
- y: clockwise ? -1 * boundBottom : boundTop,
43
- width: boundRight - boundLeft,
44
- height: boundBottom - boundTop,
45
- };
46
- }
47
- }
48
- Arc.prototype._centroid = true;
49
- Arc.prototype.className = 'Arc';
50
- Arc.prototype._attrsAffectingSize = [
51
- 'innerRadius',
52
- 'outerRadius',
53
- 'angle',
54
- 'clockwise',
55
- ];
56
- _registerNode(Arc);
57
- Factory.addGetterSetter(Arc, 'innerRadius', 0, getNumberValidator());
58
- Factory.addGetterSetter(Arc, 'outerRadius', 0, getNumberValidator());
59
- Factory.addGetterSetter(Arc, 'angle', 0, getNumberValidator());
60
- Factory.addGetterSetter(Arc, 'clockwise', false, getBooleanValidator());
@@ -1,27 +0,0 @@
1
- import type { LineConfig } from './Line.ts';
2
- import { Line } from './Line.ts';
3
- import type { GetSet } from '../types.ts';
4
- import type { Context } from '../Context.ts';
5
- export interface ArrowConfig extends LineConfig {
6
- points: number[];
7
- tension?: number;
8
- closed?: boolean;
9
- pointerLength?: number;
10
- pointerWidth?: number;
11
- pointerAtBeginning?: boolean;
12
- pointerAtEnding?: boolean;
13
- }
14
- export declare class Arrow extends Line<ArrowConfig> {
15
- _sceneFunc(ctx: Context): void;
16
- __fillStroke(ctx: Context): void;
17
- getSelfRect(): {
18
- x: number;
19
- y: number;
20
- width: number;
21
- height: number;
22
- };
23
- pointerLength: GetSet<number, this>;
24
- pointerWidth: GetSet<number, this>;
25
- pointerAtEnding: GetSet<boolean, this>;
26
- pointerAtBeginning: GetSet<boolean, this>;
27
- }
@@ -1,99 +0,0 @@
1
- import { Factory } from "../Factory.js";
2
- import { Line } from "./Line.js";
3
- import { getNumberValidator } from "../Validators.js";
4
- import { _registerNode } from "../Global.js";
5
- import { Path } from "./Path.js";
6
- export class Arrow extends Line {
7
- _sceneFunc(ctx) {
8
- super._sceneFunc(ctx);
9
- const PI2 = Math.PI * 2;
10
- const points = this.points();
11
- let tp = points;
12
- const fromTension = this.tension() !== 0 && points.length > 4;
13
- if (fromTension) {
14
- tp = this.getTensionPoints();
15
- }
16
- const length = this.pointerLength();
17
- const n = points.length;
18
- let dx, dy;
19
- if (fromTension) {
20
- const lp = [
21
- tp[tp.length - 4],
22
- tp[tp.length - 3],
23
- tp[tp.length - 2],
24
- tp[tp.length - 1],
25
- points[n - 2],
26
- points[n - 1],
27
- ];
28
- const lastLength = Path.calcLength(tp[tp.length - 4], tp[tp.length - 3], 'C', lp);
29
- const previous = Path.getPointOnQuadraticBezier(Math.min(1, 1 - length / lastLength), lp[0], lp[1], lp[2], lp[3], lp[4], lp[5]);
30
- dx = points[n - 2] - previous.x;
31
- dy = points[n - 1] - previous.y;
32
- }
33
- else {
34
- dx = points[n - 2] - points[n - 4];
35
- dy = points[n - 1] - points[n - 3];
36
- }
37
- const radians = (Math.atan2(dy, dx) + PI2) % PI2;
38
- const width = this.pointerWidth();
39
- if (this.pointerAtEnding()) {
40
- ctx.save();
41
- ctx.beginPath();
42
- ctx.translate(points[n - 2], points[n - 1]);
43
- ctx.rotate(radians);
44
- ctx.moveTo(0, 0);
45
- ctx.lineTo(-length, width / 2);
46
- ctx.lineTo(-length, -width / 2);
47
- ctx.closePath();
48
- ctx.restore();
49
- this.__fillStroke(ctx);
50
- }
51
- if (this.pointerAtBeginning()) {
52
- ctx.save();
53
- ctx.beginPath();
54
- ctx.translate(points[0], points[1]);
55
- if (fromTension) {
56
- dx = (tp[0] + tp[2]) / 2 - points[0];
57
- dy = (tp[1] + tp[3]) / 2 - points[1];
58
- }
59
- else {
60
- dx = points[2] - points[0];
61
- dy = points[3] - points[1];
62
- }
63
- ctx.rotate((Math.atan2(-dy, -dx) + PI2) % PI2);
64
- ctx.moveTo(0, 0);
65
- ctx.lineTo(-length, width / 2);
66
- ctx.lineTo(-length, -width / 2);
67
- ctx.closePath();
68
- ctx.restore();
69
- this.__fillStroke(ctx);
70
- }
71
- }
72
- __fillStroke(ctx) {
73
- const isDashEnabled = this.dashEnabled();
74
- if (isDashEnabled) {
75
- this.attrs.dashEnabled = false;
76
- ctx.setLineDash([]);
77
- }
78
- ctx.fillStrokeShape(this);
79
- if (isDashEnabled) {
80
- this.attrs.dashEnabled = true;
81
- }
82
- }
83
- getSelfRect() {
84
- const lineRect = super.getSelfRect();
85
- const offset = this.pointerWidth() / 2;
86
- return {
87
- x: lineRect.x,
88
- y: lineRect.y - offset,
89
- width: lineRect.width,
90
- height: lineRect.height + offset * 2,
91
- };
92
- }
93
- }
94
- Arrow.prototype.className = 'Arrow';
95
- _registerNode(Arrow);
96
- Factory.addGetterSetter(Arrow, 'pointerLength', 10, getNumberValidator());
97
- Factory.addGetterSetter(Arrow, 'pointerWidth', 10, getNumberValidator());
98
- Factory.addGetterSetter(Arrow, 'pointerAtBeginning', false);
99
- Factory.addGetterSetter(Arrow, 'pointerAtEnding', true);
@@ -1,15 +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 CircleConfig extends ShapeConfig {
6
- radius?: number;
7
- }
8
- export declare class Circle extends Shape<CircleConfig> {
9
- _sceneFunc(context: Context): void;
10
- getWidth(): number;
11
- getHeight(): number;
12
- setWidth(width: number): void;
13
- setHeight(height: number): void;
14
- radius: GetSet<number, this>;
15
- }
@@ -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
- export class Circle extends Shape {
6
- _sceneFunc(context) {
7
- context.beginPath();
8
- context.arc(0, 0, this.attrs.radius || 0, 0, Math.PI * 2, false);
9
- context.closePath();
10
- context.fillStrokeShape(this);
11
- }
12
- getWidth() {
13
- return this.radius() * 2;
14
- }
15
- getHeight() {
16
- return this.radius() * 2;
17
- }
18
- setWidth(width) {
19
- if (this.radius() !== width / 2) {
20
- this.radius(width / 2);
21
- }
22
- }
23
- setHeight(height) {
24
- if (this.radius() !== height / 2) {
25
- this.radius(height / 2);
26
- }
27
- }
28
- }
29
- Circle.prototype._centroid = true;
30
- Circle.prototype.className = 'Circle';
31
- Circle.prototype._attrsAffectingSize = ['radius'];
32
- _registerNode(Circle);
33
- Factory.addGetterSetter(Circle, 'radius', 0, getNumberValidator());
@@ -1,18 +0,0 @@
1
- import type { ShapeConfig } from '../Shape.ts';
2
- import { Shape } from '../Shape.ts';
3
- import type { Context } from '../Context.ts';
4
- import type { GetSet, Vector2d } from '../types.ts';
5
- export interface EllipseConfig extends ShapeConfig {
6
- radiusX: number;
7
- radiusY: number;
8
- }
9
- export declare class Ellipse extends Shape<EllipseConfig> {
10
- _sceneFunc(context: Context): void;
11
- getWidth(): number;
12
- getHeight(): number;
13
- setWidth(width: number): void;
14
- setHeight(height: number): void;
15
- radius: GetSet<Vector2d, this>;
16
- radiusX: GetSet<number, this>;
17
- radiusY: GetSet<number, this>;
18
- }
@@ -1,37 +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 Ellipse extends Shape {
6
- _sceneFunc(context) {
7
- const rx = this.radiusX(), ry = this.radiusY();
8
- context.beginPath();
9
- context.save();
10
- if (rx !== ry) {
11
- context.scale(1, ry / rx);
12
- }
13
- context.arc(0, 0, rx, 0, Math.PI * 2, false);
14
- context.restore();
15
- context.closePath();
16
- context.fillStrokeShape(this);
17
- }
18
- getWidth() {
19
- return this.radiusX() * 2;
20
- }
21
- getHeight() {
22
- return this.radiusY() * 2;
23
- }
24
- setWidth(width) {
25
- this.radiusX(width / 2);
26
- }
27
- setHeight(height) {
28
- this.radiusY(height / 2);
29
- }
30
- }
31
- Ellipse.prototype.className = 'Ellipse';
32
- Ellipse.prototype._centroid = true;
33
- Ellipse.prototype._attrsAffectingSize = ['radiusX', 'radiusY'];
34
- _registerNode(Ellipse);
35
- Factory.addComponentsGetterSetter(Ellipse, 'radius', ['x', 'y']);
36
- Factory.addGetterSetter(Ellipse, 'radiusX', 0, getNumberValidator());
37
- Factory.addGetterSetter(Ellipse, 'radiusY', 0, getNumberValidator());
@@ -1,29 +0,0 @@
1
- import type { ShapeConfig } from '../Shape.ts';
2
- import { Shape } from '../Shape.ts';
3
- import type { GetSet, IRect } from '../types.ts';
4
- import type { Context } from '../Context.ts';
5
- export interface ImageConfig extends ShapeConfig {
6
- image: CanvasImageSource | undefined;
7
- crop?: IRect;
8
- cornerRadius?: number | number[];
9
- }
10
- export declare class Image extends Shape<ImageConfig> {
11
- private _loadListener;
12
- constructor(attrs?: ImageConfig);
13
- _setImageLoad(): void;
14
- _removeImageLoad(image: any): void;
15
- destroy(): this;
16
- _useBufferCanvas(): boolean;
17
- _sceneFunc(context: Context): void;
18
- _hitFunc(context: Context): void;
19
- getWidth(): any;
20
- getHeight(): any;
21
- static fromURL(url: string, callback: (img: Image) => void, onError?: OnErrorEventHandler): void;
22
- image: GetSet<CanvasImageSource | undefined, this>;
23
- crop: GetSet<IRect, this>;
24
- cropX: GetSet<number, this>;
25
- cropY: GetSet<number, this>;
26
- cropWidth: GetSet<number, this>;
27
- cropHeight: GetSet<number, this>;
28
- cornerRadius: GetSet<number | number[], this>;
29
- }