canvas2d-wrapper 2.2.2 → 2.3.1

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 (49) hide show
  1. package/dist/Canvas2D.js +122 -158
  2. package/dist/collisions/collideElement.js +64 -61
  3. package/dist/collisions/lineWithLine.js +9 -6
  4. package/dist/collisions/pointInCircle.js +5 -5
  5. package/dist/collisions/pointInPolygon.js +18 -20
  6. package/dist/collisions/pointInRectangle.js +10 -10
  7. package/dist/collisions/pointOnLinePath.js +23 -44
  8. package/dist/events/computeEventPositions.js +13 -6
  9. package/dist/events/elementClick.js +13 -17
  10. package/dist/events/elementRightClick.js +15 -12
  11. package/dist/events/mouseMove.js +23 -36
  12. package/dist/events/mouseWheel.js +10 -9
  13. package/dist/functions/calcRatioForMinimap.js +14 -14
  14. package/dist/functions/calcTileSize.js +5 -5
  15. package/dist/functions/preloadImages.js +5 -6
  16. package/dist/functions/sortElements.js +13 -17
  17. package/dist/generateTestData.js +46 -47
  18. package/dist/hooks/useGamepad.js +8 -12
  19. package/dist/hooks/useKeyboard.js +18 -18
  20. package/dist/hooks/useMousePosition.js +25 -24
  21. package/dist/hooks/useWindowDimensions.js +17 -17
  22. package/dist/main.d.ts +2 -1
  23. package/dist/main.js +22 -42
  24. package/dist/maths/getLineLength.js +6 -6
  25. package/dist/maths/normalOnLine.js +9 -6
  26. package/dist/maths/segmentAngle.js +6 -6
  27. package/dist/render/renderCanvas.js +69 -33
  28. package/dist/render/renderCircle.js +5 -11
  29. package/dist/render/renderImage.js +7 -39
  30. package/dist/render/renderLinePath.js +24 -26
  31. package/dist/render/renderPolygon.js +7 -17
  32. package/dist/render/renderRect.js +6 -26
  33. package/dist/render/renderText.d.ts +2 -0
  34. package/dist/render/renderText.js +7 -0
  35. package/dist/shapes/CanvasImage.js +22 -37
  36. package/dist/shapes/CanvasObject.js +24 -26
  37. package/dist/shapes/Circle.js +12 -24
  38. package/dist/shapes/ColoredCanvasObject.js +13 -13
  39. package/dist/shapes/LinePath.js +15 -27
  40. package/dist/shapes/Polygon.js +12 -22
  41. package/dist/shapes/Rect.js +14 -28
  42. package/dist/shapes/Text.d.ts +38 -0
  43. package/dist/shapes/Text.js +15 -0
  44. package/dist/types/Canvas2DProps.js +0 -1
  45. package/dist/types/Canvas2DState.js +0 -1
  46. package/dist/types/CollideElementResultItem.js +0 -1
  47. package/dist/types/Position2D.js +0 -1
  48. package/dist/types/Surface2D.js +0 -1
  49. package/package.json +20 -20
