@firecms/neat 0.5.1 → 0.6.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/dist/NeatGradient.js +48 -0
- package/dist/NeatGradient.js.map +1 -1
- package/dist/index.es.js +212 -175
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +11 -6
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
- package/src/NeatGradient.ts +60 -4
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import * as n from "three";
|
|
2
|
+
console.info(
|
|
3
|
+
`%c\u{1F308} Neat Gradients%c
|
|
4
|
+
|
|
5
|
+
Licensed under MIT + The Commons Clause.
|
|
6
|
+
Free for personal and commercial use.
|
|
7
|
+
Selling this software or its derivatives is strictly prohibited.
|
|
8
|
+
https://neat.firecms.co`,
|
|
9
|
+
"font-weight: bold; font-size: 14px; color: #FF5772;",
|
|
10
|
+
"color: inherit;"
|
|
11
|
+
);
|
|
12
|
+
const U = 50, D = 80, be = !0, j = 6, ze = new n.Clock(), Q = Fe();
|
|
13
|
+
class Ue {
|
|
4
14
|
_ref;
|
|
5
15
|
_speed = -1;
|
|
6
16
|
_horizontalPressure = -1;
|
|
@@ -30,7 +40,7 @@ class Be {
|
|
|
30
40
|
_mouseDistortionRadius = 0.25;
|
|
31
41
|
_mouseDecayRate = 0.96;
|
|
32
42
|
_mouseDarken = 0;
|
|
33
|
-
_mouse = new
|
|
43
|
+
_mouse = new n.Vector2(-1e3, -1e3);
|
|
34
44
|
_mouseFBO = null;
|
|
35
45
|
_sceneMouse = null;
|
|
36
46
|
_cameraMouse = null;
|
|
@@ -60,7 +70,7 @@ class Be {
|
|
|
60
70
|
_yOffsetWaveMultiplier = 4e-3;
|
|
61
71
|
_yOffsetColorMultiplier = 4e-3;
|
|
62
72
|
_yOffsetFlowMultiplier = 4e-3;
|
|
63
|
-
_tempClearColor = new
|
|
73
|
+
_tempClearColor = new n.Color();
|
|
64
74
|
_resizeTimeoutId = null;
|
|
65
75
|
_textureNeedsUpdate = !1;
|
|
66
76
|
_lastColorUpdate = 0;
|
|
@@ -70,31 +80,31 @@ class Be {
|
|
|
70
80
|
_colorsChanged = !0;
|
|
71
81
|
constructor(e) {
|
|
72
82
|
const {
|
|
73
|
-
ref:
|
|
83
|
+
ref: o,
|
|
74
84
|
speed: t = 4,
|
|
75
|
-
horizontalPressure:
|
|
85
|
+
horizontalPressure: d = 3,
|
|
76
86
|
verticalPressure: c = 3,
|
|
77
|
-
waveFrequencyX:
|
|
87
|
+
waveFrequencyX: s = 5,
|
|
78
88
|
waveFrequencyY: p = 5,
|
|
79
89
|
waveAmplitude: g = 3,
|
|
80
|
-
colors:
|
|
81
|
-
highlights:
|
|
90
|
+
colors: f,
|
|
91
|
+
highlights: m = 4,
|
|
82
92
|
shadows: u = 4,
|
|
83
|
-
colorSaturation:
|
|
93
|
+
colorSaturation: v = 0,
|
|
84
94
|
colorBrightness: O = 1,
|
|
85
95
|
colorBlending: M = 5,
|
|
86
96
|
grainScale: z = 2,
|
|
87
97
|
grainIntensity: y = 0.55,
|
|
88
|
-
grainSparsity:
|
|
98
|
+
grainSparsity: T = 0,
|
|
89
99
|
grainSpeed: C = 0.1,
|
|
90
100
|
wireframe: a = !1,
|
|
91
|
-
backgroundColor:
|
|
101
|
+
backgroundColor: l = "#FFFFFF",
|
|
92
102
|
backgroundAlpha: h = 1,
|
|
93
103
|
resolution: _ = 1,
|
|
94
104
|
seed: S,
|
|
95
105
|
yOffset: B = 0,
|
|
96
106
|
yOffsetWaveMultiplier: N = 4,
|
|
97
|
-
yOffsetColorMultiplier:
|
|
107
|
+
yOffsetColorMultiplier: L = 4,
|
|
98
108
|
yOffsetFlowMultiplier: $ = 4,
|
|
99
109
|
flowDistortionA: ee = 0,
|
|
100
110
|
flowDistortionB: te = 0,
|
|
@@ -103,77 +113,77 @@ class Be {
|
|
|
103
113
|
flowEnabled: ie = !0,
|
|
104
114
|
mouseDistortionStrength: re = 0,
|
|
105
115
|
mouseDistortionRadius: ae = 0.25,
|
|
106
|
-
mouseDecayRate:
|
|
107
|
-
mouseDarken:
|
|
116
|
+
mouseDecayRate: ne = 0.96,
|
|
117
|
+
mouseDarken: le = 0,
|
|
108
118
|
enableProceduralTexture: ue = !1,
|
|
109
119
|
textureVoidLikelihood: ce = 0.45,
|
|
110
120
|
textureVoidWidthMin: _e = 200,
|
|
111
121
|
textureVoidWidthMax: he = 486,
|
|
112
|
-
textureBandDensity:
|
|
113
|
-
textureColorBlending:
|
|
122
|
+
textureBandDensity: de = 2.15,
|
|
123
|
+
textureColorBlending: fe = 0.01,
|
|
114
124
|
textureSeed: pe = 333,
|
|
115
|
-
textureEase:
|
|
116
|
-
proceduralBackgroundColor:
|
|
125
|
+
textureEase: me = 0.5,
|
|
126
|
+
proceduralBackgroundColor: ve = "#000000",
|
|
117
127
|
textureShapeTriangles: ge = 20,
|
|
118
|
-
textureShapeCircles:
|
|
128
|
+
textureShapeCircles: xe = 15,
|
|
119
129
|
textureShapeBars: ye = 15,
|
|
120
130
|
textureShapeSquiggles: we = 10
|
|
121
131
|
} = e;
|
|
122
|
-
this._ref =
|
|
132
|
+
this._ref = o, this.destroy = this.destroy.bind(this), this._initScene = this._initScene.bind(this), this._buildMaterial = this._buildMaterial.bind(this), this.speed = t, this.horizontalPressure = d, this.verticalPressure = c, this.waveFrequencyX = s, this.waveFrequencyY = p, this.waveAmplitude = g, this.colorBlending = M, this.grainScale = z, this.grainIntensity = y, this.grainSparsity = T, this.grainSpeed = C, this.colors = f, this.shadows = u, this.highlights = m, this.colorSaturation = v, this.colorBrightness = O, this.wireframe = a, this.backgroundColor = l, this.backgroundAlpha = h, this.yOffset = B, this.yOffsetWaveMultiplier = N, this.yOffsetColorMultiplier = L, this.yOffsetFlowMultiplier = $, this.flowDistortionA = ee, this.flowDistortionB = te, this.flowScale = oe, this.flowEase = se, this.flowEnabled = ie, this.mouseDistortionStrength = re, this.mouseDistortionRadius = ae, this.mouseDecayRate = ne, this.mouseDarken = le, this.enableProceduralTexture = ue, this.textureVoidLikelihood = ce, this.textureVoidWidthMin = _e, this.textureVoidWidthMax = he, this.textureBandDensity = de, this.textureColorBlending = fe, this.textureSeed = pe, this.textureEase = me, this._proceduralBackgroundColor = ve, this._textureShapeTriangles = ge, this._textureShapeCircles = xe, this._textureShapeBars = ye, this._textureShapeSquiggles = we, this._setupMouseInteraction(), this.sceneState = this._initScene(_), Be();
|
|
123
133
|
let G = S !== void 0 ? S : Oe();
|
|
124
134
|
const X = () => {
|
|
125
|
-
const { renderer: w, camera: E, scene:
|
|
126
|
-
if (this._linkCheckCounter++, this._linkCheckCounter >= 300 && (this._linkCheckCounter = 0, (!this._linkElement || !document.contains(this._linkElement)) && (this._linkElement = Pe(
|
|
127
|
-
const
|
|
128
|
-
G += ze.getDelta() * this._speed,
|
|
129
|
-
const
|
|
130
|
-
if (this._colorsChanged ||
|
|
131
|
-
this._lastColorUpdate =
|
|
132
|
-
const q =
|
|
135
|
+
const { renderer: w, camera: E, scene: F } = this.sceneState;
|
|
136
|
+
if (this._linkCheckCounter++, this._linkCheckCounter >= 300 && (this._linkCheckCounter = 0, (!this._linkElement || !document.contains(this._linkElement)) && (this._linkElement = Pe(o))), this._cachedUniforms) {
|
|
137
|
+
const r = this._cachedUniforms;
|
|
138
|
+
G += ze.getDelta() * this._speed, r.u_time.value = G, r.u_resolution.value.set(this._ref.width, this._ref.height), r.u_color_pressure.value.set(this._horizontalPressure, this._verticalPressure), r.u_wave_frequency_x.value = this._waveFrequencyX, r.u_wave_frequency_y.value = this._waveFrequencyY, r.u_wave_amplitude.value = this._waveAmplitude, r.u_color_blending.value = this._colorBlending, r.u_shadows.value = this._shadows, r.u_highlights.value = this._highlights, r.u_saturation.value = this._saturation, r.u_brightness.value = this._brightness, r.u_grain_intensity.value = this._grainIntensity, r.u_grain_sparsity.value = this._grainSparsity, r.u_grain_speed.value = this._grainSpeed, r.u_grain_scale.value = this._grainScale, r.u_y_offset.value = this._yOffset, r.u_y_offset_wave_multiplier.value = this._yOffsetWaveMultiplier, r.u_y_offset_color_multiplier.value = this._yOffsetColorMultiplier, r.u_y_offset_flow_multiplier.value = this._yOffsetFlowMultiplier, r.u_flow_distortion_a.value = this._flowDistortionA, r.u_flow_distortion_b.value = this._flowDistortionB, r.u_flow_scale.value = this._flowScale, r.u_flow_ease.value = this._flowEase, r.u_flow_enabled.value = this._flowEnabled ? 1 : 0, r.u_mouse_distortion_strength.value = this._mouseDistortionStrength, r.u_mouse_distortion_radius.value = this._mouseDistortionRadius, r.u_mouse_darken.value = this._mouseDarken, r.u_enable_procedural_texture.value = this._enableProceduralTexture ? 1 : 0, this._textureNeedsUpdate && this._enableProceduralTexture && (this._proceduralTexture && this._proceduralTexture.dispose(), this._proceduralTexture = this._createProceduralTexture(), this._textureNeedsUpdate = !1), r.u_procedural_texture.value = this._proceduralTexture, r.u_texture_ease.value = this._textureEase, this.sceneState.meshes[0].material.wireframe = this._wireframe;
|
|
139
|
+
const x = Date.now();
|
|
140
|
+
if (this._colorsChanged || x - this._lastColorUpdate > 100) {
|
|
141
|
+
this._lastColorUpdate = x, this._colorsChanged = !1;
|
|
142
|
+
const q = r.u_colors.value;
|
|
133
143
|
for (let P = 0; P < j; P++)
|
|
134
144
|
if (P < this._colors.length) {
|
|
135
|
-
const
|
|
136
|
-
q[P].is_active =
|
|
145
|
+
const V = this._colors[P];
|
|
146
|
+
q[P].is_active = V.enabled ? 1 : 0, q[P].color.setStyle(V.color, ""), q[P].influence = V.influence || 0;
|
|
137
147
|
} else
|
|
138
148
|
q[P].is_active = 0;
|
|
139
|
-
|
|
149
|
+
r.u_colors_count.value = j;
|
|
140
150
|
}
|
|
141
151
|
}
|
|
142
152
|
if (this._mouseFBO && this._sceneMouse && this._cameraMouse && this._mouseDistortionStrength > 0) {
|
|
143
|
-
let
|
|
144
|
-
for (let
|
|
145
|
-
const b = this._mouseObjects[
|
|
146
|
-
b.mesh.visible && (
|
|
153
|
+
let r = !1;
|
|
154
|
+
for (let x = 0; x < this._mouseObjects.length; x++) {
|
|
155
|
+
const b = this._mouseObjects[x];
|
|
156
|
+
b.mesh.visible && (r = !0, b.mesh.rotation.z += 0.01, b.mesh.material instanceof n.MeshBasicMaterial && (b.mesh.material.opacity *= this._mouseDecayRate, b.mesh.material.opacity < 0.01 && (b.mesh.visible = !1)));
|
|
147
157
|
}
|
|
148
|
-
if (
|
|
158
|
+
if (r) {
|
|
149
159
|
w.getClearColor(this._tempClearColor);
|
|
150
|
-
const
|
|
151
|
-
w.setClearColor(0, 0), w.setRenderTarget(this._mouseFBO), w.clear(), w.render(this._sceneMouse, this._cameraMouse), w.setRenderTarget(null), w.setClearColor(this._tempClearColor,
|
|
160
|
+
const x = w.getClearAlpha();
|
|
161
|
+
w.setClearColor(0, 0), w.setRenderTarget(this._mouseFBO), w.clear(), w.render(this._sceneMouse, this._cameraMouse), w.setRenderTarget(null), w.setClearColor(this._tempClearColor, x), this._cachedUniforms && (this._cachedUniforms.u_mouse_texture.value = this._mouseFBO.texture);
|
|
152
162
|
}
|
|
153
163
|
}
|
|
154
|
-
w.setClearColor(this._backgroundColor, this._backgroundAlpha), w.render(
|
|
164
|
+
w.setClearColor(this._backgroundColor, this._backgroundAlpha), w.render(F, E), this.requestRef = requestAnimationFrame(X);
|
|
155
165
|
}, Se = () => {
|
|
156
|
-
const { renderer: w } = this.sceneState, E = w.domElement,
|
|
157
|
-
if (this.sceneState.renderer.setSize(
|
|
158
|
-
const
|
|
159
|
-
this._mouseFBO.setSize(
|
|
166
|
+
const { renderer: w } = this.sceneState, E = w.domElement, F = E.clientWidth, r = E.clientHeight;
|
|
167
|
+
if (this.sceneState.renderer.setSize(F, r, !1), K(this.sceneState.camera, F, r), this._mouseFBO && this._cameraMouse) {
|
|
168
|
+
const x = r / 2, b = F / r;
|
|
169
|
+
this._mouseFBO.setSize(F / 2, r / 2), this._cameraMouse.left = -x * b, this._cameraMouse.right = x * b, this._cameraMouse.top = x, this._cameraMouse.bottom = -x, this._cameraMouse.updateProjectionMatrix();
|
|
160
170
|
}
|
|
161
171
|
};
|
|
162
172
|
this.sizeObserver = new ResizeObserver(() => {
|
|
163
173
|
this._resizeTimeoutId !== null && clearTimeout(this._resizeTimeoutId), this._resizeTimeoutId = window.setTimeout(() => {
|
|
164
174
|
Se(), this._resizeTimeoutId = null;
|
|
165
175
|
}, 100);
|
|
166
|
-
}), this.sizeObserver.observe(
|
|
176
|
+
}), this.sizeObserver.observe(o), X();
|
|
167
177
|
}
|
|
168
178
|
destroy() {
|
|
169
179
|
this && (cancelAnimationFrame(this.requestRef), this.sizeObserver.disconnect(), this._resizeTimeoutId !== null && (clearTimeout(this._resizeTimeoutId), this._resizeTimeoutId = null), this.sceneState && (this.sceneState.renderer.dispose(), this.sceneState.meshes.forEach((e) => {
|
|
170
|
-
e.geometry.dispose(), Array.isArray(e.material) ? e.material.forEach((
|
|
180
|
+
e.geometry.dispose(), Array.isArray(e.material) ? e.material.forEach((o) => o.dispose()) : e.material.dispose();
|
|
171
181
|
})), this._mouseFBO && this._mouseFBO.dispose(), this._proceduralTexture && this._proceduralTexture.dispose());
|
|
172
182
|
}
|
|
173
183
|
downloadAsPNG(e = "neat.png") {
|
|
174
184
|
console.log("Downloading as PNG", this._ref);
|
|
175
|
-
const
|
|
176
|
-
console.log("data",
|
|
185
|
+
const o = this._ref.toDataURL("image/png");
|
|
186
|
+
console.log("data", o), Te(o, e);
|
|
177
187
|
}
|
|
178
188
|
set speed(e) {
|
|
179
189
|
this._speed = e / 20;
|
|
@@ -332,39 +342,39 @@ class Be {
|
|
|
332
342
|
this._textureShapeSquiggles = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
|
|
333
343
|
}
|
|
334
344
|
_initScene(e) {
|
|
335
|
-
const
|
|
345
|
+
const o = this._ref.width, t = this._ref.height;
|
|
336
346
|
this.sceneState && this.sceneState.renderer && (this.sceneState.renderer.dispose(), this.sceneState.meshes.forEach((u) => {
|
|
337
|
-
u.geometry.dispose(), Array.isArray(u.material) ? u.material.forEach((
|
|
347
|
+
u.geometry.dispose(), Array.isArray(u.material) ? u.material.forEach((v) => v.dispose()) : u.material.dispose();
|
|
338
348
|
}));
|
|
339
|
-
const
|
|
349
|
+
const d = new n.WebGLRenderer({
|
|
340
350
|
alpha: !0,
|
|
341
351
|
preserveDrawingBuffer: !0,
|
|
342
352
|
canvas: this._ref
|
|
343
353
|
});
|
|
344
|
-
|
|
345
|
-
const c = [],
|
|
346
|
-
|
|
347
|
-
const
|
|
348
|
-
return
|
|
349
|
-
renderer:
|
|
350
|
-
camera:
|
|
351
|
-
scene:
|
|
354
|
+
d.setClearColor(16711680, 0.5), d.setSize(o, t, !1);
|
|
355
|
+
const c = [], s = new n.Scene(), p = this._buildMaterial(o, t), g = new n.PlaneGeometry(U, D, 240 * e, 240 * e), f = new n.Mesh(g, p);
|
|
356
|
+
f.rotation.x = -Math.PI / 3.5, f.position.z = -1, c.push(f), s.add(f);
|
|
357
|
+
const m = new n.OrthographicCamera(0, 0, 0, 0, 0, 0);
|
|
358
|
+
return m.position.z = 5, K(m, o, t), {
|
|
359
|
+
renderer: d,
|
|
360
|
+
camera: m,
|
|
361
|
+
scene: s,
|
|
352
362
|
meshes: c,
|
|
353
363
|
resolution: e
|
|
354
364
|
};
|
|
355
365
|
}
|
|
356
|
-
_buildMaterial(e,
|
|
357
|
-
const t = Array.from({ length: j }).map((
|
|
366
|
+
_buildMaterial(e, o) {
|
|
367
|
+
const t = Array.from({ length: j }).map((s, p) => ({
|
|
358
368
|
is_active: p < this._colors.length && this._colors[p].enabled ? 1 : 0,
|
|
359
|
-
color: new
|
|
369
|
+
color: new n.Color(p < this._colors.length ? this._colors[p].color : 0),
|
|
360
370
|
influence: p < this._colors.length && this._colors[p].influence || 0
|
|
361
|
-
})),
|
|
371
|
+
})), d = {
|
|
362
372
|
u_time: { value: 0 },
|
|
363
|
-
u_color_pressure: { value: new
|
|
373
|
+
u_color_pressure: { value: new n.Vector2(this._horizontalPressure, this._verticalPressure) },
|
|
364
374
|
u_wave_frequency_x: { value: this._waveFrequencyX },
|
|
365
375
|
u_wave_frequency_y: { value: this._waveFrequencyY },
|
|
366
376
|
u_wave_amplitude: { value: this._waveAmplitude },
|
|
367
|
-
u_resolution: { value: new
|
|
377
|
+
u_resolution: { value: new n.Vector2(e, o) },
|
|
368
378
|
u_colors: { value: t },
|
|
369
379
|
u_colors_count: { value: this._colors.length },
|
|
370
380
|
u_plane_width: { value: U },
|
|
@@ -394,22 +404,22 @@ class Be {
|
|
|
394
404
|
u_saturation: { value: this._saturation },
|
|
395
405
|
u_brightness: { value: this._brightness },
|
|
396
406
|
u_color_blending: { value: this._colorBlending }
|
|
397
|
-
}, c = new
|
|
398
|
-
uniforms:
|
|
399
|
-
vertexShader: H() + Y() +
|
|
400
|
-
fragmentShader: H() +
|
|
407
|
+
}, c = new n.ShaderMaterial({
|
|
408
|
+
uniforms: d,
|
|
409
|
+
vertexShader: H() + Y() + J() + Ce(),
|
|
410
|
+
fragmentShader: H() + J() + Y() + Me()
|
|
401
411
|
});
|
|
402
|
-
return this._cachedUniforms =
|
|
412
|
+
return this._cachedUniforms = d, c.wireframe = be, c;
|
|
403
413
|
}
|
|
404
414
|
_setupMouseInteraction() {
|
|
405
415
|
if (!this._ref)
|
|
406
416
|
return;
|
|
407
|
-
const e = this._ref.width,
|
|
408
|
-
this._mouseFBO = new
|
|
409
|
-
const t =
|
|
410
|
-
this._cameraMouse = new
|
|
411
|
-
-t *
|
|
412
|
-
t *
|
|
417
|
+
const e = this._ref.width, o = this._ref.height;
|
|
418
|
+
this._mouseFBO = new n.WebGLRenderTarget(e / 2, o / 2), this._sceneMouse = new n.Scene();
|
|
419
|
+
const t = o / 2, d = e / o;
|
|
420
|
+
this._cameraMouse = new n.OrthographicCamera(
|
|
421
|
+
-t * d,
|
|
422
|
+
t * d,
|
|
413
423
|
t,
|
|
414
424
|
-t,
|
|
415
425
|
0,
|
|
@@ -417,100 +427,100 @@ class Be {
|
|
|
417
427
|
), this._cameraMouse.position.set(0, 0, 100);
|
|
418
428
|
const c = document.createElement("canvas");
|
|
419
429
|
c.width = 128, c.height = 128;
|
|
420
|
-
const
|
|
421
|
-
if (
|
|
422
|
-
const u =
|
|
423
|
-
u.addColorStop(0, "rgba(255,255,255,0.8)"), u.addColorStop(0.5, "rgba(255,255,255,0.4)"), u.addColorStop(1, "rgba(255,255,255,0)"),
|
|
430
|
+
const s = c.getContext("2d");
|
|
431
|
+
if (s) {
|
|
432
|
+
const u = s.createRadialGradient(64, 64, 0, 64, 64, 64);
|
|
433
|
+
u.addColorStop(0, "rgba(255,255,255,0.8)"), u.addColorStop(0.5, "rgba(255,255,255,0.4)"), u.addColorStop(1, "rgba(255,255,255,0)"), s.fillStyle = u, s.fillRect(0, 0, 128, 128);
|
|
424
434
|
}
|
|
425
|
-
const p = new
|
|
435
|
+
const p = new n.CanvasTexture(c), g = new n.MeshBasicMaterial({
|
|
426
436
|
map: p,
|
|
427
437
|
transparent: !0,
|
|
428
438
|
opacity: 1,
|
|
429
439
|
depthTest: !1,
|
|
430
|
-
blending:
|
|
431
|
-
}),
|
|
432
|
-
for (let u = 0; u <
|
|
433
|
-
const
|
|
434
|
-
|
|
440
|
+
blending: n.AdditiveBlending
|
|
441
|
+
}), f = new n.PlaneGeometry(200, 200), m = 50;
|
|
442
|
+
for (let u = 0; u < m; u++) {
|
|
443
|
+
const v = new n.Mesh(f, g.clone());
|
|
444
|
+
v.visible = !1, this._sceneMouse.add(v), this._mouseObjects.push({ mesh: v, active: !1 });
|
|
435
445
|
}
|
|
436
446
|
this._updateBrushScale(), this._ref.addEventListener("mousemove", this._onMouseMove.bind(this));
|
|
437
447
|
}
|
|
438
448
|
_onMouseMove(e) {
|
|
439
449
|
if (!this._ref || !this._sceneMouse)
|
|
440
450
|
return;
|
|
441
|
-
const
|
|
451
|
+
const o = this._ref.getBoundingClientRect(), t = this._ref.width, d = this._ref.height;
|
|
442
452
|
this._pendingMousePosition = {
|
|
443
|
-
x: e.clientX -
|
|
444
|
-
y: -(e.clientY -
|
|
453
|
+
x: e.clientX - o.left - t / 2,
|
|
454
|
+
y: -(e.clientY - o.top - d / 2)
|
|
445
455
|
}, this._mouseUpdateScheduled || (this._mouseUpdateScheduled = !0, requestAnimationFrame(() => {
|
|
446
456
|
if (this._mouseUpdateScheduled = !1, !this._pendingMousePosition)
|
|
447
457
|
return;
|
|
448
458
|
this._mouse.x = this._pendingMousePosition.x, this._mouse.y = this._pendingMousePosition.y;
|
|
449
459
|
const c = this._mouseObjects[this._currentBrush];
|
|
450
|
-
c.mesh.scale.set(this._mouseBrushBaseScale, this._mouseBrushBaseScale, 1), c.active = !0, c.mesh.visible = !0, c.mesh.position.set(this._mouse.x, this._mouse.y, 0), c.mesh.rotation.z = Math.random() * Math.PI * 2, c.mesh.material instanceof
|
|
460
|
+
c.mesh.scale.set(this._mouseBrushBaseScale, this._mouseBrushBaseScale, 1), c.active = !0, c.mesh.visible = !0, c.mesh.position.set(this._mouse.x, this._mouse.y, 0), c.mesh.rotation.z = Math.random() * Math.PI * 2, c.mesh.material instanceof n.MeshBasicMaterial && (c.mesh.material.opacity = 1), this._currentBrush = (this._currentBrush + 1) % this._mouseObjects.length, this._pendingMousePosition = null;
|
|
451
461
|
}));
|
|
452
462
|
}
|
|
453
463
|
_createProceduralTexture() {
|
|
454
|
-
const
|
|
455
|
-
|
|
456
|
-
const t =
|
|
464
|
+
const o = document.createElement("canvas");
|
|
465
|
+
o.width = 1024, o.height = 1024;
|
|
466
|
+
const t = o.getContext("2d", { willReadFrequently: !0 });
|
|
457
467
|
if (!t)
|
|
458
|
-
return new
|
|
459
|
-
let
|
|
468
|
+
return new n.Texture();
|
|
469
|
+
let d = this._textureSeed;
|
|
460
470
|
const c = this._textureSeed;
|
|
461
|
-
function
|
|
462
|
-
const a = Math.sin(
|
|
471
|
+
function s() {
|
|
472
|
+
const a = Math.sin(d++) * 1e4;
|
|
463
473
|
return a - Math.floor(a);
|
|
464
474
|
}
|
|
465
475
|
const p = (a) => {
|
|
466
|
-
|
|
476
|
+
d = c + a;
|
|
467
477
|
}, g = this._colors.filter((a) => a.enabled).map((a) => a.color);
|
|
468
478
|
if (g.length === 0)
|
|
469
|
-
return new
|
|
470
|
-
function
|
|
471
|
-
const
|
|
479
|
+
return new n.Texture();
|
|
480
|
+
function f(a) {
|
|
481
|
+
const l = parseInt(a.replace("#", ""), 16);
|
|
472
482
|
return {
|
|
473
|
-
r:
|
|
474
|
-
g:
|
|
475
|
-
b:
|
|
483
|
+
r: l >> 16 & 255,
|
|
484
|
+
g: l >> 8 & 255,
|
|
485
|
+
b: l & 255
|
|
476
486
|
};
|
|
477
487
|
}
|
|
478
|
-
function
|
|
479
|
-
return "#" + ((1 << 24) + (Math.round(a) << 16) + (Math.round(
|
|
488
|
+
function m(a, l, h) {
|
|
489
|
+
return "#" + ((1 << 24) + (Math.round(a) << 16) + (Math.round(l) << 8) + Math.round(h)).toString(16).slice(1);
|
|
480
490
|
}
|
|
481
491
|
const u = () => {
|
|
482
|
-
const a = g[Math.floor(
|
|
483
|
-
return
|
|
484
|
-
},
|
|
485
|
-
t.fillStyle =
|
|
492
|
+
const a = g[Math.floor(s() * g.length)], l = g[Math.floor(s() * g.length)], h = s() * this._textureColorBlending, _ = f(a), S = f(l), B = _.r + (S.r - _.r) * h, N = _.g + (S.g - _.g) * h, L = _.b + (S.b - _.b) * h;
|
|
493
|
+
return m(B, N, L);
|
|
494
|
+
}, v = this._proceduralBackgroundColor || "#000000";
|
|
495
|
+
t.fillStyle = v, t.fillRect(0, 0, 1024, 1024);
|
|
486
496
|
const O = t.createLinearGradient(0, 0, 0, 1024);
|
|
487
497
|
O.addColorStop(0, u()), O.addColorStop(1, u()), t.fillStyle = O, t.fillRect(0, 0, 1024, 1024);
|
|
488
498
|
for (let a = 0; a < this._textureShapeTriangles; a++) {
|
|
489
499
|
t.fillStyle = u(), t.beginPath();
|
|
490
|
-
const
|
|
491
|
-
t.moveTo(
|
|
500
|
+
const l = s() * 1024, h = s() * 1024, _ = 100 + s() * 300;
|
|
501
|
+
t.moveTo(l, h), t.lineTo(l + (s() - 0.5) * _, h + (s() - 0.5) * _), t.lineTo(l + (s() - 0.5) * _, h + (s() - 0.5) * _), t.fill();
|
|
492
502
|
}
|
|
493
503
|
for (let a = 0; a < this._textureShapeCircles; a++) {
|
|
494
|
-
t.strokeStyle = u(), t.lineWidth = 10 +
|
|
495
|
-
const
|
|
496
|
-
t.arc(
|
|
504
|
+
t.strokeStyle = u(), t.lineWidth = 10 + s() * 50, t.beginPath();
|
|
505
|
+
const l = s() * 1024, h = s() * 1024, _ = 50 + s() * 150;
|
|
506
|
+
t.arc(l, h, _, 0, Math.PI * 2), t.stroke();
|
|
497
507
|
}
|
|
498
508
|
for (let a = 0; a < this._textureShapeBars; a++)
|
|
499
|
-
t.fillStyle = u(), t.save(), t.translate(
|
|
509
|
+
t.fillStyle = u(), t.save(), t.translate(s() * 1024, s() * 1024), t.rotate(s() * Math.PI), t.fillRect(-150, -25, 300, 50), t.restore();
|
|
500
510
|
t.lineWidth = 15, t.lineCap = "round";
|
|
501
511
|
for (let a = 0; a < this._textureShapeSquiggles; a++) {
|
|
502
512
|
t.strokeStyle = u(), t.beginPath();
|
|
503
|
-
let
|
|
504
|
-
t.moveTo(
|
|
513
|
+
let l = s() * 1024, h = s() * 1024;
|
|
514
|
+
t.moveTo(l, h);
|
|
505
515
|
for (let _ = 0; _ < 4; _++)
|
|
506
516
|
t.bezierCurveTo(
|
|
507
|
-
|
|
508
|
-
h + (
|
|
509
|
-
|
|
510
|
-
h + (
|
|
511
|
-
|
|
512
|
-
h + (
|
|
513
|
-
),
|
|
517
|
+
l + (s() - 0.5) * 300,
|
|
518
|
+
h + (s() - 0.5) * 300,
|
|
519
|
+
l + (s() - 0.5) * 300,
|
|
520
|
+
h + (s() - 0.5) * 300,
|
|
521
|
+
l + (s() - 0.5) * 300,
|
|
522
|
+
h + (s() - 0.5) * 300
|
|
523
|
+
), l += (s() - 0.5) * 300, h += (s() - 0.5) * 300;
|
|
514
524
|
t.stroke();
|
|
515
525
|
}
|
|
516
526
|
p(5e4);
|
|
@@ -518,26 +528,26 @@ class Be {
|
|
|
518
528
|
M.width = 1024, M.height = 1024;
|
|
519
529
|
const z = M.getContext("2d", { willReadFrequently: !0 });
|
|
520
530
|
if (!z)
|
|
521
|
-
return new
|
|
522
|
-
z.fillStyle =
|
|
531
|
+
return new n.Texture();
|
|
532
|
+
z.fillStyle = v, z.fillRect(0, 0, 1024, 1024);
|
|
523
533
|
let y = 0;
|
|
524
|
-
const
|
|
534
|
+
const T = [];
|
|
525
535
|
for (; y < 1024; )
|
|
526
|
-
if (
|
|
527
|
-
const
|
|
528
|
-
|
|
536
|
+
if (s() < this._textureVoidLikelihood) {
|
|
537
|
+
const l = this._textureVoidWidthMin + s() * (this._textureVoidWidthMax - this._textureVoidWidthMin);
|
|
538
|
+
T.push({ type: "void", x: y, width: l }), y += l;
|
|
529
539
|
} else {
|
|
530
|
-
const
|
|
531
|
-
|
|
540
|
+
const l = 50 + s() * 200;
|
|
541
|
+
T.push({ type: "matter", x: y, width: l }), y += l;
|
|
532
542
|
}
|
|
533
|
-
for (const a of
|
|
543
|
+
for (const a of T)
|
|
534
544
|
if (a.type === "matter") {
|
|
535
|
-
const
|
|
536
|
-
let _ =
|
|
545
|
+
const l = a.x, h = Math.min(a.x + a.width, 1024);
|
|
546
|
+
let _ = l;
|
|
537
547
|
for (; _ < h; ) {
|
|
538
|
-
const S = (2 +
|
|
548
|
+
const S = (2 + s() * 20) / this._textureBandDensity, B = Math.floor(s() * 1024);
|
|
539
549
|
z.drawImage(
|
|
540
|
-
|
|
550
|
+
o,
|
|
541
551
|
B,
|
|
542
552
|
0,
|
|
543
553
|
S,
|
|
@@ -549,25 +559,25 @@ class Be {
|
|
|
549
559
|
), _ += S;
|
|
550
560
|
}
|
|
551
561
|
}
|
|
552
|
-
const C = new
|
|
553
|
-
return C.minFilter =
|
|
562
|
+
const C = new n.CanvasTexture(M);
|
|
563
|
+
return C.minFilter = n.LinearMipmapLinearFilter, C.magFilter = n.LinearFilter, C.wrapS = n.RepeatWrapping, C.wrapT = n.RepeatWrapping, C.anisotropy = 16, C.needsUpdate = !0, C;
|
|
554
564
|
}
|
|
555
565
|
}
|
|
556
|
-
function K(
|
|
557
|
-
const c = e *
|
|
558
|
-
let
|
|
559
|
-
if (
|
|
560
|
-
const z =
|
|
561
|
-
|
|
566
|
+
function K(i, e, o) {
|
|
567
|
+
const c = e * o / 1e6 * U * D / 1.5, s = e / o, p = Math.sqrt(c * s), g = c / p;
|
|
568
|
+
let f = -U / 2, m = Math.min((f + p) / 1.5, U / 2), u = D / 4, v = Math.max((u - g) / 2, -D / 4);
|
|
569
|
+
if (s < 1) {
|
|
570
|
+
const z = s;
|
|
571
|
+
f = f * z, m = m * z;
|
|
562
572
|
const y = 1.05;
|
|
563
|
-
|
|
573
|
+
f = f * y, m = m * y, u = u * y, v = v * y;
|
|
564
574
|
}
|
|
565
575
|
const O = -100, M = 1e3;
|
|
566
|
-
|
|
576
|
+
i instanceof n.OrthographicCamera ? (i.left = f, i.right = m, i.top = u, i.bottom = v, i.near = O, i.far = M, i.updateProjectionMatrix()) : i instanceof n.PerspectiveCamera && (i.aspect = e / o, i.updateProjectionMatrix());
|
|
567
577
|
}
|
|
568
|
-
let
|
|
578
|
+
let k = null, A = null;
|
|
569
579
|
function Ce() {
|
|
570
|
-
return
|
|
580
|
+
return k || (k = `
|
|
571
581
|
void main() {
|
|
572
582
|
vUv = uv;
|
|
573
583
|
|
|
@@ -644,7 +654,7 @@ void main() {
|
|
|
644
654
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(newPosition, 1.0);
|
|
645
655
|
v_new_position = gl_Position;
|
|
646
656
|
}
|
|
647
|
-
`,
|
|
657
|
+
`, k);
|
|
648
658
|
}
|
|
649
659
|
function Me() {
|
|
650
660
|
return A || (A = `
|
|
@@ -731,8 +741,8 @@ void main() {
|
|
|
731
741
|
}
|
|
732
742
|
`, A);
|
|
733
743
|
}
|
|
734
|
-
let
|
|
735
|
-
const H = () =>
|
|
744
|
+
let R = null;
|
|
745
|
+
const H = () => R || (R = `
|
|
736
746
|
precision highp float;
|
|
737
747
|
|
|
738
748
|
struct Color {
|
|
@@ -796,7 +806,7 @@ varying vec4 v_new_position;
|
|
|
796
806
|
varying vec3 v_color;
|
|
797
807
|
varying float v_displacement_amount;
|
|
798
808
|
|
|
799
|
-
`,
|
|
809
|
+
`, R);
|
|
800
810
|
let I = null;
|
|
801
811
|
const Y = () => I || (I = `
|
|
802
812
|
|
|
@@ -953,7 +963,7 @@ float cnoise(vec3 P)
|
|
|
953
963
|
}
|
|
954
964
|
`, I);
|
|
955
965
|
let W = null;
|
|
956
|
-
const
|
|
966
|
+
const J = () => W || (W = `
|
|
957
967
|
|
|
958
968
|
vec3 saturation(vec3 rgb, float adjustment) {
|
|
959
969
|
const vec3 W = vec3(0.2125, 0.7154, 0.0721);
|
|
@@ -996,36 +1006,63 @@ vec3 hsv2rgb(vec3 c)
|
|
|
996
1006
|
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
|
997
1007
|
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
|
998
1008
|
}
|
|
999
|
-
`, W),
|
|
1000
|
-
|
|
1001
|
-
}, Pe = (
|
|
1002
|
-
const e =
|
|
1009
|
+
`, W), Z = (i) => {
|
|
1010
|
+
i.id = Q, i.href = "https://neat.firecms.co", i.target = "_blank", i.style.position = "absolute", i.style.display = "block", i.style.bottom = "0", i.style.right = "0", i.style.padding = "10px", i.style.color = "#dcdcdc", i.style.opacity = "0.8", i.style.fontFamily = "sans-serif", i.style.fontSize = "16px", i.style.fontWeight = "bold", i.style.textDecoration = "none", i.style.zIndex = "10000", i.innerHTML = "NEAT";
|
|
1011
|
+
}, Pe = (i) => {
|
|
1012
|
+
const e = i.parentElement?.getElementsByTagName("a");
|
|
1003
1013
|
if (e) {
|
|
1004
1014
|
for (let t = 0; t < e.length; t++)
|
|
1005
1015
|
if (e[t].id === Q)
|
|
1006
|
-
return
|
|
1016
|
+
return Z(e[t]), e[t];
|
|
1007
1017
|
}
|
|
1008
|
-
const
|
|
1009
|
-
return
|
|
1018
|
+
const o = document.createElement("a");
|
|
1019
|
+
return Z(o), i.parentElement?.appendChild(o), o;
|
|
1010
1020
|
};
|
|
1011
1021
|
function Oe() {
|
|
1012
|
-
const
|
|
1013
|
-
return e * 60 +
|
|
1022
|
+
const i = new Date(), e = i.getMinutes(), o = i.getSeconds();
|
|
1023
|
+
return e * 60 + o;
|
|
1014
1024
|
}
|
|
1015
|
-
function
|
|
1025
|
+
function Fe(i = 6) {
|
|
1016
1026
|
const e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
1017
|
-
let
|
|
1018
|
-
for (let t = 0; t <
|
|
1019
|
-
const
|
|
1020
|
-
|
|
1027
|
+
let o = "";
|
|
1028
|
+
for (let t = 0; t < i; t++) {
|
|
1029
|
+
const d = Math.floor(Math.random() * e.length);
|
|
1030
|
+
o += e.charAt(d);
|
|
1021
1031
|
}
|
|
1022
|
-
return
|
|
1032
|
+
return o;
|
|
1023
1033
|
}
|
|
1024
|
-
function
|
|
1025
|
-
const
|
|
1026
|
-
|
|
1034
|
+
function Te(i, e) {
|
|
1035
|
+
const o = document.createElement("a");
|
|
1036
|
+
o.download = e, o.href = i, document.body.appendChild(o), o.click(), document.body.removeChild(o);
|
|
1037
|
+
}
|
|
1038
|
+
function Be() {
|
|
1039
|
+
if (document.getElementById("neat-seo-schema"))
|
|
1040
|
+
return;
|
|
1041
|
+
const i = document.createElement("script");
|
|
1042
|
+
i.id = "neat-seo-schema", i.type = "application/ld+json", i.text = JSON.stringify({
|
|
1043
|
+
"@context": "https://schema.org",
|
|
1044
|
+
"@type": "WebSite",
|
|
1045
|
+
name: "NEAT Gradient",
|
|
1046
|
+
url: "https://neat.firecms.co",
|
|
1047
|
+
author: {
|
|
1048
|
+
"@type": "Organization",
|
|
1049
|
+
name: "FireCMS",
|
|
1050
|
+
url: "https://firecms.co"
|
|
1051
|
+
},
|
|
1052
|
+
description: "Beautiful, fast, heavily customizable, WebGL based gradients."
|
|
1053
|
+
}), document.head.appendChild(i);
|
|
1054
|
+
const e = document.createElement("div");
|
|
1055
|
+
e.style.position = "absolute", e.style.width = "1px", e.style.height = "1px", e.style.padding = "0", e.style.margin = "-1px", e.style.overflow = "hidden", e.style.clip = "rect(0, 0, 0, 0)", e.style.whiteSpace = "nowrap", e.style.borderWidth = "0";
|
|
1056
|
+
try {
|
|
1057
|
+
const o = e.attachShadow({ mode: "closed" }), t = document.createElement("a");
|
|
1058
|
+
t.href = "https://firecms.co", t.textContent = "FireCMS", o.appendChild(t);
|
|
1059
|
+
} catch {
|
|
1060
|
+
const t = document.createElement("a");
|
|
1061
|
+
t.href = "https://firecms.co", t.textContent = "FireCMS", e.appendChild(t);
|
|
1062
|
+
}
|
|
1063
|
+
document.body.appendChild(e);
|
|
1027
1064
|
}
|
|
1028
1065
|
export {
|
|
1029
|
-
|
|
1066
|
+
Ue as NeatGradient
|
|
1030
1067
|
};
|
|
1031
1068
|
//# sourceMappingURL=index.es.js.map
|