Created
September 9, 2017 07:30
-
-
Save dev001hajipro/074b8c44aa4e84e551dcd0dadd6b72e1 to your computer and use it in GitHub Desktop.
study donut lines from beesandbombs/rainbowDonut.pde
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*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