Skip to content

Instantly share code, notes, and snippets.

@dev001hajipro
Created September 9, 2017 07:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dev001hajipro/074b8c44aa4e84e551dcd0dadd6b72e1 to your computer and use it in GitHub Desktop.
Save dev001hajipro/074b8c44aa4e84e551dcd0dadd6b72e1 to your computer and use it in GitHub Desktop.
study donut lines from beesandbombs/rainbowDonut.pde
/*jshint esversion: 6 */
function setup() {
createCanvas(720, 720, WEBGL);
rectMode(CENTER);
noStroke();
colorMode(HSB, 255);
}
function thing(q) {
const N = 720;
const R = 160;
const r = 80;
push();
noFill();
beginShape();
const t = 1;
for (let i = 0; i < N; i++) {
let th = TWO_PI * i / N;
//let ph = 4 * th + TWO_PI * q - 3 * TWO_PI * mouseX;
let ph = 4 * th + TWO_PI * q - 3 * TWO_PI * t;
let x = R + r * cos(ph);
let y = 0;
let z = r * sin(ph);
let xx = x * cos(th);
let yy = x * sin(th);
let zz = z;
stroke(150, 250, 250);
vertex(xx, yy, zz);
}
endShape(CLOSE);
pop();
}
function draw() {
background(0, 0, 255);
let lineCount = floor(map(mouseX, 0, width, 1, 8));
rotateY(-TWO_PI*frameCount*0.001);
Array.from(Array(lineCount).keys())
.map(i=>i*1.0/lineCount)
.forEach(q=>thing(q))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment