import "env.memory" memory(4); import "env.pow" fn pow(f32, f32) -> f32; import "env.sin" fn sin(f32) -> f32; import "env.cos" fn cos(f32) -> f32; import "env.atan2" fn atan2(f32, f32) -> f32; import "env.tan" fn tan(f32) -> f32; import "env.atan" fn atan(f32) -> f32; import "env.rectangle" fn rect(f32, f32, f32, f32, i32); //export fn tic(time: i32) { // let i: i32; // loop pixels { // let lazy x = (i % 320) as f32 - 160.5; // let lazy y = (i / 320 - 120) as f32; // // let lazy dist = 4000 as f32 / sqrt(x*x + y*y + 10 as f32); // let lazy angle = atan2(x, y) * (64.0 / 3.141); // // i?120 = ((((dist + time as f32 / 63 as f32) as i32 ^ angle as i32) #% 32 + 32) >> ((dist as i32 - i % 7 * 3) / 40)) + 192; // // branch_if (i := i + 1) < 320*240: pixels; // } //} export fn tic(time: i32) { let i: i32; loop colors { rect((i % 16 * 15) as f32, (i / 16 * 15) as f32, 15 as f32, 15 as f32, i); branch_if (i := i + 1) < 256: colors } } fn make_gradient(c: f32, base: i32) -> i32 { let i: i32; loop colors { let lazy f = (i + 4) as f32 / 64 as f32; let lazy a = f * max(0 as f32, c + 0.5); let lazy b = f * f * 0.6; let lazy v = ((a + b - a * b) * 255 as f32) as i32; (base + i)?(120+320*240) = select(v < 0, 0, select(v > 255, 255, v)); branch_if (i := i + 4) < 64: colors; } base + 1 } start fn gen_palette() { let i: i32; loop hsv { let a = (i as f32 + 0.5) * (3.141 / 6.0); let inline base2 = make_gradient(cos(a) * 0.816, i * 64); let inline base3 = make_gradient(sin(a) * 0.707 - cos(a) * 0.804, base2); make_gradient(sin(a) * -0.707 - cos(a) * 0.804, base3); branch_if (i := i + 1) < 11: hsv; } make_gradient(0 as f32, make_gradient(0 as f32, make_gradient(0 as f32, 11*16*4))); i = 255; loop expand_sweetie { let lazy channel = i & 3; let lazy index = i >> 2; let lazy first_step = index >= 32; let inline src1 = select(first_step, index % 32 / 2, index * 2); let inline src2 = select(first_step, (index + 1) % 32 / 2, index * 2 + 1); let inline c1 = (src1 * 4 + channel)?(120+320*240+192*4); let inline c2 = (src2 * 4 + channel)?(120+320*240+192*4); i?(120+320*240+192*4) = (c1 + c2) * (3 + first_step) / 8; branch_if (i := i - 1) >= 0: expand_sweetie; } } data 120+320*240+192*4 { i32( 0x2c1c1a, 0x5d275d, 0x533eb1, 0x577def, 0x75cdff, 0x70f0a7, 0x64b738, 0x797125, 0x6f3629, 0xc95d3b, 0xf6a641, 0xf7ef73, 0xf4f4f4, 0xc2b094, 0x866c56, 0x573c33 ) }