|
| 1 | +import type { LivePreset } from "./types"; |
| 2 | + |
| 3 | +export const preset: LivePreset = { |
| 4 | + id: "pattern-0609", |
| 5 | + num: 609, |
| 6 | + name: "0609", |
| 7 | + desc: "Molten Magma Heat-Map with cooling crusts", |
| 8 | + author: "Seunghun LEE", |
| 9 | + license: "CC-BY-SA-4.0", |
| 10 | + date: "2026-06-09", |
| 11 | + lineage: "AI generated and curated", |
| 12 | + code: `// Pattern: 0609 |
| 13 | +// Author: Seunghun LEE |
| 14 | +// SPDX-License-Identifier: CC-BY-SA-4.0 |
| 15 | +// Date: 2026-06-09 |
| 16 | +// Lineage: AI generated and curated |
| 17 | +// |
| 18 | +// Molten Magma Heat-Map — Emulates thermal energy color bands where bright hotspots cooling down leave dark crusts. |
| 19 | +// Knob 1: Thermal Fluid Viscosity (0.0 to 1.0) |
| 20 | +// Knob 2: Boiling Flow Speed (0.1 to 10.0) |
| 21 | +// Knob 3: Hotspot Core Expansion (0.0 to 4.9) |
| 22 | +// Knob 4: Cool Crust Fracturing (0.0 to 1.0) |
| 23 | +
|
| 24 | +export function setup(params) { |
| 25 | + params.viscosity = 0.5; |
| 26 | + params.speed = 2.0; |
| 27 | + params.expansion = 2.0; |
| 28 | + params.crust = 0.4; |
| 29 | + params.timeAcc = 0.0; |
| 30 | +} |
| 31 | +
|
| 32 | +export function update(dt, input, params) { |
| 33 | + if (input && input.knobValues) { |
| 34 | + params.viscosity = input.knobValues[0]; |
| 35 | + params.speed = input.knobValues[1]; |
| 36 | + params.expansion = input.knobValues[2]; |
| 37 | + params.crust = input.knobValues[3]; |
| 38 | + } |
| 39 | + params.timeAcc += dt * params.speed; |
| 40 | +} |
| 41 | +
|
| 42 | +export function draw(display, params, time) { |
| 43 | + let w = display.width; |
| 44 | + let h = display.height; |
| 45 | + let t = params.timeAcc; |
| 46 | +
|
| 47 | + let visc = 0.02 + params.viscosity * 0.08; |
| 48 | + let coreShift = params.expansion - 2.5; |
| 49 | +
|
| 50 | + for (let y = 0; y < h; y++) { |
| 51 | + for (let x = 0; x < w; x++) { |
| 52 | + |
| 53 | + // Multiple layers of wave signals create fluid thermal paths |
| 54 | + let n1 = Math.sin(x * visc + t) * Math.cos(y * visc - t); |
| 55 | + let n2 = Math.sin((x - w/2) * 0.05 - t * 0.4) * Math.sin((y - h/2) * 0.05 + t * 0.6); |
| 56 | + let n3 = Math.cos(Math.sqrt((x-w/2)*(x-w/2) + (y-h/2)*(y-h/2)) * 0.1 - t * 1.5); |
| 57 | +
|
| 58 | + let heatSum = (n1 + n2 * 0.7 + n3 * 0.5) / 2.2; |
| 59 | + heatSum = heatSum + coreShift * 0.3; // Manual shift balancing |
| 60 | + let temp = Math.max(0.0, Math.min(1.0, (heatSum + 1.0) * 0.5)); |
| 61 | +
|
| 62 | + let r = 0, g = 0, b = 0; |
| 63 | +
|
| 64 | + // Heat map color palette step assignments |
| 65 | + if (temp > 0.85) { |
| 66 | + // Incandescent Superhot White Core |
| 67 | + r = 255; g = 255; b = 230; |
| 68 | + } else if (temp > 0.65) { |
| 69 | + // Liquid Yellow Plasma |
| 70 | + r = 255; g = 180 + Math.floor((temp - 0.65) * 375); b = 20; |
| 71 | + } else if (temp > 0.4) { |
| 72 | + // Flowing Viscous Orange-Red |
| 73 | + r = 220; g = Math.floor((temp - 0.4) * 700); b = 5; |
| 74 | + } else if (temp > 0.18) { |
| 75 | + // Deep Cooled Dormant Crimson |
| 76 | + r = 40 + Math.floor((temp - 0.18) * 800); g = 0; b = 0; |
| 77 | + } else { |
| 78 | + // Charcoal Rock Base |
| 79 | + r = 10; g = 5; b = 15; |
| 80 | + } |
| 81 | +
|
| 82 | + // Introduce cool surface fractures/cracking maps |
| 83 | + if (params.crust > 0.05) { |
| 84 | + let crackPattern = Math.sin(x * 1.5) * Math.cos(y * 1.5); |
| 85 | + if (crackPattern > 1.0 - params.crust && temp < 0.6) { |
| 86 | + // Reduce thermal radiation, exposing dark deep cracks |
| 87 | + r = Math.floor(r * 0.15); |
| 88 | + g = 0; |
| 89 | + b = Math.floor(b * 0.1); |
| 90 | + } |
| 91 | + } |
| 92 | +
|
| 93 | + display.setPixel(x, y, r, g, b); |
| 94 | + } |
| 95 | + } |
| 96 | +}`, |
| 97 | +}; |
0 commit comments