added fragments
This commit is contained in:
parent
70d78e2b37
commit
cf548fd4f3
Binary file not shown.
@ -4,7 +4,7 @@ import { Gfx } from @sdk:gfx;
|
|||||||
declare global ticks: int = 0;
|
declare global ticks: int = 0;
|
||||||
declare const SCREEN_W: int = 320;
|
declare const SCREEN_W: int = 320;
|
||||||
declare const SCREEN_H: int = 180;
|
declare const SCREEN_H: int = 180;
|
||||||
declare const CELL: int = 4;
|
declare const CELL: int = 8;
|
||||||
|
|
||||||
[Init]
|
[Init]
|
||||||
fn init() -> void
|
fn init() -> void
|
||||||
@ -28,12 +28,13 @@ fn frame() -> void
|
|||||||
let cy = SCREEN_H / 2;
|
let cy = SCREEN_H / 2;
|
||||||
let phase = ticks / 2;
|
let phase = ticks / 2;
|
||||||
|
|
||||||
Gfx.clear(new Color(0));
|
Gfx.clear(new Color(33));
|
||||||
|
|
||||||
for y: int from 0 until SCREEN_H step CELL {
|
for y: int from 0 until SCREEN_H step CELL {
|
||||||
let dy = y - cy;
|
let dy = y - cy;
|
||||||
for x: int from 0 until SCREEN_W step CELL {
|
for x: int from 0 until SCREEN_W step CELL {
|
||||||
let dx = x - cx;
|
let dx = x - cx;
|
||||||
|
let md = abs_i(dx) + abs_i(dy);
|
||||||
let seed_x = dx / 3 + ((phase % 29) - 14);
|
let seed_x = dx / 3 + ((phase % 29) - 14);
|
||||||
let seed_y = dy / 3 + (((phase * 3) % 23) - 11);
|
let seed_y = dy / 3 + (((phase * 3) % 23) - 11);
|
||||||
|
|
||||||
@ -41,7 +42,7 @@ fn frame() -> void
|
|||||||
let zy: int = seed_y;
|
let zy: int = seed_y;
|
||||||
let iter: int = 0;
|
let iter: int = 0;
|
||||||
|
|
||||||
while iter < 5 {
|
while iter < 3 {
|
||||||
let ax = abs_i(zx);
|
let ax = abs_i(zx);
|
||||||
let ay = abs_i(zy);
|
let ay = abs_i(zy);
|
||||||
let nx = ((zx * zx - zy * zy) / 48) + seed_x + ((ay * 3) / 8) - 9;
|
let nx = ((zx * zx - zy * zy) / 48) + seed_x + ((ay * 3) / 8) - 9;
|
||||||
@ -53,30 +54,33 @@ fn frame() -> void
|
|||||||
|
|
||||||
let axf = abs_i(zx);
|
let axf = abs_i(zx);
|
||||||
let ayf = abs_i(zy);
|
let ayf = abs_i(zy);
|
||||||
let energy = (axf + ayf + iter * 9 + ((x + y + phase) % 31)) % 128;
|
let ripple = (md / 9 + phase + ((dx - dy) / 12)) % 64;
|
||||||
|
let cloud = ((axf * 2) + (ayf * 3) + ripple + ((x - y + phase) % 29)) % 128;
|
||||||
|
let glow = ((abs_i(dx / 3) + abs_i(dy / 2)) / 8 + phase) % 32;
|
||||||
|
let energy = (cloud + glow) % 128;
|
||||||
|
|
||||||
let r = if energy > 95 {
|
let r = if energy > 95 {
|
||||||
24 + ((phase + x / CELL) % 7)
|
6 + ((phase + x / CELL) % 6)
|
||||||
} else if energy > 63 {
|
} else if energy > 63 {
|
||||||
10 + ((energy + phase) % 12)
|
4 + ((energy + phase) % 8)
|
||||||
} else {
|
} else {
|
||||||
(energy / 8) % 8
|
(energy / 24) % 3
|
||||||
};
|
};
|
||||||
|
|
||||||
let g = if energy > 95 {
|
let g = if energy > 95 {
|
||||||
8 + ((phase + y / CELL) % 22)
|
6 + ((phase + y / CELL) % 12)
|
||||||
} else if energy > 63 {
|
} else if energy > 63 {
|
||||||
14 + ((energy + phase) % 26)
|
8 + ((energy + phase) % 14)
|
||||||
} else {
|
} else {
|
||||||
2 + ((energy / 4) % 10)
|
2 + ((energy / 12) % 5)
|
||||||
};
|
};
|
||||||
|
|
||||||
let b = if energy > 95 {
|
let b = if energy > 95 {
|
||||||
26 + ((phase + x / CELL + y / CELL) % 5)
|
24 + ((phase + x / CELL + y / CELL) % 5)
|
||||||
} else if energy > 63 {
|
} else if energy > 63 {
|
||||||
16 + ((energy + phase) % 14)
|
18 + ((energy + phase) % 10)
|
||||||
} else {
|
} else {
|
||||||
6 + ((energy / 3) % 16)
|
7 + ((energy / 6) % 12)
|
||||||
};
|
};
|
||||||
|
|
||||||
let color_raw = r * 2048 + g * 32 + b;
|
let color_raw = r * 2048 + g * 32 + b;
|
||||||
@ -84,8 +88,46 @@ fn frame() -> void
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Gfx.draw_circle(cx, cy, 24 + (phase % 6), new Color(31743));
|
let star_a = (phase * 3) % SCREEN_W;
|
||||||
Gfx.draw_circle(cx, cy, 52 + ((phase + 3) % 9), new Color(21119));
|
let star_b = (phase * 5 + 37) % SCREEN_W;
|
||||||
Gfx.draw_circle(cx, cy, 78 + ((phase + 5) % 7), new Color(10591));
|
let star_c = (phase * 7 + 91) % SCREEN_W;
|
||||||
|
let star_d = (phase * 11 + 143) % SCREEN_W;
|
||||||
|
let star_e = (phase * 13 + 211) % SCREEN_W;
|
||||||
|
let star_f = (phase * 17 + 17) % SCREEN_W;
|
||||||
|
|
||||||
|
let star_y0 = 18 + ((phase * 2) % 24);
|
||||||
|
let star_y1 = 42 + ((phase * 3) % 18);
|
||||||
|
let star_y2 = 70 + ((phase * 4) % 22);
|
||||||
|
let star_y3 = 104 + ((phase * 5) % 16);
|
||||||
|
let star_y4 = 132 + ((phase * 6) % 20);
|
||||||
|
let star_y5 = 154 + ((phase * 7) % 14);
|
||||||
|
|
||||||
|
let twinkle0 = phase % 6;
|
||||||
|
let twinkle1 = (phase + 2) % 6;
|
||||||
|
let twinkle2 = (phase + 4) % 6;
|
||||||
|
let twinkle3 = (phase + 1) % 6;
|
||||||
|
let twinkle4 = (phase + 3) % 6;
|
||||||
|
let twinkle5 = (phase + 5) % 6;
|
||||||
|
|
||||||
|
let star_s0 = 1 + (twinkle0 / 4);
|
||||||
|
let star_s1 = 1 + (twinkle1 / 4);
|
||||||
|
let star_s2 = 1 + (twinkle2 / 4);
|
||||||
|
let star_s3 = 1 + (twinkle3 / 4);
|
||||||
|
let star_s4 = 1 + (twinkle4 / 4);
|
||||||
|
let star_s5 = 1 + (twinkle5 / 4);
|
||||||
|
|
||||||
|
let star_c0 = 57023 + twinkle0 * 1056;
|
||||||
|
let star_c1 = 48607 + twinkle1 * 1376;
|
||||||
|
let star_c2 = 44383 + twinkle2 * 1584;
|
||||||
|
let star_c3 = 61279 + twinkle3 * 704;
|
||||||
|
let star_c4 = 40159 + twinkle4 * 1696;
|
||||||
|
let star_c5 = 52831 + twinkle5 * 992;
|
||||||
|
|
||||||
|
Gfx.fill_rect(star_a, star_y0, star_s0, star_s0, new Color(star_c0));
|
||||||
|
Gfx.fill_rect(star_b, star_y1, star_s1, star_s1, new Color(star_c1));
|
||||||
|
Gfx.fill_rect(star_c, star_y2, star_s2, star_s2, new Color(star_c2));
|
||||||
|
Gfx.fill_rect(star_d, star_y3, star_s3, star_s3, new Color(star_c3));
|
||||||
|
Gfx.fill_rect(star_e, star_y4, star_s4, star_s4, new Color(star_c4));
|
||||||
|
Gfx.fill_rect(star_f, star_y5, star_s5, star_s5, new Color(star_c5));
|
||||||
}
|
}
|
||||||
// Estimated frame cost: 3600 fills + ~18000 fractal-iteration steps + 3 circles/frame at CELL=4.
|
// Estimated frame cost: ~920 fills + ~2760 fractal-iteration steps + 6 twinkling parallax stars/frame at CELL=8.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user