Last active
August 4, 2025 23:08
-
-
Save jasoncoon/6bec69d43f3183ca28fe68376d9396d1 to your computer and use it in GitHub Desktop.
Fibonacci Playground pattern for Fibonacci256 & Pixelblaze
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fibonacci Playground pattern for Fibonacci256 & Pixelblaze by Jason Coon | |
// Fibonacci256: https://www.evilgeniuslabs.org/fibonacci256-hdr-pixelblaze | |
// Pixelblaze: https://electromage.com | |
export var increment = 1; | |
export var autoIncrement = false; | |
export var speed = .165; | |
export var smooth = false; | |
export function inputNumberIncrement(v) { | |
increment = min(v, pixelCount - 1); | |
increment = max(v, 1); | |
} | |
export function toggleAuto(v) { autoIncrement = v; } | |
export function sliderSpeed(v) { speed = v; } | |
export function toggleSmooth(v) { smooth = v; } | |
var values = array(pixelCount); | |
export function beforeRender(delta) { | |
if (autoIncrement) { | |
increment += speed * (.015 * .05); | |
if (increment > 22) increment = 1; | |
} | |
hueTime = time(.2); | |
} | |
export function render2D(index, x, y) { | |
var f = physicalToFibonacci[index]; | |
// slowly dim all pixels | |
v = values[index] * .999; | |
v = 0; | |
var inc = increment; | |
if (!smooth) { | |
inc = trunc(inc); | |
} | |
// add value to pixel if it's a multiple of offset | |
if (f % inc < 1) { | |
v += .99 | |
} | |
// make sure v < 1 | |
v = min(v, 1); | |
h = hueTime - (f / pixelCount * .25); | |
s = 1; | |
v = v * v * v // gamma | |
hsv(h, s, v); | |
values[index] = v; | |
} | |
// map from the pixels' physical index to fibonacci index: (radius * pixelCount), 0 in the center, 255 for the last, outermost pixel | |
var physicalToFibonacci = [ 0, 21, 42, 63, 84, 105, 126, 147, 168, 189, 210, 231, 252, 239, 218, 197, 176, 155, 134, 113, 92, 71, 50, 29, 8, 16, 37, 58, 79, 100, 121, 142, 163, 184, 205, 226, 247, 255, 234, 213, 192, 171, 150, 129, 108, 87, 66, 45, 24, 3, 11, 32, 53, 74, 95, 116, 137, 158, 179, 200, 221, 242, 250, 229, 208, 187, 166, 145, 124, 103, 82, 61, 40, 19, 6, 27, 48, 69, 90, 111, 132, 153, 174, 195, 216, 237, 245, 224, 203, 182, 161, 140, 119, 98, 77, 56, 35, 14, 1, 22, 43, 64, 85, 106, 127, 148, 169, 190, 211, 232, 253, 240, 219, 198, 177, 156, 135, 114, 93, 72, 51, 30, 9, 17, 38, 59, 80, 101, 122, 143, 164, 185, 206, 227, 248, 235, 214, 193, 172, 151, 130, 109, 88, 67, 46, 25, 4, 12, 33, 54, 75, 96, 117, 138, 159, 180, 201, 222, 243, 251, 230, 209, 188, 167, 146, 125, 104, 83, 62, 41, 20, 7, 28, 49, 70, 91, 112, 133, 154, 175, 196, 217, 238, 246, 225, 204, 183, 162, 141, 120, 99, 78, 57, 36, 15, 2, 23, 44, 65, 86, 107, 128, 149, 170, 191, 212, 233, 254, 241, 220, 199, 178, 157, 136, 115, 94, 73, 52, 31, 10, 18, 39, 60, 81, 102, 123, 144, 165, 186, 207, 228, 249, 236, 215, 194, 173, 152, 131, 110, 89, 68, 47, 26, 5, 13, 34, 55, 76, 97, 118, 139, 160, 181, 202, 223, 244 ]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment