@tsparticles/canvas-utils 4.0.0-beta.0 → 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 +17 -0
- package/browser/Utils.js +9 -9
- package/cjs/Utils.js +9 -9
- package/esm/Utils.js +9 -9
- package/package.json +4 -5
- package/report.html +84 -29
- package/tsparticles.canvas.utils.js +2 -2
- package/tsparticles.canvas.utils.min.js +1 -1
- package/types/Utils.d.ts +3 -3
- package/umd/Utils.js +0 -123
- package/umd/index.js +0 -27
- package/umd/types.js +0 -12
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/browser/Utils.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import { defaultAlpha, defaultRgbMin, isNumber, originPoint, safeDocument, } from "@tsparticles/engine";
|
|
2
|
-
const defaultWidth = 0
|
|
1
|
+
import { defaultAlpha, defaultRgbMin, identity, isNumber, originPoint, safeDocument, } from "@tsparticles/engine";
|
|
2
|
+
const defaultWidth = 0, indexesOffset = {
|
|
3
|
+
r: 0,
|
|
4
|
+
g: 1,
|
|
5
|
+
b: 2,
|
|
6
|
+
a: 3,
|
|
7
|
+
}, alphaMax = 255, alphaFactor = identity / alphaMax;
|
|
3
8
|
export function drawLine(context, begin, end) {
|
|
4
9
|
context.beginPath();
|
|
5
10
|
context.moveTo(begin.x, begin.y);
|
|
@@ -18,12 +23,7 @@ export function getCanvasImageData(ctx, size, offset, clear = true) {
|
|
|
18
23
|
y: Math.floor(idx / size.width),
|
|
19
24
|
};
|
|
20
25
|
pixels[pos.y] ??= [];
|
|
21
|
-
const
|
|
22
|
-
r: 0,
|
|
23
|
-
g: 1,
|
|
24
|
-
b: 2,
|
|
25
|
-
a: 3,
|
|
26
|
-
}, alphaFactor = 255, row = pixels[pos.y];
|
|
26
|
+
const row = pixels[pos.y];
|
|
27
27
|
if (!row) {
|
|
28
28
|
continue;
|
|
29
29
|
}
|
|
@@ -31,7 +31,7 @@ export function getCanvasImageData(ctx, size, offset, clear = true) {
|
|
|
31
31
|
r: imageData[i + indexesOffset.r] ?? defaultRgbMin,
|
|
32
32
|
g: imageData[i + indexesOffset.g] ?? defaultRgbMin,
|
|
33
33
|
b: imageData[i + indexesOffset.b] ?? defaultRgbMin,
|
|
34
|
-
a: (imageData[i + indexesOffset.a] ?? defaultAlpha)
|
|
34
|
+
a: (imageData[i + indexesOffset.a] ?? defaultAlpha) * alphaFactor,
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
return {
|
package/cjs/Utils.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import { defaultAlpha, defaultRgbMin, isNumber, originPoint, safeDocument, } from "@tsparticles/engine";
|
|
2
|
-
const defaultWidth = 0
|
|
1
|
+
import { defaultAlpha, defaultRgbMin, identity, isNumber, originPoint, safeDocument, } from "@tsparticles/engine";
|
|
2
|
+
const defaultWidth = 0, indexesOffset = {
|
|
3
|
+
r: 0,
|
|
4
|
+
g: 1,
|
|
5
|
+
b: 2,
|
|
6
|
+
a: 3,
|
|
7
|
+
}, alphaMax = 255, alphaFactor = identity / alphaMax;
|
|
3
8
|
export function drawLine(context, begin, end) {
|
|
4
9
|
context.beginPath();
|
|
5
10
|
context.moveTo(begin.x, begin.y);
|
|
@@ -18,12 +23,7 @@ export function getCanvasImageData(ctx, size, offset, clear = true) {
|
|
|
18
23
|
y: Math.floor(idx / size.width),
|
|
19
24
|
};
|
|
20
25
|
pixels[pos.y] ??= [];
|
|
21
|
-
const
|
|
22
|
-
r: 0,
|
|
23
|
-
g: 1,
|
|
24
|
-
b: 2,
|
|
25
|
-
a: 3,
|
|
26
|
-
}, alphaFactor = 255, row = pixels[pos.y];
|
|
26
|
+
const row = pixels[pos.y];
|
|
27
27
|
if (!row) {
|
|
28
28
|
continue;
|
|
29
29
|
}
|
|
@@ -31,7 +31,7 @@ export function getCanvasImageData(ctx, size, offset, clear = true) {
|
|
|
31
31
|
r: imageData[i + indexesOffset.r] ?? defaultRgbMin,
|
|
32
32
|
g: imageData[i + indexesOffset.g] ?? defaultRgbMin,
|
|
33
33
|
b: imageData[i + indexesOffset.b] ?? defaultRgbMin,
|
|
34
|
-
a: (imageData[i + indexesOffset.a] ?? defaultAlpha)
|
|
34
|
+
a: (imageData[i + indexesOffset.a] ?? defaultAlpha) * alphaFactor,
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
return {
|
package/esm/Utils.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import { defaultAlpha, defaultRgbMin, isNumber, originPoint, safeDocument, } from "@tsparticles/engine";
|
|
2
|
-
const defaultWidth = 0
|
|
1
|
+
import { defaultAlpha, defaultRgbMin, identity, isNumber, originPoint, safeDocument, } from "@tsparticles/engine";
|
|
2
|
+
const defaultWidth = 0, indexesOffset = {
|
|
3
|
+
r: 0,
|
|
4
|
+
g: 1,
|
|
5
|
+
b: 2,
|
|
6
|
+
a: 3,
|
|
7
|
+
}, alphaMax = 255, alphaFactor = identity / alphaMax;
|
|
3
8
|
export function drawLine(context, begin, end) {
|
|
4
9
|
context.beginPath();
|
|
5
10
|
context.moveTo(begin.x, begin.y);
|
|
@@ -18,12 +23,7 @@ export function getCanvasImageData(ctx, size, offset, clear = true) {
|
|
|
18
23
|
y: Math.floor(idx / size.width),
|
|
19
24
|
};
|
|
20
25
|
pixels[pos.y] ??= [];
|
|
21
|
-
const
|
|
22
|
-
r: 0,
|
|
23
|
-
g: 1,
|
|
24
|
-
b: 2,
|
|
25
|
-
a: 3,
|
|
26
|
-
}, alphaFactor = 255, row = pixels[pos.y];
|
|
26
|
+
const row = pixels[pos.y];
|
|
27
27
|
if (!row) {
|
|
28
28
|
continue;
|
|
29
29
|
}
|
|
@@ -31,7 +31,7 @@ export function getCanvasImageData(ctx, size, offset, clear = true) {
|
|
|
31
31
|
r: imageData[i + indexesOffset.r] ?? defaultRgbMin,
|
|
32
32
|
g: imageData[i + indexesOffset.g] ?? defaultRgbMin,
|
|
33
33
|
b: imageData[i + indexesOffset.b] ?? defaultRgbMin,
|
|
34
|
-
a: (imageData[i + indexesOffset.a] ?? defaultAlpha)
|
|
34
|
+
a: (imageData[i + indexesOffset.a] ?? defaultAlpha) * alphaFactor,
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/canvas-utils",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
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
|
-
"
|
|
101
|
-
"default": "./cjs/index.js"
|
|
100
|
+
"default": "./esm/index.js"
|
|
102
101
|
},
|
|
103
102
|
"./package.json": "./package.json"
|
|
104
103
|
},
|
|
105
|
-
"
|
|
106
|
-
"@tsparticles/engine": "4.0.0-beta.
|
|
104
|
+
"peerDependencies": {
|
|
105
|
+
"@tsparticles/engine": "4.0.0-beta.10"
|
|
107
106
|
},
|
|
108
107
|
"type": "module"
|
|
109
108
|
}
|