‹ pakt16 pakt18 ›

pakt17

See /software/p5js/pakt-februari/pakt17/ for a JavaScript version and /software/supercollider/februari-pakt/pakt17/ for accompanying sound code.

use nannou::prelude::*;

const N: u16 = 45;

fn main() {
  nannou::sketch(view).size(640, 480).run();
}

fn view(app: &App, frame: Frame) {
  let draw = app.draw();
  let win = app.window_rect();
  frame.clear(BLACK);

  let index = app.time * 60.0;
  let spread = (index * 0.004).sin() * 5.0 + 6.0;

  for i in 0..N {
    let i = i as f32;
    let ii = i * spread + index;
    let a = (ii * (index * 0.0050 + (index * 0.0074 + 1.0).sin() + 1.0).sin() * 0.0075 + 1.0)
      .sin()
      * 0.25
      + 0.5;
    let b = (ii * (index * 0.0051 + (index * 0.0073 + 2.0).sin() + 2.0).sin() * 0.0075 + 2.0)
      .sin()
      * 0.25
      + 0.5;
    let c = (ii * (index * 0.0052 + (index * 0.0072 + 3.0).sin() + 3.0).sin() * 0.0075 + 3.0)
      .sin()
      * 0.25
      + 0.5;
    let d = (ii * (index * 0.0053 + (index * 0.0071 + 4.0).sin() + 4.0).sin() * 0.0075 + 4.0)
      .sin()
      * 0.25
      + 0.5;
    draw.scale_axes(vec3(1.0, -1.0, 1.0))
      .translate(vec3(win.w(), win.h(), 0.0) * -0.5)
      .rect()
      .xy(pt2(a, b) * win.wh())
      .wh(pt2(c - a, d - b) * win.wh())
      .color(rgba(a, b, c, d));
  }

  draw.to_frame(app, &frame).unwrap();
}