pakt23
See /software/p5js/pakt-februari/pakt23/ for a JavaScript version and /software/supercollider/februari-pakt/pakt23/ for accompanying sound code.
use nannou::lyon;
use nannou::prelude::*;
const N: usize = 250;
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;
let rx = (index * 0.0024).sin();
let ry = (index * 0.0022 + 1.0).sin();
let tx = (index * 0.0016 + 2.0).sin() + rx;
let ty = (index * 0.0018 + 3.0).sin() + ry;
if frame.nth() == 0 {
frame.clear(BLACK);
} else {
draw.rect().wh(win.wh()).color(rgba(1.0, 1.0, 1.0, 0.02));
}
let mut p = lyon::math::point(0.0, 0.0);
for i in 50..N {
let t = i as f32 / N as f32;
let x = t * PI * 2.0 * rx * tx;
let y = t * PI * 2.0 * ry * ty;
if i == 50 {
p = lyon::math::point(x.cos() * win.w(), y.sin() * win.h()) * 0.495 * t;
} else {
let c = (t * PI * 2.0).sin() * 0.5 + 0.5;
let mut builder = nannou::geom::path::Builder::new().with_svg();
builder.move_to(p);
p = lyon::math::point(x.sin() * win.w(), y.cos() * win.h()) * 0.495 * t;
builder.line_to(p);
p = lyon::math::point(x.cos() * win.w(), y.sin() * win.h()) * 0.495 * t;
builder.line_to(p);
builder.close();
let path = builder.build();
draw.scale_axes(vec3(1.0, -1.0, 1.0))
.path()
.stroke()
.color(rgba(c, 0.0, 0.0, c))
.events(path.iter());
}
}
draw.to_frame(app, &frame).unwrap();
}