@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/index.es.js CHANGED
@@ -1,6 +1,16 @@
1
- import * as l from "three";
2
- const U = 50, D = 80, be = !0, j = 6, ze = new l.Clock(), Q = Te();
3
- class Be {
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 l.Vector2(-1e3, -1e3);
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 l.Color();
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: s,
83
+ ref: o,
74
84
  speed: t = 4,
75
- horizontalPressure: f = 3,
85
+ horizontalPressure: d = 3,
76
86
  verticalPressure: c = 3,
77
- waveFrequencyX: o = 5,
87
+ waveFrequencyX: s = 5,
78
88
  waveFrequencyY: p = 5,
79
89
  waveAmplitude: g = 3,
80
- colors: d,
81
- highlights: v = 4,
90
+ colors: f,
91
+ highlights: m = 4,
82
92
  shadows: u = 4,
83
- colorSaturation: x = 0,
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: F = 0,
98
+ grainSparsity: T = 0,
89
99
  grainSpeed: C = 0.1,
90
100
  wireframe: a = !1,
91
- backgroundColor: n = "#FFFFFF",
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: V = 4,
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: le = 0.96,
107
- mouseDarken: ne = 0,
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: fe = 2.15,
113
- textureColorBlending: de = 0.01,
122
+ textureBandDensity: de = 2.15,
123
+ textureColorBlending: fe = 0.01,
114
124
  textureSeed: pe = 333,
115
- textureEase: ve = 0.5,
116
- proceduralBackgroundColor: xe = "#000000",
125
+ textureEase: me = 0.5,
126
+ proceduralBackgroundColor: ve = "#000000",
117
127
  textureShapeTriangles: ge = 20,
118
- textureShapeCircles: me = 15,
128
+ textureShapeCircles: xe = 15,
119
129
  textureShapeBars: ye = 15,
120
130
  textureShapeSquiggles: we = 10
121
131
  } = e;
