@tsparticles/canvas-utils 4.0.0-beta.1 → 4.0.0-beta.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/README.md CHANGED
@@ -8,6 +8,12 @@
8
8
 
9
9
  [tsParticles](https://github.com/tsparticles/tsparticles) canvas utils.
10
10
 
11
+ ## Quick checklist
12
+
13
+ 1. Install `@tsparticles/engine` (or use the CDN bundle below)
14
+ 2. Call the package loader function(s) before `tsParticles.load(...)`
15
+ 3. Apply the package options in your `tsParticles.load(...)` config
16
+
11
17
  ## How to use it
12
18
 
13
19
  ### CDN / Vanilla JS / jQuery
@@ -72,3 +78,14 @@ import { loadCanvasUtilsPath } from "@tsparticles/canvas-utils";
72
78
  await loadCanvasUtilsPath(tsParticles);
73
79
  })();
74
80
  ```
81
+
82
+ ## Common pitfalls
83
+
84
+ - Calling `tsParticles.load(...)` before `loadCanvasUtilsPath(...)`
85
+ - Verify required peer packages before enabling advanced options
86
+ - Change one option group at a time to isolate regressions quickly
87
+
88
+ ## Related docs
89
+
90
+ - All packages catalog: <https://github.com/tsparticles/tsparticles>
91
+ - Main docs: <https://particles.js.org/docs/>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/canvas-utils",
3
- "version": "4.0.0-beta.1",
3
+ "version": "4.0.0-beta.10",
4
4
  "description": "tsParticles canvas utils library",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -97,13 +97,12 @@
97
97
  "browser": "./browser/index.js",
98
98
  "import": "./esm/index.js",
99
99
  "require": "./cjs/index.js",
100
- "umd": "./umd/index.js",
101
- "default": "./cjs/index.js"
100
+ "default": "./esm/index.js"
102
101
  },
103
102
  "./package.json": "./package.json"
104
103
  },
105
- "dependencies": {
106
- "@tsparticles/engine": "4.0.0-beta.1"
104
+ "peerDependencies": {
105
+ "@tsparticles/engine": "4.0.0-beta.10"
107
106
  },
108
107
  "type": "module"
109
108
  }
package/report.html CHANGED
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1" />
6
- <title>@tsparticles/canvas-utils [31 Mar 2026 at 08:45]</title>
6
+ <title>@tsparticles/canvas-utils [8 Apr 2026 at 15:55]</title>
7
7
  <link
8
8
  rel="shortcut icon"
9
9
  href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT7/P31+fyv4vxGkcz6/P6/6P3j7vfS5PNnpNUxhcbO7f7F6v3O4vHK3/DA2u631Ouy0eqXweKJud5wqthfoNMMbLvY8f73+v2dxeR8sNtTmdDx9/zX6PSjyeaCtd1YnNGX2PuQveCGt95Nls42h8dLlM3F4vBtAAAAM3RSTlMAAyOx0/sKBvik8opWGBMOAe3l1snDm2E9LSb06eHcu5JpHbarfHZCN9CBb08zzkdNS0kYaptYAAAFV0lEQVRYw92X51/aYBDHHS2O2qqttVbrqNq9m+TJIAYIShBkWwqIiCgoWvfeq7Z2/s29hyQNyUcR7LveGwVyXy6XH8/9rqxglLfUPLxVduUor3h0rfp2TYvpivk37929TkG037hffoX0+peVtZQc1589rigVUdXS/ABSAyEmGIO/1XfvldSK8vs3OqB6u3m0nxmIrvgB0dj7rr7Y9IbuF68hnfFaiHA/sxqm0wciIG43P60qKv9WXWc1RXGh/mFESFABTSBi0sNAKzqet17eCtOb3kZIDwxEEU0oAIJGYxNBD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X6Zcjp1f2wu4tvzZKo0ecPnDtQYDQvJXaBeNzce45Fp28ZQLrEZVuFqgBwOalArKXnW1UzlnSusQKJqKYNuz4tOnI6sZG4zanpemv+7ySU2jbA9h6uhcgpfy6G2PahirDZ6zvq6zDduMVFTKvzw8wgyEdelwY9in3XkEPs3osJuwRQ4qTkfzifndg9Gfc4pdsu82+tTnHZTBa2EAMrqr2t43pguc8tNm7JQVQ2S0ukj2d22dhXYP0/veWtwKrCkNoNimAN5+Xr/oLrxswKbVJjteWrX7eR63o4j9q0GxnaBdWgGA5VStpanIjQmEhV0/nVt5VOFUvix6awJhPcAaTEShgrG+iGyvb5a0Ndb1YGHFPEwoqAinoaykaID1o1pdPNu7XsnCKQ3R+hwWIIhGvORcJUBYXe3Xa3vq/mF/N9V13ugufMkfXn+KHsRD0B8AAAAASUVORK5CYII="
@@ -4,7 +4,7 @@
4
4
  * Demo / Generator : https://particles.js.org/
5
5
  * GitHub : https://www.github.com/matteobruni/tsparticles
6
6
  * How to use? : Check the GitHub README
7
- * v4.0.0-beta.1
7
+ * v4.0.0-beta.10
8
8
  */
9
9
  /*
10
10
  * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
package/umd/Utils.js DELETED
@@ -1,123 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "@tsparticles/engine"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.drawLine = drawLine;
13
- exports.getCanvasImageData = getCanvasImageData;
14
- exports.getImageData = getImageData;
15
- exports.getTextData = getTextData;
16
- exports.loadFont = loadFont;
17
- const engine_1 = require("@tsparticles/engine");
18
- const defaultWidth = 0, indexesOffset = {
19
- r: 0,
20
- g: 1,
21
- b: 2,
22
- a: 3,
23
- }, alphaMax = 255, alphaFactor = engine_1.identity / alphaMax;
24
- function drawLine(context, begin, end) {
25
- context.beginPath();
26
- context.moveTo(begin.x, begin.y);
27
- context.lineTo(end.x, end.y);
28
- context.closePath();
29
- }
30
- function getCanvasImageData(ctx, size, offset, clear = true) {
31
- const imageData = ctx.getImageData(engine_1.originPoint.x, engine_1.originPoint.y, size.width, size.height).data;
32
- if (clear) {
33
- ctx.clearRect(engine_1.originPoint.x, engine_1.originPoint.y, size.width, size.height);
34
- }
35
- const pixels = [];
36
- for (let i = 0; i < imageData.length; i += offset) {
37
- const idx = i / offset, pos = {
38
- x: idx % size.width,
39
- y: Math.floor(idx / size.width),
40
- };
41
- pixels[pos.y] ??= [];
42
- const row = pixels[pos.y];
43
- if (!row) {
44
- continue;
45
- }
46
- row[pos.x] = {
47
- r: imageData[i + indexesOffset.r] ?? engine_1.defaultRgbMin,
48
- g: imageData[i + indexesOffset.g] ?? engine_1.defaultRgbMin,
49
- b: imageData[i + indexesOffset.b] ?? engine_1.defaultRgbMin,
50
- a: (imageData[i + indexesOffset.a] ?? engine_1.defaultAlpha) * alphaFactor,
51
- };
52
- }
53
- return {
54
- pixels,
55
- width: Math.min(...pixels.map(row => row.length)),
56
- height: pixels.length,
57
- };
58
- }
59
- function getImageData(src, offset, canvasSettings) {
60
- const image = new Image();
61
- image.crossOrigin = "Anonymous";
62
- const p = new Promise((resolve, reject) => {
63
- image.onerror = reject;
64
- image.onload = () => {
65
- const canvas = (0, engine_1.safeDocument)().createElement("canvas");
66
- canvas.width = image.width;
67
- canvas.height = image.height;
68
- const context = canvas.getContext("2d", canvasSettings);
69
- if (!context) {
70
- reject(new Error("Could not get canvas context"));
71
- return;
72
- }
73
- context.drawImage(image, engine_1.originPoint.x, engine_1.originPoint.y, image.width, image.height, engine_1.originPoint.x, engine_1.originPoint.y, canvas.width, canvas.height);
74
- resolve(getCanvasImageData(context, canvas, offset));
75
- };
76
- });
77
- image.src = src;
78
- return p;
79
- }
80
- function getTextData(textOptions, offset, fill, canvasSettings) {
81
- const canvas = (0, engine_1.safeDocument)().createElement("canvas"), context = canvas.getContext("2d", canvasSettings), { font, text, lines: linesOptions, color } = textOptions;
82
- if (!text || !context) {
83
- return;
84
- }
85
- const lines = text.split(linesOptions.separator), fontSize = (0, engine_1.isNumber)(font.size) ? `${font.size.toString()}px` : font.size, linesData = [];
86
- let maxWidth = 0, totalHeight = 0;
87
- for (const line of lines) {
88
- context.font = `${font.style || ""} ${font.variant || ""} ${font.weight || ""} ${fontSize} ${font.family}`;
89
- const measure = context.measureText(line), lineData = {
90
- measure,
91
- text: line,
92
- height: measure.actualBoundingBoxAscent + measure.actualBoundingBoxDescent,
93
- width: measure.width,
94
- };
95
- maxWidth = Math.max(maxWidth || defaultWidth, lineData.width);
96
- totalHeight += lineData.height + linesOptions.spacing;
97
- linesData.push(lineData);
98
- }
99
- canvas.width = maxWidth;
100
- canvas.height = totalHeight;
101
- let currentHeight = 0;
102
- for (const line of linesData) {
103
- context.font = `${font.style || ""} ${font.variant || ""} ${font.weight || ""} ${fontSize} ${font.family}`;
104
- if (fill) {
105
- context.fillStyle = color;
106
- context.fillText(line.text, engine_1.originPoint.x, currentHeight + line.measure.actualBoundingBoxAscent);
107
- }
108
- else {
109
- context.strokeStyle = color;
110
- context.strokeText(line.text, engine_1.originPoint.x, currentHeight + line.measure.actualBoundingBoxAscent);
111
- }
112
- currentHeight += line.height + linesOptions.spacing;
113
- }
114
- return getCanvasImageData(context, canvas, offset);
115
- }
116
- async function loadFont(font, weight) {
117
- try {
118
- await (0, engine_1.safeDocument)().fonts.load(`${weight ?? "400"} 36px '${font ?? "Verdana"}'`);
119
- }
120
- catch {
121
- }
122
- }
123
- });
package/umd/index.js DELETED
@@ -1,27 +0,0 @@
1
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2
- if (k2 === undefined) k2 = k;
3
- var desc = Object.getOwnPropertyDescriptor(m, k);
4
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
5
- desc = { enumerable: true, get: function() { return m[k]; } };
6
- }
7
- Object.defineProperty(o, k2, desc);
8
- }) : (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- o[k2] = m[k];
11
- }));
12
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
13
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
14
- };
15
- (function (factory) {
16
- if (typeof module === "object" && typeof module.exports === "object") {
17
- var v = factory(require, exports);
18
- if (v !== undefined) module.exports = v;
19
- }
20
- else if (typeof define === "function" && define.amd) {
21
- define(["require", "exports", "./Utils.js"], factory);
22
- }
23
- })(function (require, exports) {
24
- "use strict";
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- __exportStar(require("./Utils.js"), exports);
27
- });
package/umd/types.js DELETED
@@ -1,12 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- });