Skip to content

Instantly share code, notes, and snippets.

@fewlinesofcode
Created June 22, 2020 21:31
Show Gist options
  • Save fewlinesofcode/7b08837442d6c3db77d66507a697560d to your computer and use it in GitHub Desktop.
Save fewlinesofcode/7b08837442d6c3db77d66507a697560d to your computer and use it in GitHub Desktop.

Revisions

  1. fewlinesofcode created this gist Jun 22, 2020.
    41 changes: 41 additions & 0 deletions time_warp_p5.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    // Twitter: @fewlinesofcode

    var angle = 1.0;
    var angularSpeed = 0.01;
    var internalRadius = 130;

    function setup() {
    createCanvas(600, 600);
    noStroke();
    background(255);
    }

    function draw() {
    noFill();
    stroke(0);
    background(255);

    let r = 0;
    let numPts = 100;
    let numCircles = 20;
    let offset = 6;

    noiseSeed(1);
    for (let k = 0; k < numCircles; k++) {
    r = k * offset;
    for (let i = 0; i <= numPts; i++) {
    var x = sin(2 * Math.PI * i / numPts + (cos(angle)==0));
    var y = cos(2 * Math.PI * i / numPts + sin(angle));
    speed = noise(x, y) * internalRadius;
    x = width / 2 + x * (r + speed);
    y = height / 2 + y * (r - speed);
    if (i > 0) {
    line(prevX, prevY, x, y);
    }
    prevX = x;
    prevY = y;
    }
    }
    angle += angularSpeed;
    // noLoop();
    }