added fragments
This commit is contained in:
parent
dee4d81cc8
commit
70d78e2b37
Binary file not shown.
@ -4,7 +4,7 @@ import { Gfx } from @sdk:gfx;
|
||||
declare global ticks: int = 0;
|
||||
declare const SCREEN_W: int = 320;
|
||||
declare const SCREEN_H: int = 180;
|
||||
declare const CELL: int = 8;
|
||||
declare const CELL: int = 4;
|
||||
|
||||
[Init]
|
||||
fn init() -> void
|
||||
@ -12,25 +12,80 @@ fn init() -> void
|
||||
ticks = 0;
|
||||
}
|
||||
|
||||
fn abs_i(v: int) -> int
|
||||
{
|
||||
if (v < 0) {
|
||||
return 0 - v;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
[Frame]
|
||||
fn frame() -> void
|
||||
{
|
||||
ticks += 1;
|
||||
for y: int from 0 until SCREEN_H step CELL {
|
||||
let gy = y / CELL;
|
||||
for x: int from 0 until SCREEN_W step CELL {
|
||||
let gx = x / CELL;
|
||||
let wave_a = (gx * 211 + ticks * 9) % 31;
|
||||
let wave_b = (gy * 173 + ticks * 7) % 63;
|
||||
let wave_c = ((gx + gy) * 149 + ticks * 11) % 31;
|
||||
let wave_d = ((gx * gy) + ticks * 5) % 63;
|
||||
let cx = SCREEN_W / 2;
|
||||
let cy = SCREEN_H / 2;
|
||||
let phase = ticks / 2;
|
||||
|
||||
let r = (wave_a + wave_c) % 31;
|
||||
let g = (wave_b + wave_d) % 63;
|
||||
let b = ((wave_a + wave_b + wave_c) / 3) % 31;
|
||||
Gfx.clear(new Color(0));
|
||||
|
||||
for y: int from 0 until SCREEN_H step CELL {
|
||||
let dy = y - cy;
|
||||
for x: int from 0 until SCREEN_W step CELL {
|
||||
let dx = x - cx;
|
||||
let seed_x = dx / 3 + ((phase % 29) - 14);
|
||||
let seed_y = dy / 3 + (((phase * 3) % 23) - 11);
|
||||
|
||||
let zx: int = seed_x;
|
||||
let zy: int = seed_y;
|
||||
let iter: int = 0;
|
||||
|
||||
while iter < 5 {
|
||||
let ax = abs_i(zx);
|
||||
let ay = abs_i(zy);
|
||||
let nx = ((zx * zx - zy * zy) / 48) + seed_x + ((ay * 3) / 8) - 9;
|
||||
let ny = ((ax * zy) / 24) + seed_y + ((phase + iter * 7) % 17) - 8;
|
||||
zx = nx;
|
||||
zy = ny;
|
||||
iter += 1;
|
||||
}
|
||||
|
||||
let axf = abs_i(zx);
|
||||
let ayf = abs_i(zy);
|
||||
let energy = (axf + ayf + iter * 9 + ((x + y + phase) % 31)) % 128;
|
||||
|
||||
let r = if energy > 95 {
|
||||
24 + ((phase + x / CELL) % 7)
|
||||
} else if energy > 63 {
|
||||
10 + ((energy + phase) % 12)
|
||||
} else {
|
||||
(energy / 8) % 8
|
||||
};
|
||||
|
||||
let g = if energy > 95 {
|
||||
8 + ((phase + y / CELL) % 22)
|
||||
} else if energy > 63 {
|
||||
14 + ((energy + phase) % 26)
|
||||
} else {
|
||||
2 + ((energy / 4) % 10)
|
||||
};
|
||||
|
||||
let b = if energy > 95 {
|
||||
26 + ((phase + x / CELL + y / CELL) % 5)
|
||||
} else if energy > 63 {
|
||||
16 + ((energy + phase) % 14)
|
||||
} else {
|
||||
6 + ((energy / 3) % 16)
|
||||
};
|
||||
|
||||
let color_raw = r * 2048 + g * 32 + b;
|
||||
Gfx.fill_rect(x, y, CELL, CELL, new Color(color_raw));
|
||||
}
|
||||
}
|
||||
|
||||
Gfx.draw_circle(cx, cy, 24 + (phase % 6), new Color(31743));
|
||||
Gfx.draw_circle(cx, cy, 52 + ((phase + 3) % 9), new Color(21119));
|
||||
Gfx.draw_circle(cx, cy, 78 + ((phase + 5) % 7), new Color(10591));
|
||||
}
|
||||
// Estimated frame cost: 3600 fills + ~18000 fractal-iteration steps + 3 circles/frame at CELL=4.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user