canvas2d-wrapper 2.2.1 → 2.3.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/dist/Canvas2D.js +122 -158
- package/dist/collisions/collideElement.js +64 -61
- package/dist/collisions/lineWithLine.js +9 -6
- package/dist/collisions/pointInCircle.js +5 -5
- package/dist/collisions/pointInPolygon.js +18 -20
- package/dist/collisions/pointInRectangle.js +10 -10
- package/dist/collisions/pointOnLinePath.js +23 -44
- package/dist/events/computeEventPositions.js +13 -6
- package/dist/events/elementClick.js +13 -17
- package/dist/events/elementRightClick.js +15 -12
- package/dist/events/mouseMove.js +23 -36
- package/dist/events/mouseWheel.js +10 -9
- package/dist/functions/calcRatioForMinimap.js +14 -14
- package/dist/functions/calcTileSize.js +5 -5
- package/dist/functions/preloadImages.js +5 -6
- package/dist/functions/sortElements.js +13 -17
- package/dist/generateTestData.js +46 -47
- package/dist/hooks/useGamepad.js +8 -12
- package/dist/hooks/useKeyboard.js +18 -18
- package/dist/hooks/useMousePosition.js +25 -24
- package/dist/hooks/useWindowDimensions.js +17 -17
- package/dist/{main.d.ts → lib/main.d.ts} +2 -1
- package/dist/lib/render/renderText.d.ts +2 -0
- package/dist/lib/shapes/Text.d.ts +38 -0
- package/dist/main.js +22 -42
- package/dist/maths/getLineLength.js +6 -6
- package/dist/maths/normalOnLine.js +9 -6
- package/dist/maths/segmentAngle.js +6 -6
- package/dist/render/renderCanvas.js +69 -33
- package/dist/render/renderCircle.js +5 -11
- package/dist/render/renderImage.js +7 -39
- package/dist/render/renderLinePath.js +24 -26
- package/dist/render/renderPolygon.js +7 -17
- package/dist/render/renderRect.js +6 -26
- package/dist/render/renderText.js +7 -0
- package/dist/shapes/CanvasImage.js +22 -37
- package/dist/shapes/CanvasObject.js +24 -26
- package/dist/shapes/Circle.js +12 -24
- package/dist/shapes/ColoredCanvasObject.js +13 -13
- package/dist/shapes/LinePath.js +15 -27
- package/dist/shapes/Polygon.js +12 -22
- package/dist/shapes/Rect.js +14 -28
- package/dist/shapes/Text.js +15 -0
- package/dist/types/Canvas2DProps.js +0 -1
- package/dist/types/Canvas2DState.js +0 -1
- package/dist/types/CollideElementResultItem.js +0 -1
- package/dist/types/Position2D.js +0 -1
- package/dist/types/Surface2D.js +0 -1
- package/package.json +20 -20
- /package/dist/{Canvas2D.d.ts → lib/Canvas2D.d.ts} +0 -0
- /package/dist/{Canvas2D.spec.d.ts → lib/Canvas2D.spec.d.ts} +0 -0
- /package/dist/{collisions → lib/collisions}/collideElement.d.ts +0 -0
- /package/dist/{collisions → lib/collisions}/lineWithLine.d.ts +0 -0
- /package/dist/{collisions → lib/collisions}/pointInCircle.d.ts +0 -0
- /package/dist/{collisions → lib/collisions}/pointInPolygon.d.ts +0 -0
- /package/dist/{collisions → lib/collisions}/pointInRectangle.d.ts +0 -0
- /package/dist/{collisions → lib/collisions}/pointOnLinePath.d.ts +0 -0
- /package/dist/{events → lib/events}/computeEventPositions.d.ts +0 -0
- /package/dist/{events → lib/events}/elementClick.d.ts +0 -0
- /package/dist/{events → lib/events}/elementRightClick.d.ts +0 -0
- /package/dist/{events → lib/events}/mouseMove.d.ts +0 -0
- /package/dist/{events → lib/events}/mouseWheel.d.ts +0 -0
- /package/dist/{functions → lib/functions}/calcRatioForMinimap.d.ts +0 -0
- /package/dist/{functions → lib/functions}/calcTileSize.d.ts +0 -0
- /package/dist/{functions → lib/functions}/preloadImages.d.ts +0 -0
- /package/dist/{functions → lib/functions}/sortElements.d.ts +0 -0
- /package/dist/{generateTestData.d.ts → lib/generateTestData.d.ts} +0 -0
- /package/dist/{hooks → lib/hooks}/useGamepad.d.ts +0 -0
- /package/dist/{hooks → lib/hooks}/useKeyboard.d.ts +0 -0
- /package/dist/{hooks → lib/hooks}/useMousePosition.d.ts +0 -0
- /package/dist/{hooks → lib/hooks}/useWindowDimensions.d.ts +0 -0
- /package/dist/{maths → lib/maths}/getLineLength.d.ts +0 -0
- /package/dist/{maths → lib/maths}/normalOnLine.d.ts +0 -0
- /package/dist/{maths → lib/maths}/segmentAngle.d.ts +0 -0
- /package/dist/{render → lib/render}/renderCanvas.d.ts +0 -0
- /package/dist/{render → lib/render}/renderCircle.d.ts +0 -0
- /package/dist/{render → lib/render}/renderImage.d.ts +0 -0
- /package/dist/{render → lib/render}/renderLinePath.d.ts +0 -0
- /package/dist/{render → lib/render}/renderPolygon.d.ts +0 -0
- /package/dist/{render → lib/render}/renderRect.d.ts +0 -0
- /package/dist/{shapes → lib/shapes}/CanvasImage.d.ts +0 -0
- /package/dist/{shapes → lib/shapes}/CanvasObject.d.ts +0 -0
- /package/dist/{shapes → lib/shapes}/Circle.d.ts +0 -0
- /package/dist/{shapes → lib/shapes}/ColoredCanvasObject.d.ts +0 -0
- /package/dist/{shapes → lib/shapes}/LinePath.d.ts +0 -0
- /package/dist/{shapes → lib/shapes}/Polygon.d.ts +0 -0
- /package/dist/{shapes → lib/shapes}/Rect.d.ts +0 -0
- /package/dist/{types → lib/types}/Canvas2DProps.d.ts +0 -0
- /package/dist/{types → lib/types}/Canvas2DState.d.ts +0 -0
- /package/dist/{types → lib/types}/CollideElementResultItem.d.ts +0 -0
- /package/dist/{types → lib/types}/Position2D.d.ts +0 -0
- /package/dist/{types → lib/types}/Surface2D.d.ts +0 -0
|
@@ -1,35 +1,71 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
};
|
|
70
|
+
//#endregion
|
|
71
|
+
export { m as default };
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
11
|
-
|
|
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
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { e as default };
|
|
@@ -1,27 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { e as default };
|
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
7
|
+
//#endregion
|
|
8
|
+
export { e as default };
|
|
@@ -1,27 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
6
|
+
//#endregion
|
|
7
|
+
export { e as default };
|
|
@@ -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
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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 };
|
package/dist/shapes/Circle.js
CHANGED
|
@@ -1,25 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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 };
|
package/dist/shapes/LinePath.js
CHANGED
|
@@ -1,28 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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 };
|
package/dist/shapes/Polygon.js
CHANGED
|
@@ -1,23 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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 };
|
package/dist/shapes/Rect.js
CHANGED
|
@@ -1,29 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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 };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import e from "./ColoredCanvasObject.js";
|
|
2
|
+
//#region lib/shapes/Text.ts
|
|
3
|
+
var t = class extends e {
|
|
4
|
+
text;
|
|
5
|
+
maxWidth;
|
|
6
|
+
font;
|
|
7
|
+
constructor({ id: e, x: t, y: n, text: r, maxWidth: i, font: a, fill: o, stroke: s, zIndex: c, draggable: l, hasCollisions: u }) {
|
|
8
|
+
super(e, t, n, o, s, c, l, u), this.text = r, this.maxWidth = i, this.font = a;
|
|
9
|
+
}
|
|
10
|
+
get constructorName() {
|
|
11
|
+
return "Text";
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
export { t as default };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
package/dist/types/Position2D.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
package/dist/types/Surface2D.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|