@tsparticles/engine 3.7.0 → 3.8.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/browser/Core/Canvas.js +51 -36
- package/browser/Core/Container.js +10 -13
- package/browser/Core/Engine.js +15 -11
- package/browser/Core/Particle.js +8 -11
- package/browser/Core/Particles.js +10 -14
- package/browser/Core/Retina.js +1 -1
- package/browser/Core/Utils/Constants.js +10 -16
- package/browser/Core/Utils/EventListeners.js +5 -8
- package/browser/Core/Utils/QuadTree.js +1 -1
- package/browser/Core/Utils/Ranges.js +1 -1
- package/browser/Core/Utils/Vectors.js +10 -15
- package/browser/Options/Classes/ManualParticle.js +3 -3
- package/browser/Utils/CanvasUtils.js +8 -14
- package/browser/Utils/ColorUtils.js +12 -17
- package/browser/Utils/EventDispatcher.js +2 -2
- package/browser/Utils/NumberUtils.js +2 -4
- package/browser/Utils/Utils.js +58 -9
- package/cjs/Core/Canvas.js +52 -37
- package/cjs/Core/Container.js +14 -17
- package/cjs/Core/Engine.js +21 -17
- package/cjs/Core/Particle.js +18 -21
- package/cjs/Core/Particles.js +22 -26
- package/cjs/Core/Retina.js +5 -5
- package/cjs/Core/Utils/Constants.js +12 -17
- package/cjs/Core/Utils/EventListeners.js +8 -11
- package/cjs/Core/Utils/QuadTree.js +4 -4
- package/cjs/Core/Utils/Ranges.js +4 -4
- package/cjs/Core/Utils/Vectors.js +11 -16
- package/cjs/Options/Classes/ManualParticle.js +3 -3
- package/cjs/Utils/CanvasUtils.js +14 -20
- package/cjs/Utils/ColorUtils.js +47 -52
- package/cjs/Utils/EventDispatcher.js +5 -5
- package/cjs/Utils/NumberUtils.js +11 -13
- package/cjs/Utils/Utils.js +60 -10
- package/esm/Core/Canvas.js +51 -36
- package/esm/Core/Container.js +10 -13
- package/esm/Core/Engine.js +15 -11
- package/esm/Core/Particle.js +8 -11
- package/esm/Core/Particles.js +10 -14
- package/esm/Core/Retina.js +1 -1
- package/esm/Core/Utils/Constants.js +10 -16
- package/esm/Core/Utils/EventListeners.js +5 -8
- package/esm/Core/Utils/QuadTree.js +1 -1
- package/esm/Core/Utils/Ranges.js +1 -1
- package/esm/Core/Utils/Vectors.js +10 -15
- package/esm/Options/Classes/ManualParticle.js +3 -3
- package/esm/Utils/CanvasUtils.js +8 -14
- package/esm/Utils/ColorUtils.js +12 -17
- package/esm/Utils/EventDispatcher.js +2 -2
- package/esm/Utils/NumberUtils.js +2 -4
- package/esm/Utils/Utils.js +58 -9
- package/package.json +1 -1
- package/report.html +1 -1
- package/tsparticles.engine.js +20 -20
- package/tsparticles.engine.min.js +1 -1
- package/tsparticles.engine.min.js.LICENSE.txt +1 -1
- package/types/Core/Canvas.d.ts +1 -1
- package/types/Core/Engine.d.ts +5 -4
- package/types/Core/Utils/Constants.d.ts +7 -16
- package/types/Utils/ColorUtils.d.ts +1 -1
- package/types/Utils/Utils.d.ts +2 -2
- package/umd/Core/Canvas.js +53 -38
- package/umd/Core/Container.js +14 -17
- package/umd/Core/Engine.js +21 -17
- package/umd/Core/Particle.js +19 -22
- package/umd/Core/Particles.js +23 -27
- package/umd/Core/Retina.js +6 -6
- package/umd/Core/Utils/Constants.js +11 -17
- package/umd/Core/Utils/EventListeners.js +9 -12
- package/umd/Core/Utils/QuadTree.js +5 -5
- package/umd/Core/Utils/Ranges.js +5 -5
- package/umd/Core/Utils/Vectors.js +11 -16
- package/umd/Options/Classes/ManualParticle.js +4 -4
- package/umd/Utils/CanvasUtils.js +15 -21
- package/umd/Utils/ColorUtils.js +48 -53
- package/umd/Utils/EventDispatcher.js +6 -6
- package/umd/Utils/NumberUtils.js +12 -14
- package/umd/Utils/Utils.js +60 -10
package/umd/Core/Retina.js
CHANGED
|
@@ -4,25 +4,25 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "../Utils/NumberUtils.js", "../Utils/Utils.js"], factory);
|
|
7
|
+
define(["require", "exports", "./Utils/Constants.js", "../Utils/NumberUtils.js", "../Utils/Utils.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.Retina = void 0;
|
|
13
|
+
const Constants_js_1 = require("./Utils/Constants.js");
|
|
13
14
|
const NumberUtils_js_1 = require("../Utils/NumberUtils.js");
|
|
14
15
|
const Utils_js_1 = require("../Utils/Utils.js");
|
|
15
|
-
const defaultRatio = 1, defaultReduceFactor = 1;
|
|
16
16
|
class Retina {
|
|
17
17
|
constructor(container) {
|
|
18
18
|
this.container = container;
|
|
19
|
-
this.pixelRatio = defaultRatio;
|
|
20
|
-
this.reduceFactor = defaultReduceFactor;
|
|
19
|
+
this.pixelRatio = Constants_js_1.defaultRatio;
|
|
20
|
+
this.reduceFactor = Constants_js_1.defaultReduceFactor;
|
|
21
21
|
}
|
|
22
22
|
init() {
|
|
23
23
|
const container = this.container, options = container.actualOptions;
|
|
24
|
-
this.pixelRatio = !options.detectRetina || (0, Utils_js_1.isSsr)() ? defaultRatio : window.devicePixelRatio;
|
|
25
|
-
this.reduceFactor = defaultReduceFactor;
|
|
24
|
+
this.pixelRatio = !options.detectRetina || (0, Utils_js_1.isSsr)() ? Constants_js_1.defaultRatio : window.devicePixelRatio;
|
|
25
|
+
this.reduceFactor = Constants_js_1.defaultReduceFactor;
|
|
26
26
|
const ratio = this.pixelRatio, canvas = container.canvas;
|
|
27
27
|
if (canvas.element) {
|
|
28
28
|
const element = canvas.element;
|
|
@@ -9,21 +9,15 @@
|
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.millisecondsToSeconds = exports.
|
|
13
|
-
exports.generatedAttribute = "generated"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
exports.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
exports.
|
|
23
|
-
exports.resizeEvent = "resize";
|
|
24
|
-
exports.visibilityChangeEvent = "visibilitychange";
|
|
25
|
-
exports.errorPrefix = "tsParticles - Error";
|
|
26
|
-
exports.percentDenominator = 100;
|
|
27
|
-
exports.halfRandom = 0.5;
|
|
28
|
-
exports.millisecondsToSeconds = 1000;
|
|
12
|
+
exports.defaultTime = exports.defaultLoops = exports.defaultVelocity = exports.defaultRgbMin = exports.phaseNumerator = exports.sNormalizedOffset = exports.sextuple = exports.triple = exports.rgbFactor = exports.lMin = exports.lFactor = exports.minStrokeWidth = exports.identity = exports.defaultAngle = exports.manualDefaultPosition = exports.touchDelay = exports.deleteCount = exports.defaultDensityFactor = exports.lengthOffset = exports.manualCount = exports.minIndex = exports.minCount = exports.countOffset = exports.minLimit = exports.sizeFactor = exports.posOffset = exports.defaultRadius = exports.minZ = exports.rollFactor = exports.minRetries = exports.tryCountIncrement = exports.decayOffset = exports.none = exports.one = exports.loadMinIndex = exports.loadRandomFactor = exports.canvasFirstIndex = exports.minFpsLimit = exports.defaultFpsLimit = exports.removeMinIndex = exports.removeDeleteCount = exports.minCoordinate = exports.touchEndLengthOffset = exports.clickRadius = exports.defaultOpacity = exports.zIndexFactorOffset = exports.minimumLength = exports.minimumSize = exports.defaultTransformValue = exports.minVelocity = exports.threeQuarter = exports.quarter = exports.empty = exports.hPhase = exports.sMin = exports.hMin = exports.lMax = exports.sMax = exports.hMax = exports.rgbMax = exports.inverseFactorNumerator = exports.subdivideCount = exports.defaultReduceFactor = exports.defaultRatio = exports.defaultRemoveQuantity = exports.qTreeCapacity = exports.squareExp = exports.defaultRetryCount = exports.canvasTag = exports.generatedFalse = exports.generatedTrue = exports.defaultAlpha = exports.defaultFps = exports.doublePI = exports.double = exports.midColorValue = exports.randomColorValue = exports.defaultTransform = exports.originPoint = exports.millisecondsToSeconds = exports.half = exports.percentDenominator = exports.errorPrefix = exports.visibilityChangeEvent = exports.resizeEvent = exports.touchCancelEvent = exports.touchMoveEvent = exports.touchEndEvent = exports.touchStartEvent = exports.mouseMoveEvent = exports.mouseOutEvent = exports.mouseLeaveEvent = exports.mouseUpEvent = exports.mouseDownEvent = exports.generatedAttribute = void 0;
|
|
13
|
+
exports.generatedAttribute = "generated", exports.mouseDownEvent = "pointerdown", exports.mouseUpEvent = "pointerup", exports.mouseLeaveEvent = "pointerleave", exports.mouseOutEvent = "pointerout", exports.mouseMoveEvent = "pointermove", exports.touchStartEvent = "touchstart", exports.touchEndEvent = "touchend", exports.touchMoveEvent = "touchmove", exports.touchCancelEvent = "touchcancel", exports.resizeEvent = "resize", exports.visibilityChangeEvent = "visibilitychange", exports.errorPrefix = "tsParticles - Error", exports.percentDenominator = 100, exports.half = 0.5, exports.millisecondsToSeconds = 1000, exports.originPoint = {
|
|
14
|
+
x: 0,
|
|
15
|
+
y: 0,
|
|
16
|
+
z: 0,
|
|
17
|
+
}, exports.defaultTransform = {
|
|
18
|
+
a: 1,
|
|
19
|
+
b: 0,
|
|
20
|
+
c: 0,
|
|
21
|
+
d: 1,
|
|
22
|
+
}, exports.randomColorValue = "random", exports.midColorValue = "mid", exports.double = 2, exports.doublePI = Math.PI * exports.double, exports.defaultFps = 60, exports.defaultAlpha = 1, exports.generatedTrue = "true", exports.generatedFalse = "false", exports.canvasTag = "canvas", exports.defaultRetryCount = 0, exports.squareExp = 2, exports.qTreeCapacity = 4, exports.defaultRemoveQuantity = 1, exports.defaultRatio = 1, exports.defaultReduceFactor = 1, exports.subdivideCount = 4, exports.inverseFactorNumerator = 1.0, exports.rgbMax = 255, exports.hMax = 360, exports.sMax = 100, exports.lMax = 100, exports.hMin = 0, exports.sMin = 0, exports.hPhase = 60, exports.empty = 0, exports.quarter = 0.25, exports.threeQuarter = exports.half + exports.quarter, exports.minVelocity = 0, exports.defaultTransformValue = 1, exports.minimumSize = 0, exports.minimumLength = 0, exports.zIndexFactorOffset = 1, exports.defaultOpacity = 1, exports.clickRadius = 1, exports.touchEndLengthOffset = 1, exports.minCoordinate = 0, exports.removeDeleteCount = 1, exports.removeMinIndex = 0, exports.defaultFpsLimit = 120, exports.minFpsLimit = 0, exports.canvasFirstIndex = 0, exports.loadRandomFactor = 10000, exports.loadMinIndex = 0, exports.one = 1, exports.none = 0, exports.decayOffset = 1, exports.tryCountIncrement = 1, exports.minRetries = 0, exports.rollFactor = 1, exports.minZ = 0, exports.defaultRadius = 0, exports.posOffset = -exports.quarter, exports.sizeFactor = 1.5, exports.minLimit = 0, exports.countOffset = 1, exports.minCount = 0, exports.minIndex = 0, exports.manualCount = 0, exports.lengthOffset = 1, exports.defaultDensityFactor = 1, exports.deleteCount = 1, exports.touchDelay = 500, exports.manualDefaultPosition = 50, exports.defaultAngle = 0, exports.identity = 1, exports.minStrokeWidth = 0, exports.lFactor = 1, exports.lMin = 0, exports.rgbFactor = 255, exports.triple = 3, exports.sextuple = 6, exports.sNormalizedOffset = 1, exports.phaseNumerator = 1, exports.defaultRgbMin = 0, exports.defaultVelocity = 0, exports.defaultLoops = 0, exports.defaultTime = 0;
|
|
29
23
|
});
|
|
@@ -4,17 +4,16 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "
|
|
7
|
+
define(["require", "exports", "./Constants.js", "../../Utils/Utils.js", "../../Enums/InteractivityDetect.js", "../../Utils/TypeUtils.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.EventListeners = void 0;
|
|
13
|
-
const Utils_js_1 = require("../../Utils/Utils.js");
|
|
14
13
|
const Constants_js_1 = require("./Constants.js");
|
|
14
|
+
const Utils_js_1 = require("../../Utils/Utils.js");
|
|
15
15
|
const InteractivityDetect_js_1 = require("../../Enums/InteractivityDetect.js");
|
|
16
16
|
const TypeUtils_js_1 = require("../../Utils/TypeUtils.js");
|
|
17
|
-
const double = 2;
|
|
18
17
|
function manageListener(element, event, handler, add, options) {
|
|
19
18
|
if (add) {
|
|
20
19
|
let addOptions = { passive: true };
|
|
@@ -47,8 +46,7 @@
|
|
|
47
46
|
(0, Utils_js_1.executeOnSingleOrMultiple)(onClick.mode, mode => this.container.handleClickMode(mode));
|
|
48
47
|
}
|
|
49
48
|
if (e.type === "touchend") {
|
|
50
|
-
|
|
51
|
-
setTimeout(() => this._mouseTouchFinish(), touchDelay);
|
|
49
|
+
setTimeout(() => this._mouseTouchFinish(), Constants_js_1.touchDelay);
|
|
52
50
|
}
|
|
53
51
|
};
|
|
54
52
|
this._handleThemeChange = (e) => {
|
|
@@ -89,8 +87,7 @@
|
|
|
89
87
|
this._resizeTimeout = setTimeout(() => void handleResize(), this.container.actualOptions.interactivity.events.resize.delay * Constants_js_1.millisecondsToSeconds);
|
|
90
88
|
};
|
|
91
89
|
this._manageInteractivityListeners = (mouseLeaveTmpEvent, add) => {
|
|
92
|
-
const handlers = this._handlers, container = this.container, options = container.actualOptions;
|
|
93
|
-
const interactivityEl = container.interactivity.element;
|
|
90
|
+
const handlers = this._handlers, container = this.container, options = container.actualOptions, interactivityEl = container.interactivity.element;
|
|
94
91
|
if (!interactivityEl) {
|
|
95
92
|
return;
|
|
96
93
|
}
|
|
@@ -250,8 +247,8 @@
|
|
|
250
247
|
if (source && target && canvasEl) {
|
|
251
248
|
const sourceRect = source.getBoundingClientRect(), targetRect = target.getBoundingClientRect(), canvasRect = canvasEl.getBoundingClientRect();
|
|
252
249
|
pos = {
|
|
253
|
-
x: mouseEvent.offsetX + double * sourceRect.left - (targetRect.left + canvasRect.left),
|
|
254
|
-
y: mouseEvent.offsetY + double * sourceRect.top - (targetRect.top + canvasRect.top),
|
|
250
|
+
x: mouseEvent.offsetX + Constants_js_1.double * sourceRect.left - (targetRect.left + canvasRect.left),
|
|
251
|
+
y: mouseEvent.offsetY + Constants_js_1.double * sourceRect.top - (targetRect.top + canvasRect.top),
|
|
255
252
|
};
|
|
256
253
|
}
|
|
257
254
|
else {
|
|
@@ -271,10 +268,10 @@
|
|
|
271
268
|
else {
|
|
272
269
|
this._canPush = e.type !== "touchmove";
|
|
273
270
|
if (canvasEl) {
|
|
274
|
-
const touchEvent = e,
|
|
271
|
+
const touchEvent = e, lastTouch = touchEvent.touches[touchEvent.touches.length - Constants_js_1.lengthOffset], canvasRect = canvasEl.getBoundingClientRect();
|
|
275
272
|
pos = {
|
|
276
|
-
x: lastTouch.clientX - (canvasRect.left ??
|
|
277
|
-
y: lastTouch.clientY - (canvasRect.top ??
|
|
273
|
+
x: lastTouch.clientX - (canvasRect.left ?? Constants_js_1.minCoordinate),
|
|
274
|
+
y: lastTouch.clientY - (canvasRect.top ?? Constants_js_1.minCoordinate),
|
|
278
275
|
};
|
|
279
276
|
}
|
|
280
277
|
}
|
|
@@ -4,24 +4,24 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "./Ranges.js", "../../Utils/NumberUtils.js"], factory);
|
|
7
|
+
define(["require", "exports", "./Ranges.js", "./Constants.js", "../../Utils/NumberUtils.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.QuadTree = void 0;
|
|
13
13
|
const Ranges_js_1 = require("./Ranges.js");
|
|
14
|
+
const Constants_js_1 = require("./Constants.js");
|
|
14
15
|
const NumberUtils_js_1 = require("../../Utils/NumberUtils.js");
|
|
15
|
-
const half = 0.5, double = 2, subdivideCount = 4;
|
|
16
16
|
class QuadTree {
|
|
17
17
|
constructor(rectangle, capacity) {
|
|
18
18
|
this.rectangle = rectangle;
|
|
19
19
|
this.capacity = capacity;
|
|
20
20
|
this._subdivide = () => {
|
|
21
21
|
const { x, y } = this.rectangle.position, { width, height } = this.rectangle.size, { capacity } = this;
|
|
22
|
-
for (let i = 0; i < subdivideCount; i++) {
|
|
23
|
-
const fixedIndex = i % double;
|
|
24
|
-
this._subs.push(new QuadTree(new Ranges_js_1.Rectangle(x + width * half * fixedIndex, y + height * half * (Math.round(i * half) - fixedIndex), width * half, height * half), capacity));
|
|
22
|
+
for (let i = 0; i < Constants_js_1.subdivideCount; i++) {
|
|
23
|
+
const fixedIndex = i % Constants_js_1.double;
|
|
24
|
+
this._subs.push(new QuadTree(new Ranges_js_1.Rectangle(x + width * Constants_js_1.half * fixedIndex, y + height * Constants_js_1.half * (Math.round(i * Constants_js_1.half) - fixedIndex), width * Constants_js_1.half, height * Constants_js_1.half), capacity));
|
|
25
25
|
}
|
|
26
26
|
this._divided = true;
|
|
27
27
|
};
|
package/umd/Core/Utils/Ranges.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "../../Types/RangeType.js", "../../Utils/NumberUtils.js"], factory);
|
|
7
|
+
define(["require", "exports", "../../Types/RangeType.js", "../../Utils/NumberUtils.js", "./Constants.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
exports.Rectangle = exports.Circle = exports.BaseRange = void 0;
|
|
13
13
|
const RangeType_js_1 = require("../../Types/RangeType.js");
|
|
14
14
|
const NumberUtils_js_1 = require("../../Utils/NumberUtils.js");
|
|
15
|
-
const
|
|
15
|
+
const Constants_js_1 = require("./Constants.js");
|
|
16
16
|
class BaseRange {
|
|
17
17
|
constructor(x, y, type) {
|
|
18
18
|
this.position = {
|
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
intersects(range) {
|
|
35
35
|
const pos1 = this.position, pos2 = range.position, distPos = { x: Math.abs(pos2.x - pos1.x), y: Math.abs(pos2.y - pos1.y) }, r = this.radius;
|
|
36
36
|
if (range instanceof Circle || range.type === RangeType_js_1.RangeType.circle) {
|
|
37
|
-
const circleRange = range, rSum = r + circleRange.radius, dist = Math.sqrt(distPos.x ** squareExp + distPos.y ** squareExp);
|
|
37
|
+
const circleRange = range, rSum = r + circleRange.radius, dist = Math.sqrt(distPos.x ** Constants_js_1.squareExp + distPos.y ** Constants_js_1.squareExp);
|
|
38
38
|
return rSum > dist;
|
|
39
39
|
}
|
|
40
40
|
else if (range instanceof Rectangle || range.type === RangeType_js_1.RangeType.rectangle) {
|
|
41
|
-
const rectRange = range, { width, height } = rectRange.size, edges = Math.pow(distPos.x - width, squareExp) + Math.pow(distPos.y - height, squareExp);
|
|
42
|
-
return (edges <= r ** squareExp ||
|
|
41
|
+
const rectRange = range, { width, height } = rectRange.size, edges = Math.pow(distPos.x - width, Constants_js_1.squareExp) + Math.pow(distPos.y - height, Constants_js_1.squareExp);
|
|
42
|
+
return (edges <= r ** Constants_js_1.squareExp ||
|
|
43
43
|
(distPos.x <= r + width && distPos.y <= r + height) ||
|
|
44
44
|
distPos.x <= width ||
|
|
45
45
|
distPos.y <= height);
|
|
@@ -12,11 +12,6 @@
|
|
|
12
12
|
exports.Vector = exports.Vector3d = void 0;
|
|
13
13
|
const Constants_js_1 = require("./Constants.js");
|
|
14
14
|
const TypeUtils_js_1 = require("../../Utils/TypeUtils.js");
|
|
15
|
-
const origin = {
|
|
16
|
-
x: 0,
|
|
17
|
-
y: 0,
|
|
18
|
-
z: 0,
|
|
19
|
-
}, squareExp = 2, inverseFactorNumerator = 1.0;
|
|
20
15
|
class Vector3d {
|
|
21
16
|
constructor(xOrCoords, y, z) {
|
|
22
17
|
this._updateFromAngle = (angle, length) => {
|
|
@@ -27,19 +22,19 @@
|
|
|
27
22
|
this.x = xOrCoords.x;
|
|
28
23
|
this.y = xOrCoords.y;
|
|
29
24
|
const coords3d = xOrCoords;
|
|
30
|
-
this.z = coords3d.z ? coords3d.z :
|
|
25
|
+
this.z = coords3d.z ? coords3d.z : Constants_js_1.originPoint.z;
|
|
31
26
|
}
|
|
32
27
|
else if (xOrCoords !== undefined && y !== undefined) {
|
|
33
28
|
this.x = xOrCoords;
|
|
34
29
|
this.y = y;
|
|
35
|
-
this.z = z ??
|
|
30
|
+
this.z = z ?? Constants_js_1.originPoint.z;
|
|
36
31
|
}
|
|
37
32
|
else {
|
|
38
33
|
throw new Error(`${Constants_js_1.errorPrefix} Vector3d not initialized correctly`);
|
|
39
34
|
}
|
|
40
35
|
}
|
|
41
36
|
static get origin() {
|
|
42
|
-
return Vector3d.create(
|
|
37
|
+
return Vector3d.create(Constants_js_1.originPoint.x, Constants_js_1.originPoint.y, Constants_js_1.originPoint.z);
|
|
43
38
|
}
|
|
44
39
|
get angle() {
|
|
45
40
|
return Math.atan2(this.y, this.x);
|
|
@@ -85,7 +80,7 @@
|
|
|
85
80
|
this.z /= n;
|
|
86
81
|
}
|
|
87
82
|
getLengthSq() {
|
|
88
|
-
return this.x ** squareExp + this.y ** squareExp;
|
|
83
|
+
return this.x ** Constants_js_1.squareExp + this.y ** Constants_js_1.squareExp;
|
|
89
84
|
}
|
|
90
85
|
mult(n) {
|
|
91
86
|
return Vector3d.create(this.x * n, this.y * n, this.z * n);
|
|
@@ -96,19 +91,19 @@
|
|
|
96
91
|
this.z *= n;
|
|
97
92
|
}
|
|
98
93
|
normalize() {
|
|
99
|
-
const length = this.length
|
|
100
|
-
if (length !=
|
|
101
|
-
this.multTo(inverseFactorNumerator / length);
|
|
94
|
+
const length = this.length;
|
|
95
|
+
if (length != Constants_js_1.none) {
|
|
96
|
+
this.multTo(Constants_js_1.inverseFactorNumerator / length);
|
|
102
97
|
}
|
|
103
98
|
}
|
|
104
99
|
rotate(angle) {
|
|
105
|
-
return Vector3d.create(this.x * Math.cos(angle) - this.y * Math.sin(angle), this.x * Math.sin(angle) + this.y * Math.cos(angle),
|
|
100
|
+
return Vector3d.create(this.x * Math.cos(angle) - this.y * Math.sin(angle), this.x * Math.sin(angle) + this.y * Math.cos(angle), Constants_js_1.originPoint.z);
|
|
106
101
|
}
|
|
107
102
|
setTo(c) {
|
|
108
103
|
this.x = c.x;
|
|
109
104
|
this.y = c.y;
|
|
110
105
|
const v3d = c;
|
|
111
|
-
this.z = v3d.z ? v3d.z :
|
|
106
|
+
this.z = v3d.z ? v3d.z : Constants_js_1.originPoint.z;
|
|
112
107
|
}
|
|
113
108
|
sub(v) {
|
|
114
109
|
return Vector3d.create(this.x - v.x, this.y - v.y, this.z - v.z);
|
|
@@ -122,10 +117,10 @@
|
|
|
122
117
|
exports.Vector3d = Vector3d;
|
|
123
118
|
class Vector extends Vector3d {
|
|
124
119
|
constructor(xOrCoords, y) {
|
|
125
|
-
super(xOrCoords, y,
|
|
120
|
+
super(xOrCoords, y, Constants_js_1.originPoint.z);
|
|
126
121
|
}
|
|
127
122
|
static get origin() {
|
|
128
|
-
return Vector.create(
|
|
123
|
+
return Vector.create(Constants_js_1.originPoint.x, Constants_js_1.originPoint.y);
|
|
129
124
|
}
|
|
130
125
|
static clone(source) {
|
|
131
126
|
return Vector.create(source.x, source.y);
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "../../Enums/Modes/PixelMode.js", "../../Utils/Utils.js", "../../Utils/TypeUtils.js"], factory);
|
|
7
|
+
define(["require", "exports", "../../Enums/Modes/PixelMode.js", "../../Utils/Utils.js", "../../Utils/TypeUtils.js", "../../Core/Utils/Constants.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
const PixelMode_js_1 = require("../../Enums/Modes/PixelMode.js");
|
|
14
14
|
const Utils_js_1 = require("../../Utils/Utils.js");
|
|
15
15
|
const TypeUtils_js_1 = require("../../Utils/TypeUtils.js");
|
|
16
|
-
const
|
|
16
|
+
const Constants_js_1 = require("../../Core/Utils/Constants.js");
|
|
17
17
|
class ManualParticle {
|
|
18
18
|
load(data) {
|
|
19
19
|
if ((0, TypeUtils_js_1.isNull)(data)) {
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
}
|
|
22
22
|
if (data.position) {
|
|
23
23
|
this.position = {
|
|
24
|
-
x: data.position.x ??
|
|
25
|
-
y: data.position.y ??
|
|
24
|
+
x: data.position.x ?? Constants_js_1.manualDefaultPosition,
|
|
25
|
+
y: data.position.y ?? Constants_js_1.manualDefaultPosition,
|
|
26
26
|
mode: data.position.mode ?? PixelMode_js_1.PixelMode.percent,
|
|
27
27
|
};
|
|
28
28
|
}
|
package/umd/Utils/CanvasUtils.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "../Enums/Types/AlterType.js", "./ColorUtils.js"], factory);
|
|
7
|
+
define(["require", "exports", "../Core/Utils/Constants.js", "../Enums/Types/AlterType.js", "./ColorUtils.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
@@ -20,14 +20,9 @@
|
|
|
20
20
|
exports.drawPlugin = drawPlugin;
|
|
21
21
|
exports.drawParticlePlugin = drawParticlePlugin;
|
|
22
22
|
exports.alterHsl = alterHsl;
|
|
23
|
+
const Constants_js_1 = require("../Core/Utils/Constants.js");
|
|
23
24
|
const AlterType_js_1 = require("../Enums/Types/AlterType.js");
|
|
24
25
|
const ColorUtils_js_1 = require("./ColorUtils.js");
|
|
25
|
-
const origin = { x: 0, y: 0 }, defaultTransform = {
|
|
26
|
-
a: 1,
|
|
27
|
-
b: 0,
|
|
28
|
-
c: 0,
|
|
29
|
-
d: 1,
|
|
30
|
-
};
|
|
31
26
|
function drawLine(context, begin, end) {
|
|
32
27
|
context.beginPath();
|
|
33
28
|
context.moveTo(begin.x, begin.y);
|
|
@@ -36,28 +31,28 @@
|
|
|
36
31
|
}
|
|
37
32
|
function paintBase(context, dimension, baseColor) {
|
|
38
33
|
context.fillStyle = baseColor ?? "rgba(0,0,0,0)";
|
|
39
|
-
context.fillRect(
|
|
34
|
+
context.fillRect(Constants_js_1.originPoint.x, Constants_js_1.originPoint.y, dimension.width, dimension.height);
|
|
40
35
|
}
|
|
41
36
|
function paintImage(context, dimension, image, opacity) {
|
|
42
37
|
if (!image) {
|
|
43
38
|
return;
|
|
44
39
|
}
|
|
45
40
|
context.globalAlpha = opacity;
|
|
46
|
-
context.drawImage(image,
|
|
41
|
+
context.drawImage(image, Constants_js_1.originPoint.x, Constants_js_1.originPoint.y, dimension.width, dimension.height);
|
|
47
42
|
context.globalAlpha = 1;
|
|
48
43
|
}
|
|
49
44
|
function clear(context, dimension) {
|
|
50
|
-
context.clearRect(
|
|
45
|
+
context.clearRect(Constants_js_1.originPoint.x, Constants_js_1.originPoint.y, dimension.width, dimension.height);
|
|
51
46
|
}
|
|
52
47
|
function drawParticle(data) {
|
|
53
|
-
const { container, context, particle, delta, colorStyles, backgroundMask, composite, radius, opacity, shadow, transform, } = data, pos = particle.getPosition(),
|
|
48
|
+
const { container, context, particle, delta, colorStyles, backgroundMask, composite, radius, opacity, shadow, transform, } = data, pos = particle.getPosition(), angle = particle.rotation + (particle.pathRotation ? particle.velocity.angle : Constants_js_1.defaultAngle), rotateData = {
|
|
54
49
|
sin: Math.sin(angle),
|
|
55
50
|
cos: Math.cos(angle),
|
|
56
|
-
}, rotating = !!angle,
|
|
57
|
-
a: rotateData.cos * (transform.a ?? defaultTransform.a),
|
|
58
|
-
b: rotating ? rotateData.sin * (transform.b ?? identity) : (transform.b ?? defaultTransform.b),
|
|
59
|
-
c: rotating ? -rotateData.sin * (transform.c ?? identity) : (transform.c ?? defaultTransform.c),
|
|
60
|
-
d: rotateData.cos * (transform.d ?? defaultTransform.d),
|
|
51
|
+
}, rotating = !!angle, transformData = {
|
|
52
|
+
a: rotateData.cos * (transform.a ?? Constants_js_1.defaultTransform.a),
|
|
53
|
+
b: rotating ? rotateData.sin * (transform.b ?? Constants_js_1.identity) : (transform.b ?? Constants_js_1.defaultTransform.b),
|
|
54
|
+
c: rotating ? -rotateData.sin * (transform.c ?? Constants_js_1.identity) : (transform.c ?? Constants_js_1.defaultTransform.c),
|
|
55
|
+
d: rotateData.cos * (transform.d ?? Constants_js_1.defaultTransform.d),
|
|
61
56
|
};
|
|
62
57
|
context.setTransform(transformData.a, transformData.b, transformData.c, transformData.d, pos.x, pos.y);
|
|
63
58
|
if (backgroundMask) {
|
|
@@ -73,7 +68,7 @@
|
|
|
73
68
|
if (colorStyles.fill) {
|
|
74
69
|
context.fillStyle = colorStyles.fill;
|
|
75
70
|
}
|
|
76
|
-
const
|
|
71
|
+
const strokeWidth = particle.strokeWidth ?? Constants_js_1.minStrokeWidth;
|
|
77
72
|
context.lineWidth = strokeWidth;
|
|
78
73
|
if (colorStyles.stroke) {
|
|
79
74
|
context.strokeStyle = colorStyles.stroke;
|
|
@@ -114,7 +109,7 @@
|
|
|
114
109
|
});
|
|
115
110
|
}
|
|
116
111
|
function drawShape(data) {
|
|
117
|
-
const { container, context, particle, radius, opacity, delta, strokeWidth, transformData } = data
|
|
112
|
+
const { container, context, particle, radius, opacity, delta, strokeWidth, transformData } = data;
|
|
118
113
|
if (!particle.shape) {
|
|
119
114
|
return;
|
|
120
115
|
}
|
|
@@ -135,7 +130,7 @@
|
|
|
135
130
|
if (particle.shapeClose) {
|
|
136
131
|
context.closePath();
|
|
137
132
|
}
|
|
138
|
-
if (strokeWidth > minStrokeWidth) {
|
|
133
|
+
if (strokeWidth > Constants_js_1.minStrokeWidth) {
|
|
139
134
|
context.stroke();
|
|
140
135
|
}
|
|
141
136
|
if (particle.shapeFill) {
|
|
@@ -174,11 +169,10 @@
|
|
|
174
169
|
plugin.drawParticle(context, particle, delta);
|
|
175
170
|
}
|
|
176
171
|
function alterHsl(color, type, value) {
|
|
177
|
-
const lFactor = 1;
|
|
178
172
|
return {
|
|
179
173
|
h: color.h,
|
|
180
174
|
s: color.s,
|
|
181
|
-
l: color.l + (type === AlterType_js_1.AlterType.darken ? -lFactor : lFactor) * value,
|
|
175
|
+
l: color.l + (type === AlterType_js_1.AlterType.darken ? -Constants_js_1.lFactor : Constants_js_1.lFactor) * value,
|
|
182
176
|
};
|
|
183
177
|
}
|
|
184
178
|
});
|
package/umd/Utils/ColorUtils.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "./NumberUtils.js", "
|
|
7
|
+
define(["require", "exports", "./NumberUtils.js", "../Core/Utils/Constants.js", "./TypeUtils.js", "../Enums/AnimationStatus.js", "./Utils.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
@@ -29,11 +29,10 @@
|
|
|
29
29
|
exports.updateColorValue = updateColorValue;
|
|
30
30
|
exports.updateColor = updateColor;
|
|
31
31
|
const NumberUtils_js_1 = require("./NumberUtils.js");
|
|
32
|
-
const TypeUtils_js_1 = require("./TypeUtils.js");
|
|
33
32
|
const Constants_js_1 = require("../Core/Utils/Constants.js");
|
|
33
|
+
const TypeUtils_js_1 = require("./TypeUtils.js");
|
|
34
34
|
const AnimationStatus_js_1 = require("../Enums/AnimationStatus.js");
|
|
35
35
|
const Utils_js_1 = require("./Utils.js");
|
|
36
|
-
const randomColorValue = "random", midColorValue = "mid";
|
|
37
36
|
function stringToRgba(engine, input) {
|
|
38
37
|
if (!input) {
|
|
39
38
|
return;
|
|
@@ -70,7 +69,7 @@
|
|
|
70
69
|
}
|
|
71
70
|
const color = (0, TypeUtils_js_1.isString)(input) ? { value: input } : input;
|
|
72
71
|
if ((0, TypeUtils_js_1.isString)(color.value)) {
|
|
73
|
-
return color.value === randomColorValue ? getRandomRgbColor() : stringToRgb(engine, color.value);
|
|
72
|
+
return color.value === Constants_js_1.randomColorValue ? getRandomRgbColor() : stringToRgb(engine, color.value);
|
|
74
73
|
}
|
|
75
74
|
if ((0, TypeUtils_js_1.isArray)(color.value)) {
|
|
76
75
|
return colorToRgb(engine, {
|
|
@@ -93,26 +92,26 @@
|
|
|
93
92
|
return rgb ? rgbToHsl(rgb) : undefined;
|
|
94
93
|
}
|
|
95
94
|
function rgbToHsl(color) {
|
|
96
|
-
const
|
|
97
|
-
h: hMin,
|
|
98
|
-
l: (max + min) * half,
|
|
99
|
-
s: sMin,
|
|
95
|
+
const r1 = color.r / Constants_js_1.rgbMax, g1 = color.g / Constants_js_1.rgbMax, b1 = color.b / Constants_js_1.rgbMax, max = Math.max(r1, g1, b1), min = Math.min(r1, g1, b1), res = {
|
|
96
|
+
h: Constants_js_1.hMin,
|
|
97
|
+
l: (max + min) * Constants_js_1.half,
|
|
98
|
+
s: Constants_js_1.sMin,
|
|
100
99
|
};
|
|
101
100
|
if (max !== min) {
|
|
102
|
-
res.s = res.l < half ? (max - min) / (max + min) : (max - min) / (double - max - min);
|
|
101
|
+
res.s = res.l < Constants_js_1.half ? (max - min) / (max + min) : (max - min) / (Constants_js_1.double - max - min);
|
|
103
102
|
res.h =
|
|
104
103
|
r1 === max
|
|
105
104
|
? (g1 - b1) / (max - min)
|
|
106
|
-
: (res.h = g1 === max ? double + (b1 - r1) / (max - min) : double * double + (r1 - g1) / (max - min));
|
|
105
|
+
: (res.h = g1 === max ? Constants_js_1.double + (b1 - r1) / (max - min) : Constants_js_1.double * Constants_js_1.double + (r1 - g1) / (max - min));
|
|
107
106
|
}
|
|
108
|
-
res.l *= lMax;
|
|
109
|
-
res.s *= sMax;
|
|
110
|
-
res.h *= hPhase;
|
|
111
|
-
if (res.h < hMin) {
|
|
112
|
-
res.h += hMax;
|
|
107
|
+
res.l *= Constants_js_1.lMax;
|
|
108
|
+
res.s *= Constants_js_1.sMax;
|
|
109
|
+
res.h *= Constants_js_1.hPhase;
|
|
110
|
+
if (res.h < Constants_js_1.hMin) {
|
|
111
|
+
res.h += Constants_js_1.hMax;
|
|
113
112
|
}
|
|
114
|
-
if (res.h >= hMax) {
|
|
115
|
-
res.h -= hMax;
|
|
113
|
+
if (res.h >= Constants_js_1.hMax) {
|
|
114
|
+
res.h -= Constants_js_1.hMax;
|
|
116
115
|
}
|
|
117
116
|
return res;
|
|
118
117
|
}
|
|
@@ -123,33 +122,33 @@
|
|
|
123
122
|
return stringToRgba(engine, input);
|
|
124
123
|
}
|
|
125
124
|
function hslToRgb(hsl) {
|
|
126
|
-
const
|
|
127
|
-
if (s === sMin) {
|
|
128
|
-
const grayscaleValue = Math.round(lNormalized * rgbFactor);
|
|
125
|
+
const h = ((hsl.h % Constants_js_1.hMax) + Constants_js_1.hMax) % Constants_js_1.hMax, s = Math.max(Constants_js_1.sMin, Math.min(Constants_js_1.sMax, hsl.s)), l = Math.max(Constants_js_1.lMin, Math.min(Constants_js_1.lMax, hsl.l)), hNormalized = h / Constants_js_1.hMax, sNormalized = s / Constants_js_1.sMax, lNormalized = l / Constants_js_1.lMax;
|
|
126
|
+
if (s === Constants_js_1.sMin) {
|
|
127
|
+
const grayscaleValue = Math.round(lNormalized * Constants_js_1.rgbFactor);
|
|
129
128
|
return { r: grayscaleValue, g: grayscaleValue, b: grayscaleValue };
|
|
130
129
|
}
|
|
131
|
-
const
|
|
132
|
-
const temp3Min = 0, temp3Max = 1
|
|
130
|
+
const channel = (temp1, temp2, temp3) => {
|
|
131
|
+
const temp3Min = 0, temp3Max = 1;
|
|
133
132
|
if (temp3 < temp3Min) {
|
|
134
133
|
temp3++;
|
|
135
134
|
}
|
|
136
135
|
if (temp3 > temp3Max) {
|
|
137
136
|
temp3--;
|
|
138
137
|
}
|
|
139
|
-
if (temp3 * sextuple < temp3Max) {
|
|
140
|
-
return temp1 + (temp2 - temp1) * sextuple * temp3;
|
|
138
|
+
if (temp3 * Constants_js_1.sextuple < temp3Max) {
|
|
139
|
+
return temp1 + (temp2 - temp1) * Constants_js_1.sextuple * temp3;
|
|
141
140
|
}
|
|
142
|
-
if (temp3 * double < temp3Max) {
|
|
141
|
+
if (temp3 * Constants_js_1.double < temp3Max) {
|
|
143
142
|
return temp2;
|
|
144
143
|
}
|
|
145
|
-
if (temp3 * triple < temp3Max * double) {
|
|
146
|
-
const temp3Offset = double / triple;
|
|
147
|
-
return temp1 + (temp2 - temp1) * (temp3Offset - temp3) * sextuple;
|
|
144
|
+
if (temp3 * Constants_js_1.triple < temp3Max * Constants_js_1.double) {
|
|
145
|
+
const temp3Offset = Constants_js_1.double / Constants_js_1.triple;
|
|
146
|
+
return temp1 + (temp2 - temp1) * (temp3Offset - temp3) * Constants_js_1.sextuple;
|
|
148
147
|
}
|
|
149
148
|
return temp1;
|
|
150
|
-
},
|
|
151
|
-
? lNormalized * (sNormalizedOffset + sNormalized)
|
|
152
|
-
: lNormalized + sNormalized - lNormalized * sNormalized, temp2 = double * lNormalized - temp1,
|
|
149
|
+
}, temp1 = lNormalized < Constants_js_1.half
|
|
150
|
+
? lNormalized * (Constants_js_1.sNormalizedOffset + sNormalized)
|
|
151
|
+
: lNormalized + sNormalized - lNormalized * sNormalized, temp2 = Constants_js_1.double * lNormalized - temp1, phaseThird = Constants_js_1.phaseNumerator / Constants_js_1.triple, red = Math.min(Constants_js_1.rgbFactor, Constants_js_1.rgbFactor * channel(temp2, temp1, hNormalized + phaseThird)), green = Math.min(Constants_js_1.rgbFactor, Constants_js_1.rgbFactor * channel(temp2, temp1, hNormalized)), blue = Math.min(Constants_js_1.rgbFactor, Constants_js_1.rgbFactor * channel(temp2, temp1, hNormalized - phaseThird));
|
|
153
152
|
return { r: Math.round(red), g: Math.round(green), b: Math.round(blue) };
|
|
154
153
|
}
|
|
155
154
|
function hslaToRgba(hsla) {
|
|
@@ -162,20 +161,18 @@
|
|
|
162
161
|
};
|
|
163
162
|
}
|
|
164
163
|
function getRandomRgbColor(min) {
|
|
165
|
-
const
|
|
164
|
+
const fixedMin = min ?? Constants_js_1.defaultRgbMin, fixedMax = Constants_js_1.rgbMax + Constants_js_1.identity;
|
|
166
165
|
return {
|
|
167
|
-
b: Math.floor((0, NumberUtils_js_1.randomInRange)((0, NumberUtils_js_1.setRangeValue)(fixedMin,
|
|
168
|
-
g: Math.floor((0, NumberUtils_js_1.randomInRange)((0, NumberUtils_js_1.setRangeValue)(fixedMin,
|
|
169
|
-
r: Math.floor((0, NumberUtils_js_1.randomInRange)((0, NumberUtils_js_1.setRangeValue)(fixedMin,
|
|
166
|
+
b: Math.floor((0, NumberUtils_js_1.randomInRange)((0, NumberUtils_js_1.setRangeValue)(fixedMin, fixedMax))),
|
|
167
|
+
g: Math.floor((0, NumberUtils_js_1.randomInRange)((0, NumberUtils_js_1.setRangeValue)(fixedMin, fixedMax))),
|
|
168
|
+
r: Math.floor((0, NumberUtils_js_1.randomInRange)((0, NumberUtils_js_1.setRangeValue)(fixedMin, fixedMax))),
|
|
170
169
|
};
|
|
171
170
|
}
|
|
172
171
|
function getStyleFromRgb(color, opacity) {
|
|
173
|
-
|
|
174
|
-
return `rgba(${color.r}, ${color.g}, ${color.b}, ${opacity ?? defaultOpacity})`;
|
|
172
|
+
return `rgba(${color.r}, ${color.g}, ${color.b}, ${opacity ?? Constants_js_1.defaultOpacity})`;
|
|
175
173
|
}
|
|
176
174
|
function getStyleFromHsl(color, opacity) {
|
|
177
|
-
|
|
178
|
-
return `hsla(${color.h}, ${color.s}%, ${color.l}%, ${opacity ?? defaultOpacity})`;
|
|
175
|
+
return `hsla(${color.h}, ${color.s}%, ${color.l}%, ${opacity ?? Constants_js_1.defaultOpacity})`;
|
|
179
176
|
}
|
|
180
177
|
function colorMix(color1, color2, size1, size2) {
|
|
181
178
|
let rgb1 = color1, rgb2 = color2;
|
|
@@ -192,10 +189,10 @@
|
|
|
192
189
|
};
|
|
193
190
|
}
|
|
194
191
|
function getLinkColor(p1, p2, linkColor) {
|
|
195
|
-
if (linkColor === randomColorValue) {
|
|
192
|
+
if (linkColor === Constants_js_1.randomColorValue) {
|
|
196
193
|
return getRandomRgbColor();
|
|
197
194
|
}
|
|
198
|
-
else if (linkColor === midColorValue) {
|
|
195
|
+
else if (linkColor === Constants_js_1.midColorValue) {
|
|
199
196
|
const sourceColor = p1.getFillColor() ?? p1.getStrokeColor(), destColor = p2?.getFillColor() ?? p2?.getStrokeColor();
|
|
200
197
|
if (sourceColor && destColor && p2) {
|
|
201
198
|
return colorMix(sourceColor, destColor, p1.getRadius(), p2.getRadius());
|
|
@@ -213,19 +210,19 @@
|
|
|
213
210
|
}
|
|
214
211
|
function getLinkRandomColor(engine, optColor, blink, consent) {
|
|
215
212
|
const color = (0, TypeUtils_js_1.isString)(optColor) ? optColor : optColor.value;
|
|
216
|
-
if (color === randomColorValue) {
|
|
213
|
+
if (color === Constants_js_1.randomColorValue) {
|
|
217
214
|
if (consent) {
|
|
218
215
|
return rangeColorToRgb(engine, {
|
|
219
216
|
value: color,
|
|
220
217
|
});
|
|
221
218
|
}
|
|
222
219
|
if (blink) {
|
|
223
|
-
return randomColorValue;
|
|
220
|
+
return Constants_js_1.randomColorValue;
|
|
224
221
|
}
|
|
225
|
-
return midColorValue;
|
|
222
|
+
return Constants_js_1.midColorValue;
|
|
226
223
|
}
|
|
227
|
-
else if (color === midColorValue) {
|
|
228
|
-
return midColorValue;
|
|
224
|
+
else if (color === Constants_js_1.midColorValue) {
|
|
225
|
+
return Constants_js_1.midColorValue;
|
|
229
226
|
}
|
|
230
227
|
else {
|
|
231
228
|
return rangeColorToRgb(engine, {
|
|
@@ -266,14 +263,13 @@
|
|
|
266
263
|
}
|
|
267
264
|
function setColorAnimation(colorValue, colorAnimation, reduceFactor) {
|
|
268
265
|
colorValue.enable = colorAnimation.enable;
|
|
269
|
-
const defaultVelocity = 0, decayOffset = 1, defaultLoops = 0, defaultTime = 0;
|
|
270
266
|
if (colorValue.enable) {
|
|
271
267
|
colorValue.velocity = ((0, NumberUtils_js_1.getRangeValue)(colorAnimation.speed) / Constants_js_1.percentDenominator) * reduceFactor;
|
|
272
|
-
colorValue.decay = decayOffset - (0, NumberUtils_js_1.getRangeValue)(colorAnimation.decay);
|
|
268
|
+
colorValue.decay = Constants_js_1.decayOffset - (0, NumberUtils_js_1.getRangeValue)(colorAnimation.decay);
|
|
273
269
|
colorValue.status = AnimationStatus_js_1.AnimationStatus.increasing;
|
|
274
|
-
colorValue.loops = defaultLoops;
|
|
270
|
+
colorValue.loops = Constants_js_1.defaultLoops;
|
|
275
271
|
colorValue.maxLoops = (0, NumberUtils_js_1.getRangeValue)(colorAnimation.count);
|
|
276
|
-
colorValue.time = defaultTime;
|
|
272
|
+
colorValue.time = Constants_js_1.defaultTime;
|
|
277
273
|
colorValue.delayTime = (0, NumberUtils_js_1.getRangeValue)(colorAnimation.delay) * Constants_js_1.millisecondsToSeconds;
|
|
278
274
|
if (!colorAnimation.sync) {
|
|
279
275
|
colorValue.velocity *= (0, NumberUtils_js_1.getRandom)();
|
|
@@ -283,7 +279,7 @@
|
|
|
283
279
|
colorValue.offset = (0, NumberUtils_js_1.setRangeValue)(colorAnimation.offset);
|
|
284
280
|
}
|
|
285
281
|
else {
|
|
286
|
-
colorValue.velocity = defaultVelocity;
|
|
282
|
+
colorValue.velocity = Constants_js_1.defaultVelocity;
|
|
287
283
|
}
|
|
288
284
|
}
|
|
289
285
|
function updateColorValue(data, range, decrease, delta) {
|
|
@@ -338,8 +334,7 @@
|
|
|
338
334
|
if (!color) {
|
|
339
335
|
return;
|
|
340
336
|
}
|
|
341
|
-
const { h, s, l } = color
|
|
342
|
-
const ranges = {
|
|
337
|
+
const { h, s, l } = color, ranges = {
|
|
343
338
|
h: { min: 0, max: 360 },
|
|
344
339
|
s: { min: 0, max: 100 },
|
|
345
340
|
l: { min: 0, max: 100 },
|