feat: colors

This commit is contained in:
2025-10-12 10:35:56 +02:00
parent 91d8bd410c
commit 9a75b23169
12 changed files with 272 additions and 136 deletions

View File

@@ -7,14 +7,6 @@ class WormholeTunnelPreset extends BasePreset {
constructor(width = 16, height = 16) {
super(width, height);
this.timeSeconds = 0;
this.paletteStops = [
{ stop: 0.0, color: hexToRgb('010005') },
{ stop: 0.2, color: hexToRgb('07204f') },
{ stop: 0.45, color: hexToRgb('124aa0') },
{ stop: 0.7, color: hexToRgb('36a5ff') },
{ stop: 0.87, color: hexToRgb('99e6ff') },
{ stop: 1.0, color: hexToRgb('f1fbff') },
];
this.defaultParameters = {
ringDensity: 8,
ringSpeed: 1.4,
@@ -23,6 +15,12 @@ class WormholeTunnelPreset extends BasePreset {
twistSpeed: 0.9,
coreExponent: 1.6,
brightness: 1.0,
color1: '010005',
color2: '07204f',
color3: '124aa0',
color4: '36a5ff',
color5: '99e6ff',
color6: 'f1fbff',
};
}
@@ -32,6 +30,15 @@ class WormholeTunnelPreset extends BasePreset {
const frame = createFrame(this.width, this.height);
const brightness = this.getParameter('brightness') || 1.0;
const paletteStops = [
{ stop: 0.0, color: hexToRgb(this.getParameter('color1') || '010005') },
{ stop: 0.2, color: hexToRgb(this.getParameter('color2') || '07204f') },
{ stop: 0.45, color: hexToRgb(this.getParameter('color3') || '124aa0') },
{ stop: 0.7, color: hexToRgb(this.getParameter('color4') || '36a5ff') },
{ stop: 0.87, color: hexToRgb(this.getParameter('color5') || '99e6ff') },
{ stop: 1.0, color: hexToRgb(this.getParameter('color6') || 'f1fbff') },
];
const cx = (this.width - 1) / 2;
const cy = (this.height - 1) / 2;
const radiusNorm = Math.hypot(cx, cy) || 1;
@@ -51,7 +58,7 @@ class WormholeTunnelPreset extends BasePreset {
const value = clamp(ring * 0.6 + depth * 0.3 + twist * 0.1, 0, 1);
let color = samplePalette(this.paletteStops, value);
let color = samplePalette(paletteStops, value);
// Apply brightness
if (brightness < 1.0) {
@@ -80,6 +87,12 @@ class WormholeTunnelPreset extends BasePreset {
twistSpeed: { type: 'range', min: 0.3, max: 1.5, step: 0.1, default: 0.9 },
coreExponent: { type: 'range', min: 1.0, max: 2.5, step: 0.1, default: 1.6 },
brightness: { type: 'range', min: 0.3, max: 1.0, step: 0.1, default: 1.0 },
color1: { type: 'color', default: '010005' },
color2: { type: 'color', default: '07204f' },
color3: { type: 'color', default: '124aa0' },
color4: { type: 'color', default: '36a5ff' },
color5: { type: 'color', default: '99e6ff' },
color6: { type: 'color', default: 'f1fbff' },
},
width: this.width,
height: this.height,