tsparticles-updater-stroke-color
Advanced tools
Comparing version 2.0.0-alpha.7 to 2.0.0-beta.0
{ | ||
"name": "tsparticles-updater-stroke-color", | ||
"version": "2.0.0-alpha.7", | ||
"version": "2.0.0-beta.0", | ||
"description": "tsParticles particles stroke color updater", | ||
@@ -42,27 +42,10 @@ "homepage": "https://particles.js.org/", | ||
"main": "index.js", | ||
"jsdelivr": "tsparticles.updater.stroke.color.min.js", | ||
"unpkg": "tsparticles.updater.stroke.color.min.js", | ||
"jsdelivr": "tsparticles.updater.stroke-color.min.js", | ||
"unpkg": "tsparticles.updater.stroke-color.min.js", | ||
"browser": "index.js", | ||
"module": "index.js", | ||
"types": "index.d.ts", | ||
"typesVersions": { | ||
">=4.0 <4.1": { | ||
"*": [ | ||
"dist/ts4.0" | ||
] | ||
}, | ||
">=3.8 <4.0": { | ||
"*": [ | ||
"dist/ts3.8" | ||
] | ||
}, | ||
"<3.8": { | ||
"*": [ | ||
"dist/ts3.4" | ||
] | ||
} | ||
}, | ||
"dependencies": { | ||
"tsparticles-engine": "^2.0.0-alpha.7" | ||
"tsparticles-engine": "^2.0.0-beta.0" | ||
} | ||
} |
@@ -1,5 +0,5 @@ | ||
[![banner](https://cdn.matteobruni.it/images/particles/banner2.png)](https://particles.js.org) | ||
[![banner](https://particles.js.org/images/banner2.png)](https://particles.js.org) | ||
# tsparticles-shape-bubble | ||
# tsparticles-updater-strokeColor | ||
tsParticles bubble shape | ||
tsParticles updater strokeColor |
@@ -1,9 +0,8 @@ | ||
import type { Container, IDelta, IParticleUpdater, IParticleValueAnimation, Particle } from "tsparticles-engine"; | ||
import type { IColorAnimation } from "tsparticles-engine/Options/Interfaces/IColorAnimation"; | ||
import type { Container, IDelta, IParticleUpdater, Particle } from "tsparticles-engine"; | ||
export declare class StrokeColorUpdater implements IParticleUpdater { | ||
private readonly container; | ||
constructor(container: Container); | ||
init(particle: Particle): void; | ||
isEnabled(particle: Particle): boolean; | ||
update(particle: Particle, delta: IDelta): void; | ||
updateValue(particle: Particle, delta: IDelta, value: IParticleValueAnimation<number>, valueAnimation: IColorAnimation, max: number): void; | ||
} |
@@ -1,2 +0,47 @@ | ||
import { randomInRange } from "tsparticles-engine"; | ||
import { AnimationStatus, colorToHsl, getHslAnimationFromHsl, itemFromArray, randomInRange } from "tsparticles-engine"; | ||
function updateColorValue(delta, value, valueAnimation, max, decrease) { | ||
var _a; | ||
const colorValue = value; | ||
if (!colorValue || !colorValue.enable) { | ||
return; | ||
} | ||
const offset = randomInRange(valueAnimation.offset); | ||
const velocity = ((_a = value.velocity) !== null && _a !== void 0 ? _a : 0) * delta.factor + offset * 3.6; | ||
if (!decrease || colorValue.status === AnimationStatus.increasing) { | ||
colorValue.value += velocity; | ||
if (decrease && colorValue.value > max) { | ||
colorValue.status = AnimationStatus.decreasing; | ||
colorValue.value -= colorValue.value % max; | ||
} | ||
} | ||
else { | ||
colorValue.value -= velocity; | ||
if (colorValue.value < 0) { | ||
colorValue.status = AnimationStatus.increasing; | ||
colorValue.value += colorValue.value; | ||
} | ||
} | ||
if (colorValue.value > max) { | ||
colorValue.value %= max; | ||
} | ||
} | ||
function updateStrokeColor(particle, delta) { | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; | ||
if (!((_a = particle.stroke) === null || _a === void 0 ? void 0 : _a.color)) { | ||
return; | ||
} | ||
const animationOptions = particle.stroke.color.animation; | ||
const h = (_c = (_b = particle.strokeColor) === null || _b === void 0 ? void 0 : _b.h) !== null && _c !== void 0 ? _c : (_d = particle.color) === null || _d === void 0 ? void 0 : _d.h; | ||
if (h) { | ||
updateColorValue(delta, h, animationOptions.h, 360, false); | ||
} | ||
const s = (_f = (_e = particle.strokeColor) === null || _e === void 0 ? void 0 : _e.s) !== null && _f !== void 0 ? _f : (_g = particle.color) === null || _g === void 0 ? void 0 : _g.s; | ||
if (s) { | ||
updateColorValue(delta, s, animationOptions.s, 100, true); | ||
} | ||
const l = (_j = (_h = particle.strokeColor) === null || _h === void 0 ? void 0 : _h.l) !== null && _j !== void 0 ? _j : (_k = particle.color) === null || _k === void 0 ? void 0 : _k.l; | ||
if (l) { | ||
updateColorValue(delta, l, animationOptions.l, 100, true); | ||
} | ||
} | ||
export class StrokeColorUpdater { | ||
@@ -6,53 +51,31 @@ constructor(container) { | ||
} | ||
init(particle) { | ||
var _a, _b; | ||
const container = this.container; | ||
particle.stroke = | ||
particle.options.stroke instanceof Array | ||
? itemFromArray(particle.options.stroke, particle.id, particle.options.reduceDuplicates) | ||
: particle.options.stroke; | ||
particle.strokeWidth = particle.stroke.width * container.retina.pixelRatio; | ||
const strokeHslColor = (_a = colorToHsl(particle.stroke.color)) !== null && _a !== void 0 ? _a : particle.getFillColor(); | ||
if (strokeHslColor) { | ||
particle.strokeColor = getHslAnimationFromHsl(strokeHslColor, (_b = particle.stroke.color) === null || _b === void 0 ? void 0 : _b.animation, container.retina.reduceFactor); | ||
} | ||
} | ||
isEnabled(particle) { | ||
var _a, _b, _c; | ||
const color = particle.stroke.color; | ||
var _a, _b, _c, _d; | ||
const color = (_a = particle.stroke) === null || _a === void 0 ? void 0 : _a.color; | ||
return (!particle.destroyed && | ||
!particle.spawning && | ||
color !== undefined && | ||
((((_a = particle.strokeColor) === null || _a === void 0 ? void 0 : _a.h.value) !== undefined && color.animation.h.enable) || | ||
(((_b = particle.strokeColor) === null || _b === void 0 ? void 0 : _b.s.value) !== undefined && color.animation.s.enable) || | ||
(((_c = particle.strokeColor) === null || _c === void 0 ? void 0 : _c.l.value) !== undefined && color.animation.l.enable))); | ||
!!color && | ||
((((_b = particle.strokeColor) === null || _b === void 0 ? void 0 : _b.h.value) !== undefined && color.animation.h.enable) || | ||
(((_c = particle.strokeColor) === null || _c === void 0 ? void 0 : _c.s.value) !== undefined && color.animation.s.enable) || | ||
(((_d = particle.strokeColor) === null || _d === void 0 ? void 0 : _d.l.value) !== undefined && color.animation.l.enable))); | ||
} | ||
update(particle, delta) { | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m; | ||
if (!this.isEnabled(particle)) { | ||
return; | ||
} | ||
const animationOptions = particle.stroke.color.animation; | ||
const valueAnimations = animationOptions; | ||
if (valueAnimations.enable !== undefined) { | ||
const hue = (_b = (_a = particle.strokeColor) === null || _a === void 0 ? void 0 : _a.h) !== null && _b !== void 0 ? _b : (_c = particle.color) === null || _c === void 0 ? void 0 : _c.h; | ||
if (hue) { | ||
this.updateValue(particle, delta, hue, valueAnimations, 360); | ||
} | ||
} | ||
else { | ||
const hslAnimations = animationOptions; | ||
const h = (_e = (_d = particle.strokeColor) === null || _d === void 0 ? void 0 : _d.h) !== null && _e !== void 0 ? _e : (_f = particle.color) === null || _f === void 0 ? void 0 : _f.h; | ||
if (h) { | ||
this.updateValue(particle, delta, h, hslAnimations.h, 360); | ||
} | ||
const s = (_h = (_g = particle.strokeColor) === null || _g === void 0 ? void 0 : _g.s) !== null && _h !== void 0 ? _h : (_j = particle.color) === null || _j === void 0 ? void 0 : _j.s; | ||
if (s) { | ||
this.updateValue(particle, delta, s, hslAnimations.s, 100); | ||
} | ||
const l = (_l = (_k = particle.strokeColor) === null || _k === void 0 ? void 0 : _k.l) !== null && _l !== void 0 ? _l : (_m = particle.color) === null || _m === void 0 ? void 0 : _m.l; | ||
if (l) { | ||
this.updateValue(particle, delta, l, hslAnimations.l, 100); | ||
} | ||
} | ||
updateStrokeColor(particle, delta); | ||
} | ||
updateValue(particle, delta, value, valueAnimation, max) { | ||
var _a; | ||
const colorValue = value; | ||
if (!colorValue) { | ||
return; | ||
} | ||
const offset = randomInRange(valueAnimation.offset); | ||
colorValue.value += ((_a = value.velocity) !== null && _a !== void 0 ? _a : 0) * delta.factor + offset * 3.6; | ||
if (colorValue.value > max) { | ||
colorValue.value %= max; | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
293919
15
299
1