@@ -1,35 +1,71 @@
1
- import y from "../functions/calcTileSize.js";
2
- import u from "../shapes/CanvasImage.js";
3
- import h from "../shapes/Circle.js";
4
- import w from "../shapes/LinePath.js";
5
- import k from "../shapes/Polygon.js";
6
- import S from "../shapes/Rect.js";
7
- import g from "./renderCircle.js";
8
- import N from "./renderImage.js";
9
- import v from "./renderLinePath.js";
10
- import C from "./renderPolygon.js";
11
- import P from "./renderRect.js";
12
- const l = {
13
- [new h({ id: "a", x: 0, y: 0, radius: 0 }).constructorName]: g,
14
- [new u({ id: "a", x: 0, y: 0, src: "", width: 0, height: 0 }).constructorName]: N,
15
- [new w({ id: "a", points: [{ x: 0, y: 0 }], lineWidth: 0, stroke: "" }).constructorName]: v,
16
- [new k({ id: "a", points: [{ x: 0, y: 0 }] }).constructorName]: C,
17
- [new S({ id: "a", x: 0, y: 0, width: 0, height: 0 }).constructorName]: P
1
+ import e from "../functions/calcTileSize.js";
2
+ import t from "../shapes/CanvasImage.js";
3
+ import n from "../shapes/Circle.js";
4
+ import r from "../shapes/LinePath.js";
5
+ import i from "../shapes/Polygon.js";
6
+ import a from "../shapes/Rect.js";
7
+ import o from "../shapes/Text.js";
8
+ import s from "./renderCircle.js";
9
+ import c from "./renderImage.js";
10
+ import l from "./renderLinePath.js";
11
+ import u from "./renderPolygon.js";
12
+ import d from "./renderRect.js";
13
+ import f from "./renderText.js";
14
+ //#region lib/render/renderCanvas.ts
15
+ var p = {
16
+ [new n({
17
+ id: "a",
18
+ x: 0,
19
+ y: 0,
20
+ radius: 0
21
+ }).constructorName]: s,
22
+ [new t({
23
+ id: "a",
24
+ x: 0,
25
+ y: 0,
26
+ src: "",
27
+ width: 0,
28
+ height: 0
29
+ }).constructorName]: c,
30
+ [new r({
31
+ id: "a",
32
+ points: [{
33
+ x: 0,
34
+ y: 0
35
+ }],
36
+ lineWidth: 0,
37
+ stroke: ""
38
+ }).constructorName]: l,
39
+ [new i({
40
+ id: "a",
41
+ points: [{
42
+ x: 0,
43
+ y: 0
44
+ }]
45
+ }).constructorName]: u,
46
+ [new a({
47
+ id: "a",
48
+ x: 0,
49
+ y: 0,
50
+ width: 0,
51
+ height: 0
52
+ }).constructorName]: d,
53
+ [new o({
54
+ id: "a",
55
+ x: 0,
56
+ y: 0,
57
+ text: "?"
58
+ }).constructorName]: f
18
59
  };
19
- function j(o, m, f, c, p, r) {
20
- const a = r.left + r.deltaLeft, d = r.top + r.deltaTop;
21
- let i = "", n = "";
22
- const s = y(p, r.zoom);
23
- o.clearRect(0, 0, m, f);
24
- for (const e of c) {
25
- e.fill !== i && typeof e.fill < "u" && (o.fillStyle = e.fill, i = e.fill), e.stroke !== n && typeof e.stroke < "u" && (o.strokeStyle = e.stroke, n = e.stroke);
26
- const t = e.constructorName;
27
- if (l[t])
28
- l[t](o, e, a, d, s);
29
- else
30
- throw new Error("Unsupported shape type:" + t);
31
- }
60
+ function m(t, n, r, i, a, o) {
61
+ let s = o.left + o.deltaLeft, c = o.top + o.deltaTop, l = "", u = "", d = e(a, o.zoom);
62
+ t.clearRect(0, 0, n, r);
63
+ for (let e of i) {
64
+ e.fill !== l && e.fill !== void 0 && (t.fillStyle = e.fill, l = e.fill), e.stroke !== u && e.stroke !== void 0 && (t.strokeStyle = e.stroke, u = e.stroke);
65
+ let n = e.constructorName;
66
+ if (p[n]) p[n](t, e, s, c, d);
67
+ else throw Error("Unsupported shape type:" + n);
68
+ }
32
69
  }
33
- export {
34
- j as default
35
- };
70
+ //#endregion
71
+ export { m as default };
@@ -1,12 +1,6 @@
1
- function d(f, r, i, s, a) {
2
- f.beginPath(), f.arc(
3
- i + r.x * a,
4
- s + r.y * a,
5
- r.radius * a,
6
- 0,
7
- 2 * Math.PI
8
- ), r.fill && f.fill(), r.stroke && f.stroke();
1
+ //#region lib/render/renderCircle.ts
2
+ function e(e, t, n, r, i) {
3
+ e.beginPath(), e.arc(n + t.x * i, r + t.y * i, t.radius * i, 0, 2 * Math.PI), t.fill && e.fill(), t.stroke && e.stroke();
9
4
  }
10
- export {
11
- d as default
12
- };
5
+ //#endregion
6
+ export { e as default };
@@ -1,41 +1,9 @@
1
+ //#region lib/render/renderImage.ts
1
2
  window.__canvas2dWrapper__ = { imgCache: {} };
2
- function p(a, s, g, c, h) {
3
- __canvas2dWrapper__.imgCache[s.src] || (__canvas2dWrapper__.imgCache[s.src] = new Image(), __canvas2dWrapper__.imgCache[s.src].src = s.src);
4
- const i = g + s.x * h, d = c + s.y * h, r = s.width * h, _ = s.height * h;
5
- s.rotation ? (a.save(), a.translate(i + r / 2, d + _ / 2), a.rotate(s.rotation), !s.sx || !s.sy || !s.swidth || !s.sheight ? a.drawImage(
6
- __canvas2dWrapper__.imgCache[s.src],
7
- -r / 2,
8
- -_ / 2,
9
- r,
10
- _
11
- ) : a.drawImage(
12
- __canvas2dWrapper__.imgCache[s.src],
13
- s.sx,
14
- s.sy,
15
- s.swidth,
16
- s.sheight,
17
- -s.swidth / 2,
18
- -s.sheight / 2,
19
- r,
20
- _
21
- ), a.restore()) : !s.sx || !s.sy || !s.swidth || !s.sheight ? a.drawImage(
22
- __canvas2dWrapper__.imgCache[s.src],
23
- i,
24
- d,
25
- r,
26
- _
27
- ) : a.drawImage(
28
- __canvas2dWrapper__.imgCache[s.src],
29
- s.sx,
30
- s.sy,
31
- s.swidth,
32
- s.sheight,
33
- i,
34
- d,
35
- r,
36
- _
37
- );
3
+ function e(e, t, n, r, i) {
4
+ __canvas2dWrapper__.imgCache[t.src] || (__canvas2dWrapper__.imgCache[t.src] = new Image(), __canvas2dWrapper__.imgCache[t.src].src = t.src);
5
+ let a = n + t.x * i, o = r + t.y * i, s = t.width * i, c = t.height * i;
6
+ t.rotation ? (e.save(), e.translate(a + s / 2, o + c / 2), e.rotate(t.rotation), !t.sx || !t.sy || !t.swidth || !t.sheight ? e.drawImage(__canvas2dWrapper__.imgCache[t.src], -s / 2, -c / 2, s, c) : e.drawImage(__canvas2dWrapper__.imgCache[t.src], t.sx, t.sy, t.swidth, t.sheight, -t.swidth / 2, -t.sheight / 2, s, c), e.restore()) : !t.sx || !t.sy || !t.swidth || !t.sheight ? e.drawImage(__canvas2dWrapper__.imgCache[t.src], a, o, s, c) : e.drawImage(__canvas2dWrapper__.imgCache[t.src], t.sx, t.sy, t.swidth, t.sheight, a, o, s, c);
38
7
  }
39
- export {
40
- p as default
41
- };
8
+ //#endregion
9
+ export { e as default };
@@ -1,27 +1,25 @@
1
- function L(n, r, g, l, i) {
2
- const p = n.lineWidth, o = r.points.map((s) => ({
3
- x: g + s.x * i,
4
- y: l + s.y * i
5
- }));
6
- if (!(o.length < 2)) {
7
- if (n.beginPath(), n.moveTo(o[0].x, o[0].y), r.smoothCorners && r.smoothCornersRadius) {
8
- for (let s = 1; s < o.length - 1; s++) {
9
- const h = o[s - 1], t = o[s], y = o[s + 1], d = t.x - h.x, f = t.y - h.y, a = y.x - t.x, u = y.y - t.y, c = Math.hypot(d, f), x = Math.hypot(a, u), R = d / c * r.smoothCornersRadius, W = f / c * r.smoothCornersRadius, v = a / x * r.smoothCornersRadius, T = u / x * r.smoothCornersRadius, e = {
10
- x: t.x - R,
11
- y: t.y - W
12
- }, C = {
13
- x: t.x + v,
14
- y: t.y + T
15
- };
16
- n.lineTo(e.x, e.y), n.quadraticCurveTo(t.x, t.y, C.x, C.y);
17
- }
18
- n.lineTo(o[o.length - 1].x, o[o.length - 1].y);
19
- } else
20
- for (let s = 1; s < o.length; s++)
21
- n.lineTo(o[s].x, o[s].y);
22
- n.lineWidth = r.lineWidth * i, n.stroke(), n.lineWidth = p;
23
- }
1
+ //#region lib/render/renderLinePath.ts
2
+ function e(e, t, n, r, i) {
3
+ let a = e.lineWidth, o = t.points.map((e) => ({
4
+ x: n + e.x * i,
5
+ y: r + e.y * i
6
+ }));
7
+ if (!(o.length < 2)) {
8
+ if (e.beginPath(), e.moveTo(o[0].x, o[0].y), t.smoothCorners && t.smoothCornersRadius) {
9
+ for (let n = 1; n < o.length - 1; n++) {
10
+ let r = o[n - 1], i = o[n], a = o[n + 1], s = i.x - r.x, c = i.y - r.y, l = a.x - i.x, u = a.y - i.y, d = Math.hypot(s, c), f = Math.hypot(l, u), p = s / d * t.smoothCornersRadius, m = c / d * t.smoothCornersRadius, h = l / f * t.smoothCornersRadius, g = u / f * t.smoothCornersRadius, _ = {
11
+ x: i.x - p,
12
+ y: i.y - m
13
+ }, v = {
14
+ x: i.x + h,
15
+ y: i.y + g
16
+ };
17
+ e.lineTo(_.x, _.y), e.quadraticCurveTo(i.x, i.y, v.x, v.y);
18
+ }
19
+ e.lineTo(o[o.length - 1].x, o[o.length - 1].y);
20
+ } else for (let t = 1; t < o.length; t++) e.lineTo(o[t].x, o[t].y);
21
+ e.lineWidth = t.lineWidth * i, e.stroke(), e.lineWidth = a;
22
+ }
24
23
  }
25
- export {
26
- L as default
27
- };
24
+ //#endregion
25
+ export { e as default };
@@ -1,18 +1,8 @@
1
- function y(i, s, r, f, o) {
2
- i.beginPath(), i.moveTo(
3
- r + s.points[0].x * o,
4
- f + s.points[0].y * o
5
- );
6
- for (let p = 0; p < s.points.length; p++)
7
- i.lineTo(
8
- r + s.points[p].x * o,
9
- f + s.points[p].y * o
10
- );
11
- i.lineTo(
12
- r + s.points[0].x * o,
13
- f + s.points[0].y * o
14
- ), s.fill && i.fill(), s.stroke && i.stroke();
1
+ //#region lib/render/renderPolygon.ts
2
+ function e(e, t, n, r, i) {
3
+ e.beginPath(), e.moveTo(n + t.points[0].x * i, r + t.points[0].y * i);
4
+ for (let a = 0; a < t.points.length; a++) e.lineTo(n + t.points[a].x * i, r + t.points[a].y * i);
5
+ e.lineTo(n + t.points[0].x * i, r + t.points[0].y * i), t.fill && e.fill(), t.stroke && e.stroke();
15
6
  }
16
- export {
17
- y as default
18
- };
7
+ //#endregion
8
+ export { e as default };
@@ -1,27 +1,7 @@
1
- function d(r, s, a, R, o) {
2
- const t = a + s.x * o, h = R + s.y * o, i = s.width * o, f = s.height * o;
3
- s.rotation ? (r.save(), r.translate(t + i / 2, h + f / 2), r.rotate(s.rotation), s.fill && r.fillRect(
4
- -i / 2,
5
- -i / 2,
6
- i,
7
- f
8
- ), s.stroke && r.strokeRect(
9
- -i / 2,
10
- -i / 2,
11
- i,
12
- f
13
- ), r.restore()) : (s.fill && r.fillRect(
14
- t,
15
- h,
16
- i,
17
- f
18
- ), s.stroke && r.strokeRect(
19
- t,
20
- h,
21
- i,
22
- f
23
- ));
1
+ //#region lib/render/renderRect.ts
2
+ function e(e, t, n, r, i) {
3
+ let a = n + t.x * i, o = r + t.y * i, s = t.width * i, c = t.height * i;
4
+ t.rotation ? (e.save(), e.translate(a + s / 2, o + c / 2), e.rotate(t.rotation), t.fill && e.fillRect(-s / 2, -s / 2, s, c), t.stroke && e.strokeRect(-s / 2, -s / 2, s, c), e.restore()) : (t.fill && e.fillRect(a, o, s, c), t.stroke && e.strokeRect(a, o, s, c));
24
5
  }
25
- export {
26
- d as default
27
- };
6
+ //#endregion
7
+ export { e as default };
@@ -0,0 +1,2 @@
1
+ import { default as Text } from '../shapes/Text';
2
+ export default function renderText(context: CanvasRenderingContext2D, element: Text, left: number, top: number, localTileSize: number): void;
@@ -0,0 +1,7 @@
1
+ //#region lib/render/renderText.ts
2
+ function e(e, t, n, r, i) {
3
+ let a = n + t.x * i, o = r + t.y * i;
4
+ e.font = t.font ?? "16px arial", t.fill && e.fillText(t.text, a, o, t.maxWidth), t.stroke && e.strokeText(t.text, a, o, t.maxWidth);
5
+ }
6
+ //#endregion
7
+ export { e as default };
@@ -1,38 +1,23 @@
1
- import g from "./CanvasObject.js";
2
- class u extends g {
3
- src;
4
- width;
5
- height;
6
- rotation;
7
- swidth;
8
- sheight;
9
- sx;
10
- sy;
11
- /**
12
- * Represents an Image that will be created on the canvas.
13
- * Note: a cache to prevent too much loading is implemented, you can create as much
14
- * images as you want of the same source without any performance issue.
15
- *
16
- * @param {string|number} id Identifier (used in click callback)
17
- * @param {number} x Left coordinate of top-left corner of picture in canvas
18
- * @param {number} y Top coordinate of top-left corner of picture in canvas
19
- * @param {number} width Picture width in canvas
20
- * @param {number} height Picture height in canvas
21
- * @param {string} src Image source link
22
- * @param {number} zIndex Stack order of the element
23
- * @param {boolean} hasCollisions Does the object have collisions ?
24
- * @param {number} rotation The rotation in radians
25
- */
26
- constructor({ id: t, x: s, y: h, width: i, height: e, src: r, zIndex: a, draggable: o, hasCollisions: c, rotation: n }) {
27
- super(t, s, h, a, o, c), this.width = i, this.height = e, this.src = r, this.rotation = n;
28
- }
29
- crop(t, s, h) {
30
- this.sx = t, this.sy = t, this.swidth = s, this.sheight = h;
31
- }
32
- get constructorName() {
33
- return "CanvasImage";
34
- }
35
- }
36
- export {
37
- u as default
1
+ import e from "./CanvasObject.js";
2
+ //#region lib/shapes/CanvasImage.ts
3
+ var t = class extends e {
4
+ src;
5
+ width;
6
+ height;
7
+ rotation;
8
+ swidth;
9
+ sheight;
10
+ sx;
11
+ sy;
12
+ constructor({ id: e, x: t, y: n, width: r, height: i, src: a, zIndex: o, draggable: s, hasCollisions: c, rotation: l }) {
13
+ super(e, t, n, o, s, c), this.width = r, this.height = i, this.src = a, this.rotation = l;
14
+ }
15
+ crop(e, t, n) {
16
+ this.sx = e, this.sy = e, this.swidth = t, this.sheight = n;
17
+ }
18
+ get constructorName() {
19
+ return "CanvasImage";
20
+ }
38
21
  };
22
+ //#endregion
23
+ export { t as default };
@@ -1,27 +1,25 @@
1
- class d {
2
- id;
3
- x;
4
- y;
5
- draggable;
6
- hasCollisions;
7
- "z-index";
8
- fill;
9
- // Always undefined here but needed for typescript to work with renderCanvas() sorting
10
- stroke;
11
- // Always undefined here but needed for typescript to work with renderCanvas() sorting
12
- constructor(s, t, e, i, a, n) {
13
- this.id = s, this.x = t, this.y = e, this["z-index"] = i, this.draggable = a, this.hasCollisions = n;
14
- }
15
- set zIndex(s) {
16
- this["z-index"] = s;
17
- }
18
- get zIndex() {
19
- return this["z-index"] || 0;
20
- }
21
- get constructorName() {
22
- return "CanvasObject";
23
- }
24
- }
25
- export {
26
- d as default
1
+ //#region lib/shapes/CanvasObject.ts
2
+ var e = class {
3
+ id;
4
+ x;
5
+ y;
6
+ draggable;
7
+ hasCollisions;
8
+ "z-index";
9
+ fill;
10
+ stroke;
11
+ constructor(e, t, n, r, i, a) {
12
+ this.id = e, this.x = t, this.y = n, this["z-index"] = r, this.draggable = i, this.hasCollisions = a;
13
+ }
14
+ set zIndex(e) {
15
+ this["z-index"] = e;
16
+ }
17
+ get zIndex() {
18
+ return this["z-index"] || 0;
19
+ }
20
+ get constructorName() {
21
+ return "CanvasObject";
22
+ }
27
23
  };
24
+ //#endregion
25
+ export { e as default };
@@ -1,25 +1,13 @@
1
- import d from "./ColoredCanvasObject.js";
2
- class C extends d {
3
- radius;
4
- /**
5
- * Represents a Rectangle that will be created on the canvas.
6
- *
7
- * @param {string|number} id Identifier (used in click callback)
8
- * @param {number} x Left coordinate of circle center in canvas
9
- * @param {number} y Top coordinate of circle center in canvas
10
- * @param {number} radius Circle radius in canvas
11
- * @param {string} fill DOMString, CanvasGradient or CanvsPattern representing what should be put in CanvasRenderingContext2D.fillStyle
12
- * @param {string} stroke DOMString, CanvasGradient or CanvsPattern representing what should be put in CanvasRenderingContext2D.strokeStyle
13
- * @param {number} zIndex Stack order of the element
14
- * @param {boolean} hasCollisions Does the object have collisions ?
15
- */
16
- constructor({ id: r, x: e, y: t, radius: s, fill: o, stroke: a, zIndex: c, draggable: u, hasCollisions: i }) {
17
- super(r, e, t, o, a, c, u, i), this.radius = s;
18
- }
19
- get constructorName() {
20
- return "Circle";
21
- }
22
- }
23
- export {
24
- C as default
1
+ import e from "./ColoredCanvasObject.js";
2
+ //#region lib/shapes/Circle.ts
3
+ var t = class extends e {
4
+ radius;
5
+ constructor({ id: e, x: t, y: n, radius: r, fill: i, stroke: a, zIndex: o, draggable: s, hasCollisions: c }) {
6
+ super(e, t, n, i, a, o, s, c), this.radius = r;
7
+ }
8
+ get constructorName() {
9
+ return "Circle";
10
+ }
25
11
  };
12
+ //#endregion
13
+ export { t as default };
@@ -1,14 +1,14 @@
1
- import n from "./CanvasObject.js";
2
- class C extends n {
3
- fill;
4
- stroke;
5
- constructor(t, e, r, s, o, a, c, l) {
6
- super(t, e, r, a, c, l), this.fill = s, this.stroke = o;
7
- }
8
- get constructorName() {
9
- return "ColoredCanvasObject";
10
- }
11
- }
12
- export {
13
- C as default
1
+ import e from "./CanvasObject.js";
2
+ //#region lib/shapes/ColoredCanvasObject.ts
3
+ var t = class extends e {
4
+ fill;
5
+ stroke;
6
+ constructor(e, t, n, r, i, a, o, s) {
7
+ super(e, t, n, a, o, s), this.fill = r, this.stroke = i;
8
+ }
9
+ get constructorName() {
10
+ return "ColoredCanvasObject";
11
+ }
14
12
  };
13
+ //#endregion
14
+ export { t as default };
@@ -1,28 +1,16 @@
1
- import a from "./ColoredCanvasObject.js";
2
- class u extends a {
3
- points;
4
- lineWidth;
5
- smoothCorners;
6
- smoothCornersRadius;
7
- /**
8
- * Represents a Line Path that will be created on the canvas.
9
- *
10
- * @param {string|number} id Identifier (used in click callback)
11
- * @param {number} points Array of coordinates {x, y} of the polygon points
12
- * @param {string} stroke DOMString, CanvasGradient or CanvsPattern representing what should be put in CanvasRenderingContext2D.strokeStyle
13
- * @param {number} zIndex Stack order of the element
14
- * @param {number} lineWidth Width of the stroked line
15
- * @param {number} smoothCorners Should we have smooth corners ?
16
- * @param {number} smoothCornersRadius Radius of smoothed corners
17
- * @param {boolean} hasCollisions Does the object have collisions ?
18
- */
19
- constructor({ id: t, lineWidth: o, points: s, stroke: e, zIndex: r, smoothCorners: n, smoothCornersRadius: i, hasCollisions: h }) {
20
- super(t, s[0].x, s[0].y, "none", e, r, !1, h), this.points = s, this.lineWidth = o, this.smoothCorners = n, this.smoothCornersRadius = i;
21
- }
22
- get constructorName() {
23
- return "LinePath";
24
- }
25
- }
26
- export {
27
- u as default
1
+ import e from "./ColoredCanvasObject.js";
2
+ //#region lib/shapes/LinePath.ts
3
+ var t = class extends e {
4
+ points;
5
+ lineWidth;
6
+ smoothCorners;
7
+ smoothCornersRadius;
8
+ constructor({ id: e, lineWidth: t, points: n, stroke: r, zIndex: i, smoothCorners: a, smoothCornersRadius: o, hasCollisions: s }) {
9
+ super(e, n[0].x, n[0].y, "none", r, i, !1, s), this.points = n, this.lineWidth = t, this.smoothCorners = a, this.smoothCornersRadius = o;
10
+ }
11
+ get constructorName() {
12
+ return "LinePath";
13
+ }
28
14
  };
15
+ //#endregion
16
+ export { t as default };
@@ -1,23 +1,13 @@
1
- import c from "./ColoredCanvasObject.js";
2
- class d extends c {
3
- points;
4
- /**
5
- * Represents a Rectangle that will be created on the canvas.
6
- *
7
- * @param {string|number} id Identifier (used in click callback)
8
- * @param {number} points Array of coordinates {x, y} of the polygon points
9
- * @param {string} fill DOMString, CanvasGradient or CanvsPattern representing what should be put in CanvasRenderingContext2D.fillStyle
10
- * @param {string} stroke DOMString, CanvasGradient or CanvsPattern representing what should be put in CanvasRenderingContext2D.strokeStyle
11
- * @param {number} zIndex Stack order of the element
12
- * @param {boolean} hasCollisions Does the object have collisions ?
13
- */
14
- constructor({ id: t, points: o, fill: r, stroke: e, zIndex: s, draggable: n, hasCollisions: a }) {
15
- super(t, o[0].x, o[0].y, r, e, s, n, a), this.points = o;
16
- }
17
- get constructorName() {
18
- return "Polygon";
19
- }
20
- }
21
- export {
22
- d as default
1
+ import e from "./ColoredCanvasObject.js";
2
+ //#region lib/shapes/Polygon.ts
3
+ var t = class extends e {
4
+ points;
5
+ constructor({ id: e, points: t, fill: n, stroke: r, zIndex: i, draggable: a, hasCollisions: o }) {
6
+ super(e, t[0].x, t[0].y, n, r, i, a, o), this.points = t;
7
+ }
8
+ get constructorName() {
9
+ return "Polygon";
10
+ }
23
11
  };
12
+ //#endregion
13
+ export { t as default };
@@ -1,29 +1,15 @@
1
- import u from "./ColoredCanvasObject.js";
2
- class m extends u {
3
- width;
4
- height;
5
- rotation;
6
- /**
7
- * Represents a Rectangle that will be created on the canvas.
8
- *
9
- * @param {string|number} id Identifier (used in click callback)
10
- * @param {number} x Left coordinate of top-left corner of rectangle in canvas
11
- * @param {number} y Top coordinate of top-left corner of rectangle in canvas
12
- * @param {number} width Rectangle width in canvas
13
- * @param {number} height Rectangle height in canvas
14
- * @param {string} fill DOMString, CanvasGradient or CanvsPattern representing what should be put in CanvasRenderingContext2D.fillStyle
15
- * @param {string} stroke DOMString, CanvasGradient or CanvsPattern representing what should be put in CanvasRenderingContext2D.strokeStyle
16
- * @param {number} zIndex Stack order of the element
17
- * @param {boolean} hasCollisions Does the object have collisions ?
18
- * @param {number} rotation The rotation in radians
19
- */
20
- constructor({ id: t, x: e, y: o, width: r, height: s, fill: i, stroke: h, zIndex: a, draggable: c, hasCollisions: n, rotation: d }) {
21
- super(t, e, o, i, h, a, c, n), this.width = r, this.height = s, this.rotation = d;
22
- }
23
- get constructorName() {
24
- return "Rect";
25
- }
26
- }
27
- export {
28
- m as default
1
+ import e from "./ColoredCanvasObject.js";
2
+ //#region lib/shapes/Rect.ts
3
+ var t = class extends e {
4
+ width;
5
+ height;
6
+ rotation;
7
+ constructor({ id: e, x: t, y: n, width: r, height: i, fill: a, stroke: o, zIndex: s, draggable: c, hasCollisions: l, rotation: u }) {
8
+ super(e, t, n, a, o, s, c, l), this.width = r, this.height = i, this.rotation = u;
9
+ }
10
+ get constructorName() {
11
+ return "Rect";
12
+ }
29
13
  };
14
+ //#endregion
15
+ export { t as default };