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.
- 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 +2 -1
- 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.d.ts +2 -0
- 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.d.ts +38 -0
- 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
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { default as ColoredCanvasObject } from './ColoredCanvasObject';
|
|
2
|
+
export default class Text extends ColoredCanvasObject {
|
|
3
|
+
text: string;
|
|
4
|
+
maxWidth?: number;
|
|
5
|
+
font?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Represents an Image that will be created on the canvas.
|
|
8
|
+
* Note: a cache to prevent too much loading is implemented, you can create as much
|
|
9
|
+
* images as you want of the same source without any performance issue.
|
|
10
|
+
*
|
|
11
|
+
* @param {string|number} id Identifier (used in click callback)
|
|
12
|
+
* @param {number} x Left coordinate of top-left corner of picture in canvas
|
|
13
|
+
* @param {number} y Top coordinate of top-left corner of picture in canvas
|
|
14
|
+
* @param {number} text Text to show
|
|
15
|
+
* @param {number} maxWidth Maximum width of this text
|
|
16
|
+
* @param {number} font Text font
|
|
17
|
+
* @param {string} fill DOMString, CanvasGradient or CanvsPattern representing what should be put in CanvasRenderingContext2D.fillStyle
|
|
18
|
+
* @param {string} stroke DOMString, CanvasGradient or CanvsPattern representing what should be put in CanvasRenderingContext2D.strokeStyle
|
|
19
|
+
* @param {number} zIndex Stack order of the element
|
|
20
|
+
* @param {boolean} hasCollisions Does the object have collisions ?
|
|
21
|
+
* @param {number} rotation The rotation in radians
|
|
22
|
+
*/
|
|
23
|
+
constructor({ id, x, y, text, maxWidth, font, fill, stroke, zIndex, draggable, hasCollisions }: {
|
|
24
|
+
id: string;
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
text: string;
|
|
28
|
+
maxWidth?: number;
|
|
29
|
+
font?: string;
|
|
30
|
+
fill?: string;
|
|
31
|
+
stroke?: string;
|
|
32
|
+
zIndex?: number;
|
|
33
|
+
draggable?: boolean;
|
|
34
|
+
hasCollisions?: boolean;
|
|
35
|
+
rotation?: number;
|
|
36
|
+
});
|
|
37
|
+
get constructorName(): string;
|
|
38
|
+
}
|
|
@@ -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
|
-
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "canvas2d-wrapper",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"types": "dist/main.d.ts",
|
|
@@ -20,28 +20,28 @@
|
|
|
20
20
|
"react-dom": "^19.0.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@eslint/js": "^
|
|
23
|
+
"@eslint/js": "^10.0.1",
|
|
24
24
|
"@testing-library/jest-dom": "^6.9.1",
|
|
25
|
-
"@testing-library/react": "^16.3.
|
|
25
|
+
"@testing-library/react": "^16.3.2",
|
|
26
26
|
"@types/jest": "^30.0.0",
|
|
27
|
-
"@types/node": "^25.
|
|
28
|
-
"@types/react": "^19.2.
|
|
27
|
+
"@types/node": "^25.9.2",
|
|
28
|
+
"@types/react": "^19.2.17",
|
|
29
29
|
"@types/react-dom": "^19.2.3",
|
|
30
|
-
"@vitejs/plugin-react": "^
|
|
31
|
-
"@vitest/coverage-v8": "^4.
|
|
32
|
-
"eslint": "^
|
|
33
|
-
"eslint-plugin-react-hooks": "^7.
|
|
34
|
-
"eslint-plugin-react-refresh": "^0.
|
|
35
|
-
"glob": "^13.0.
|
|
36
|
-
"globals": "^17.
|
|
37
|
-
"jsdom": "^
|
|
38
|
-
"react": "^19.2.
|
|
39
|
-
"react-dom": "^19.2.
|
|
40
|
-
"typescript": "5.9",
|
|
41
|
-
"typescript-eslint": "^8.
|
|
42
|
-
"vite": "^
|
|
43
|
-
"vite-plugin-dts": "^
|
|
30
|
+
"@vitejs/plugin-react": "^6.0.2",
|
|
31
|
+
"@vitest/coverage-v8": "^4.1.8",
|
|
32
|
+
"eslint": "^10.4.1",
|
|
33
|
+
"eslint-plugin-react-hooks": "^7.1.1",
|
|
34
|
+
"eslint-plugin-react-refresh": "^0.5.2",
|
|
35
|
+
"glob": "^13.0.6",
|
|
36
|
+
"globals": "^17.6.0",
|
|
37
|
+
"jsdom": "^29.1.1",
|
|
38
|
+
"react": "^19.2.7",
|
|
39
|
+
"react-dom": "^19.2.7",
|
|
40
|
+
"typescript": "^5.9.3",
|
|
41
|
+
"typescript-eslint": "^8.60.1",
|
|
42
|
+
"vite": "^8.0.16",
|
|
43
|
+
"vite-plugin-dts": "^5.0.2",
|
|
44
44
|
"vite-plugin-lib-inject-css": "^2.2.2",
|
|
45
|
-
"vitest": "^4.
|
|
45
|
+
"vitest": "^4.1.8"
|
|
46
46
|
}
|
|
47
47
|
}
|