pakt27
See /software/p5js/pakt-februari/pakt27/ for a JavaScript version and /software/supercollider/februari-pakt/pakt27/ for accompanying sound code.
use nannou::prelude::*;
const N: u16 = 80;
fn main() {
nannou::sketch(view).size(640, 480).run();
}
fn view(app: &App, frame: Frame) {
let draw = app.draw();
let win = app.window_rect();
let index = app.time * 60.0;
if frame.nth() == 0 {
frame.clear(BLACK);
} else {
draw.rect().wh(win.wh()).color(rgba(0.0, 0.0, 0.0, 0.2));
}
for i in 0..N {
let t = i as f32 / N as f32 * PI * 2.0;
let c = ((index * 0.036 + t).sin() + (index * 0.022 - t).cos()) * 0.01;
let d = ((index * 0.033 + t).cos() + (index * 0.020 - t).sin()) * 0.01;
let r = t.sin() * 25.0 + 30.0;
let p = pt2(
(index * d * 0.05 + c + t).sin() * 0.4,
(index * c * 0.05 + d + t).cos() * 0.35,
) * win.wh();
draw.scale_axes(vec3(1.0, -1.0, 1.0))
.ellipse()
.xy(p)
.w_h(r * 2.0, r * 2.0)
.color(hsva(t.sin() * 0.15 + 0.15, 1.0, 1.0, 0.4));
}
draw.to_frame(app, &frame).unwrap();
}