feat: colors
This commit is contained in:
@@ -7,20 +7,19 @@ class VoxelFirefliesPreset extends BasePreset {
|
||||
constructor(width = 16, height = 16) {
|
||||
super(width, height);
|
||||
this.fireflies = [];
|
||||
this.paletteStops = [
|
||||
{ stop: 0.0, color: hexToRgb('02030a') },
|
||||
{ stop: 0.2, color: hexToRgb('031c2d') },
|
||||
{ stop: 0.4, color: hexToRgb('053d4a') },
|
||||
{ stop: 0.6, color: hexToRgb('107b68') },
|
||||
{ stop: 0.8, color: hexToRgb('14c491') },
|
||||
{ stop: 1.0, color: hexToRgb('f2ffd2') },
|
||||
];
|
||||
this.defaultParameters = {
|
||||
fireflyCount: 18,
|
||||
hoverSpeed: 0.6,
|
||||
glowSpeed: 1.8,
|
||||
trailDecay: 0.8,
|
||||
brightness: 1.0,
|
||||
color1: '02030a',
|
||||
color2: '031c2d',
|
||||
color3: '053d4a',
|
||||
color4: '107b68',
|
||||
color5: '14c491',
|
||||
color6: 'f2ffd2',
|
||||
accentColor: 'ffd966',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -69,10 +68,11 @@ class VoxelFirefliesPreset extends BasePreset {
|
||||
firefly.glowPhase += deltaSeconds * (this.getParameter('glowSpeed') || 1.8) * (0.7 + Math.random() * 0.6);
|
||||
}
|
||||
|
||||
drawFirefly(firefly) {
|
||||
drawFirefly(firefly, paletteStops) {
|
||||
const baseGlow = (Math.sin(firefly.glowPhase) + 1) * 0.5;
|
||||
const col = Math.round(firefly.x);
|
||||
const row = Math.round(firefly.y);
|
||||
const accentColor = this.getParameter('accentColor') || 'ffd966';
|
||||
|
||||
for (let dy = -1; dy <= 1; ++dy) {
|
||||
for (let dx = -1; dx <= 1; ++dx) {
|
||||
@@ -89,9 +89,9 @@ class VoxelFirefliesPreset extends BasePreset {
|
||||
continue;
|
||||
}
|
||||
|
||||
this.frame[toIndex(sampleX, sampleY, this.width)] = samplePalette(this.paletteStops, intensity);
|
||||
this.frame[toIndex(sampleX, sampleY, this.width)] = samplePalette(paletteStops, intensity);
|
||||
if (distance === 0) {
|
||||
addHexColor(this.frame, toIndex(sampleX, sampleY, this.width), 'ffd966', intensity * 1.6);
|
||||
addHexColor(this.frame, toIndex(sampleX, sampleY, this.width), accentColor, intensity * 1.6);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -103,6 +103,15 @@ class VoxelFirefliesPreset extends BasePreset {
|
||||
const fireflyCount = this.getParameter('fireflyCount') || 18;
|
||||
const brightness = this.getParameter('brightness') || 1.0;
|
||||
|
||||
const paletteStops = [
|
||||
{ stop: 0.0, color: hexToRgb(this.getParameter('color1') || '02030a') },
|
||||
{ stop: 0.2, color: hexToRgb(this.getParameter('color2') || '031c2d') },
|
||||
{ stop: 0.4, color: hexToRgb(this.getParameter('color3') || '053d4a') },
|
||||
{ stop: 0.6, color: hexToRgb(this.getParameter('color4') || '107b68') },
|
||||
{ stop: 0.8, color: hexToRgb(this.getParameter('color5') || '14c491') },
|
||||
{ stop: 1.0, color: hexToRgb(this.getParameter('color6') || 'f2ffd2') },
|
||||
];
|
||||
|
||||
fadeFrame(this.frame, trailDecay);
|
||||
|
||||
// Update firefly count if it changed
|
||||
@@ -115,7 +124,7 @@ class VoxelFirefliesPreset extends BasePreset {
|
||||
|
||||
this.fireflies.forEach((firefly) => {
|
||||
this.updateFirefly(firefly, 0.016); // Assume 60 FPS
|
||||
this.drawFirefly(firefly);
|
||||
this.drawFirefly(firefly, paletteStops);
|
||||
});
|
||||
|
||||
return this.frame;
|
||||
@@ -131,6 +140,13 @@ class VoxelFirefliesPreset extends BasePreset {
|
||||
glowSpeed: { type: 'range', min: 1.0, max: 3.0, step: 0.2, default: 1.8 },
|
||||
trailDecay: { type: 'range', min: 0.7, max: 0.95, step: 0.05, default: 0.8 },
|
||||
brightness: { type: 'range', min: 0.5, max: 1.5, step: 0.1, default: 1.0 },
|
||||
color1: { type: 'color', default: '02030a' },
|
||||
color2: { type: 'color', default: '031c2d' },
|
||||
color3: { type: 'color', default: '053d4a' },
|
||||
color4: { type: 'color', default: '107b68' },
|
||||
color5: { type: 'color', default: '14c491' },
|
||||
color6: { type: 'color', default: 'f2ffd2' },
|
||||
accentColor: { type: 'color', default: 'ffd966' },
|
||||
},
|
||||
width: this.width,
|
||||
height: this.height,
|
||||
|
||||
Reference in New Issue
Block a user