122
- this._ref = s, this.destroy = this.destroy.bind(this), this._initScene = this._initScene.bind(this), this._buildMaterial = this._buildMaterial.bind(this), this.speed = t, this.horizontalPressure = f, this.verticalPressure = c, this.waveFrequencyX = o, this.waveFrequencyY = p, this.waveAmplitude = g, this.colorBlending = M, this.grainScale = z, this.grainIntensity = y, this.grainSparsity = F, this.grainSpeed = C, this.colors = d, this.shadows = u, this.highlights = v, this.colorSaturation = x, this.colorBrightness = O, this.wireframe = a, this.backgroundColor = n, this.backgroundAlpha = h, this.yOffset = B, this.yOffsetWaveMultiplier = N, this.yOffsetColorMultiplier = V, 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 = le, this.mouseDarken = ne, this.enableProceduralTexture = ue, this.textureVoidLikelihood = ce, this.textureVoidWidthMin = _e, this.textureVoidWidthMax = he, this.textureBandDensity = fe, this.textureColorBlending = de, this.textureSeed = pe, this.textureEase = ve, this._proceduralBackgroundColor = xe, this._textureShapeTriangles = ge, this._textureShapeCircles = me, this._textureShapeBars = ye, this._textureShapeSquiggles = we, this._setupMouseInteraction(), this.sceneState = this._initScene(_);
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: T } = this.sceneState;
126
- if (this._linkCheckCounter++, this._linkCheckCounter >= 300 && (this._linkCheckCounter = 0, (!this._linkElement || !document.contains(this._linkElement)) && (this._linkElement = Pe(s))), this._cachedUniforms) {
127
- const i = this._cachedUniforms;
128
- G += ze.getDelta() * this._speed, i.u_time.value = G, i.u_resolution.value.set(this._ref.width, this._ref.height), i.u_color_pressure.value.set(this._horizontalPressure, this._verticalPressure), i.u_wave_frequency_x.value = this._waveFrequencyX, i.u_wave_frequency_y.value = this._waveFrequencyY, i.u_wave_amplitude.value = this._waveAmplitude, i.u_color_blending.value = this._colorBlending, i.u_shadows.value = this._shadows, i.u_highlights.value = this._highlights, i.u_saturation.value = this._saturation, i.u_brightness.value = this._brightness, i.u_grain_intensity.value = this._grainIntensity, i.u_grain_sparsity.value = this._grainSparsity, i.u_grain_speed.value = this._grainSpeed, i.u_grain_scale.value = this._grainScale, i.u_y_offset.value = this._yOffset, i.u_y_offset_wave_multiplier.value = this._yOffsetWaveMultiplier, i.u_y_offset_color_multiplier.value = this._yOffsetColorMultiplier, i.u_y_offset_flow_multiplier.value = this._yOffsetFlowMultiplier, i.u_flow_distortion_a.value = this._flowDistortionA, i.u_flow_distortion_b.value = this._flowDistortionB, i.u_flow_scale.value = this._flowScale, i.u_flow_ease.value = this._flowEase, i.u_flow_enabled.value = this._flowEnabled ? 1 : 0, i.u_mouse_distortion_strength.value = this._mouseDistortionStrength, i.u_mouse_distortion_radius.value = this._mouseDistortionRadius, i.u_mouse_darken.value = this._mouseDarken, i.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), i.u_procedural_texture.value = this._proceduralTexture, i.u_texture_ease.value = this._textureEase, this.sceneState.meshes[0].material.wireframe = this._wireframe;
129
- const m = Date.now();
130
- if (this._colorsChanged || m - this._lastColorUpdate > 100) {
131
- this._lastColorUpdate = m, this._colorsChanged = !1;
132
- const q = i.u_colors.value;
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 L = this._colors[P];
136
- q[P].is_active = L.enabled ? 1 : 0, q[P].color.setStyle(L.color, ""), q[P].influence = L.influence || 0;
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
- i.u_colors_count.value = j;
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 i = !1;
144
- for (let m = 0; m < this._mouseObjects.length; m++) {
145
- const b = this._mouseObjects[m];
146
- b.mesh.visible && (i = !0, b.mesh.rotation.z += 0.01, b.mesh.material instanceof l.MeshBasicMaterial && (b.mesh.material.opacity *= this._mouseDecayRate, b.mesh.material.opacity < 0.01 && (b.mesh.visible = !1)));
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 (i) {
158
+ if (r) {
149
159
  w.getClearColor(this._tempClearColor);
150
- const m = w.getClearAlpha();
151
- w.setClearColor(0, 0), w.setRenderTarget(this._mouseFBO), w.clear(), w.render(this._sceneMouse, this._cameraMouse), w.setRenderTarget(null), w.setClearColor(this._tempClearColor, m), this._cachedUniforms && (this._cachedUniforms.u_mouse_texture.value = this._mouseFBO.texture);
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(T, E), this.requestRef = requestAnimationFrame(X);
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, T = E.clientWidth, i = E.clientHeight;
157
- if (this.sceneState.renderer.setSize(T, i, !1), K(this.sceneState.camera, T, i), this._mouseFBO && this._cameraMouse) {
158
- const m = i / 2, b = T / i;
159
- this._mouseFBO.setSize(T / 2, i / 2), this._cameraMouse.left = -m * b, this._cameraMouse.right = m * b, this._cameraMouse.top = m, this._cameraMouse.bottom = -m, this._cameraMouse.updateProjectionMatrix();
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(s), X();
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((s) => s.dispose()) : e.material.dispose();
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 s = this._ref.toDataURL("image/png");
176
- console.log("data", s), Fe(s, e);
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 s = this._ref.width, t = this._ref.height;
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((x) => x.dispose()) : u.material.dispose();
347
+ u.geometry.dispose(), Array.isArray(u.material) ? u.material.forEach((v) => v.dispose()) : u.material.dispose();
338
348
  }));
339
- const f = new l.WebGLRenderer({
349
+ const d = new n.WebGLRenderer({
340
350
  alpha: !0,
341
351
  preserveDrawingBuffer: !0,
342
352
  canvas: this._ref
343
353
  });
344
- f.setClearColor(16711680, 0.5), f.setSize(s, t, !1);
345
- const c = [], o = new l.Scene(), p = this._buildMaterial(s, t), g = new l.PlaneGeometry(U, D, 240 * e, 240 * e), d = new l.Mesh(g, p);
346
- d.rotation.x = -Math.PI / 3.5, d.position.z = -1, c.push(d), o.add(d);
347
- const v = new l.OrthographicCamera(0, 0, 0, 0, 0, 0);
348
- return v.position.z = 5, K(v, s, t), {
349
- renderer: f,
350
- camera: v,
351
- scene: o,
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, s) {
357
- const t = Array.from({ length: j }).map((o, p) => ({
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 l.Color(p < this._colors.length ? this._colors[p].color : 0),
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
- })), f = {
371
+ })), d = {
362
372
  u_time: { value: 0 },
363
- u_color_pressure: { value: new l.Vector2(this._horizontalPressure, this._verticalPressure) },
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 l.Vector2(e, s) },
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 l.ShaderMaterial({
398
- uniforms: f,
399
- vertexShader: H() + Y() + Z() + Ce(),
400
- fragmentShader: H() + Z() + Y() + Me()
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 = f, c.wireframe = be, c;
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, s = this._ref.height;
408
- this._mouseFBO = new l.WebGLRenderTarget(e / 2, s / 2), this._sceneMouse = new l.Scene();
409
- const t = s / 2, f = e / s;
410
- this._cameraMouse = new l.OrthographicCamera(
411
- -t * f,
412
- t * f,
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 o = c.getContext("2d");
421
- if (o) {
422
- const u = o.createRadialGradient(64, 64, 0, 64, 64, 64);
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)"), o.fillStyle = u, o.fillRect(0, 0, 128, 128);
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 l.CanvasTexture(c), g = new l.MeshBasicMaterial({
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: l.AdditiveBlending
431
- }), d = new l.PlaneGeometry(200, 200), v = 50;
432
- for (let u = 0; u < v; u++) {
433
- const x = new l.Mesh(d, g.clone());
434
- x.visible = !1, this._sceneMouse.add(x), this._mouseObjects.push({ mesh: x, active: !1 });
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 s = this._ref.getBoundingClientRect(), t = this._ref.width, f = this._ref.height;
451
+ const o = this._ref.getBoundingClientRect(), t = this._ref.width, d = this._ref.height;
442
452
  this._pendingMousePosition = {
443
- x: e.clientX - s.left - t / 2,
444
- y: -(e.clientY - s.top - f / 2)
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 l.MeshBasicMaterial && (c.mesh.material.opacity = 1), this._currentBrush = (this._currentBrush + 1) % this._mouseObjects.length, this._pendingMousePosition = null;
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 s = document.createElement("canvas");
455
- s.width = 1024, s.height = 1024;
456
- const t = s.getContext("2d", { willReadFrequently: !0 });
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 l.Texture();
459
- let f = this._textureSeed;
468
+ return new n.Texture();
469
+ let d = this._textureSeed;
460
470
  const c = this._textureSeed;
461
- function o() {
462
- const a = Math.sin(f++) * 1e4;
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
- f = c + a;
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 l.Texture();
470
- function d(a) {
471
- const n = parseInt(a.replace("#", ""), 16);
479
+ return new n.Texture();
480
+ function f(a) {
481
+ const l = parseInt(a.replace("#", ""), 16);
472
482
  return {
473
- r: n >> 16 & 255,
474
- g: n >> 8 & 255,
475
- b: n & 255
483
+ r: l >> 16 & 255,
484
+ g: l >> 8 & 255,
485
+ b: l & 255
476
486
  };
477
487
  }
478
- function v(a, n, h) {
479
- return "#" + ((1 << 24) + (Math.round(a) << 16) + (Math.round(n) << 8) + Math.round(h)).toString(16).slice(1);
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(o() * g.length)], n = g[Math.floor(o() * g.length)], h = o() * this._textureColorBlending, _ = d(a), S = d(n), B = _.r + (S.r - _.r) * h, N = _.g + (S.g - _.g) * h, V = _.b + (S.b - _.b) * h;
483
- return v(B, N, V);
484
- }, x = this._proceduralBackgroundColor || "#000000";
485
- t.fillStyle = x, t.fillRect(0, 0, 1024, 1024);
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 n = o() * 1024, h = o() * 1024, _ = 100 + o() * 300;
491
- t.moveTo(n, h), t.lineTo(n + (o() - 0.5) * _, h + (o() - 0.5) * _), t.lineTo(n + (o() - 0.5) * _, h + (o() - 0.5) * _), t.fill();
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 + o() * 50, t.beginPath();
495
- const n = o() * 1024, h = o() * 1024, _ = 50 + o() * 150;
496
- t.arc(n, h, _, 0, Math.PI * 2), t.stroke();
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(o() * 1024, o() * 1024), t.rotate(o() * Math.PI), t.fillRect(-150, -25, 300, 50), t.restore();
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 n = o() * 1024, h = o() * 1024;
504
- t.moveTo(n, h);
513
+ let l = s() * 1024, h = s() * 1024;
514
+ t.moveTo(l, h);
505
515
  for (let _ = 0; _ < 4; _++)
506
516
  t.bezierCurveTo(
507
- n + (o() - 0.5) * 300,
508
- h + (o() - 0.5) * 300,
509
- n + (o() - 0.5) * 300,
510
- h + (o() - 0.5) * 300,
511
- n + (o() - 0.5) * 300,
512
- h + (o() - 0.5) * 300
513
- ), n += (o() - 0.5) * 300, h += (o() - 0.5) * 300;
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 l.Texture();
522
- z.fillStyle = x, z.fillRect(0, 0, 1024, 1024);
531
+ return new n.Texture();
532
+ z.fillStyle = v, z.fillRect(0, 0, 1024, 1024);
523
533
  let y = 0;
524
- const F = [];
534
+ const T = [];
525
535
  for (; y < 1024; )
526
- if (o() < this._textureVoidLikelihood) {
527
- const n = this._textureVoidWidthMin + o() * (this._textureVoidWidthMax - this._textureVoidWidthMin);
528
- F.push({ type: "void", x: y, width: n }), y += n;
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 n = 50 + o() * 200;
531
- F.push({ type: "matter", x: y, width: n }), y += n;
540
+ const l = 50 + s() * 200;
541
+ T.push({ type: "matter", x: y, width: l }), y += l;
532
542
  }
533
- for (const a of F)
543
+ for (const a of T)
534
544
  if (a.type === "matter") {
535
- const n = a.x, h = Math.min(a.x + a.width, 1024);
536
- let _ = n;
545
+ const l = a.x, h = Math.min(a.x + a.width, 1024);
546
+ let _ = l;
537
547
  for (; _ < h; ) {
538
- const S = (2 + o() * 20) / this._textureBandDensity, B = Math.floor(o() * 1024);
548
+ const S = (2 + s() * 20) / this._textureBandDensity, B = Math.floor(s() * 1024);
539
549
  z.drawImage(
540
- s,
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 l.CanvasTexture(M);
553
- return C.minFilter = l.LinearMipmapLinearFilter, C.magFilter = l.LinearFilter, C.wrapS = l.RepeatWrapping, C.wrapT = l.RepeatWrapping, C.anisotropy = 16, C.needsUpdate = !0, C;
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(r, e, s) {
557
- const c = e * s / 1e6 * U * D / 1.5, o = e / s, p = Math.sqrt(c * o), g = c / p;
558
- let d = -U / 2, v = Math.min((d + p) / 1.5, U / 2), u = D / 4, x = Math.max((u - g) / 2, -D / 4);
559
- if (o < 1) {
560
- const z = o;
561
- d = d * z, v = v * z;
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
- d = d * y, v = v * y, u = u * y, x = x * y;
573
+ f = f * y, m = m * y, u = u * y, v = v * y;
564
574
  }
565
575
  const O = -100, M = 1e3;
566
- r instanceof l.OrthographicCamera ? (r.left = d, r.right = v, r.top = u, r.bottom = x, r.near = O, r.far = M, r.updateProjectionMatrix()) : r instanceof l.PerspectiveCamera && (r.aspect = e / s, r.updateProjectionMatrix());
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 R = null, A = null;
578
+ let k = null, A = null;
569
579
  function Ce() {
570
- return R || (R = `
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
- `, R);
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 k = null;
735
- const H = () => k || (k = `
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
- `, k);
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 Z = () => W || (W = `
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), J = (r) => {
1000
- r.id = Q, r.href = "https://neat.firecms.co", r.target = "_blank", r.style.position = "absolute", r.style.display = "block", r.style.bottom = "0", r.style.right = "0", r.style.padding = "10px", r.style.color = "#dcdcdc", r.style.opacity = "0.8", r.style.fontFamily = "sans-serif", r.style.fontSize = "16px", r.style.fontWeight = "bold", r.style.textDecoration = "none", r.style.zIndex = "10000", r.innerHTML = "NEAT";
1001
- }, Pe = (r) => {
1002
- const e = r.parentElement?.getElementsByTagName("a");
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 J(e[t]), e[t];
1016
+ return Z(e[t]), e[t];
1007
1017
  }
1008
- const s = document.createElement("a");
1009
- return J(s), r.parentElement?.appendChild(s), s;
1018
+ const o = document.createElement("a");
1019
+ return Z(o), i.parentElement?.appendChild(o), o;
1010
1020
  };
1011
1021
  function Oe() {
1012
- const r = new Date(), e = r.getMinutes(), s = r.getSeconds();
1013
- return e * 60 + s;
1022
+ const i = new Date(), e = i.getMinutes(), o = i.getSeconds();
1023
+ return e * 60 + o;
1014
1024
  }
1015
- function Te(r = 6) {
1025
+ function Fe(i = 6) {
1016
1026
  const e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
1017
- let s = "";
1018
- for (let t = 0; t < r; t++) {
1019
- const f = Math.floor(Math.random() * e.length);
1020
- s += e.charAt(f);
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 s;
1032
+ return o;
1023
1033
  }
1024
- function Fe(r, e) {
1025
- const s = document.createElement("a");
1026
- s.download = e, s.href = r, document.body.appendChild(s), s.click(), document.body.removeChild(s);
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
- Be as NeatGradient
1066
+ Ue as NeatGradient
1030
1067
  };
1031
1068
  //# sourceMappingURL=index.es.js.map