feat: colors
This commit is contained in:
@@ -8,19 +8,19 @@ class CircuitPulsePreset extends BasePreset {
|
||||
super(width, height);
|
||||
this.paths = [];
|
||||
this.pulses = [];
|
||||
this.paletteStops = [
|
||||
{ stop: 0.0, color: hexToRgb('020209') },
|
||||
{ stop: 0.3, color: hexToRgb('023047') },
|
||||
{ stop: 0.6, color: hexToRgb('115173') },
|
||||
{ stop: 0.8, color: hexToRgb('1ca78f') },
|
||||
{ stop: 1.0, color: hexToRgb('94fdf3') },
|
||||
];
|
||||
this.accentColors = ['14f5ff', 'a7ff4d', 'ffcc3f'];
|
||||
this.defaultParameters = {
|
||||
pathFade: 0.85,
|
||||
pulseLength: 6,
|
||||
pulseSpeed: 5.0,
|
||||
pulseCount: 3,
|
||||
color1: '020209',
|
||||
color2: '023047',
|
||||
color3: '115173',
|
||||
color4: '1ca78f',
|
||||
color5: '94fdf3',
|
||||
accentColor1: '14f5ff',
|
||||
accentColor2: 'a7ff4d',
|
||||
accentColor3: 'ffcc3f',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -65,7 +65,12 @@ class CircuitPulsePreset extends BasePreset {
|
||||
}
|
||||
|
||||
spawnPulse(pathIndex) {
|
||||
const color = this.accentColors[pathIndex % this.accentColors.length];
|
||||
const accentColors = [
|
||||
this.getParameter('accentColor1') || '14f5ff',
|
||||
this.getParameter('accentColor2') || 'a7ff4d',
|
||||
this.getParameter('accentColor3') || 'ffcc3f',
|
||||
];
|
||||
const color = accentColors[pathIndex % accentColors.length];
|
||||
return {
|
||||
pathIndex,
|
||||
position: 0,
|
||||
@@ -95,6 +100,13 @@ class CircuitPulsePreset extends BasePreset {
|
||||
}
|
||||
|
||||
const pulseLength = this.getParameter('pulseLength');
|
||||
const paletteStops = [
|
||||
{ stop: 0.0, color: hexToRgb(this.getParameter('color1') || '020209') },
|
||||
{ stop: 0.3, color: hexToRgb(this.getParameter('color2') || '023047') },
|
||||
{ stop: 0.6, color: hexToRgb(this.getParameter('color3') || '115173') },
|
||||
{ stop: 0.8, color: hexToRgb(this.getParameter('color4') || '1ca78f') },
|
||||
{ stop: 1.0, color: hexToRgb(this.getParameter('color5') || '94fdf3') },
|
||||
];
|
||||
|
||||
for (let offset = 0; offset < pulseLength; ++offset) {
|
||||
const index = Math.floor(pulse.position) - offset;
|
||||
@@ -104,7 +116,7 @@ class CircuitPulsePreset extends BasePreset {
|
||||
|
||||
const { x, y } = path[index];
|
||||
const intensity = Math.max(0, 1 - offset / pulseLength);
|
||||
const baseColor = samplePalette(this.paletteStops, intensity);
|
||||
const baseColor = samplePalette(paletteStops, intensity);
|
||||
this.frame[toIndex(x, y, this.width)] = baseColor;
|
||||
addHexColor(this.frame, toIndex(x, y, this.width), pulse.color, intensity * 1.4);
|
||||
}
|
||||
@@ -142,6 +154,14 @@ class CircuitPulsePreset extends BasePreset {
|
||||
pulseLength: { type: 'range', min: 3, max: 12, step: 1, default: 6 },
|
||||
pulseSpeed: { type: 'range', min: 2.0, max: 8.0, step: 0.5, default: 5.0 },
|
||||
pulseCount: { type: 'range', min: 1, max: 6, step: 1, default: 3 },
|
||||
color1: { type: 'color', default: '020209' },
|
||||
color2: { type: 'color', default: '023047' },
|
||||
color3: { type: 'color', default: '115173' },
|
||||
color4: { type: 'color', default: '1ca78f' },
|
||||
color5: { type: 'color', default: '94fdf3' },
|
||||
accentColor1: { type: 'color', default: '14f5ff' },
|
||||
accentColor2: { type: 'color', default: 'a7ff4d' },
|
||||
accentColor3: { type: 'color', default: 'ffcc3f' },
|
||||
},
|
||||
width: this.width,
|
||||
height: this.height,
|
||||
|
||||
Reference in New Issue
Block a user