Skip to content

Instantly share code, notes, and snippets.

@yutannihilation
Created April 22, 2019 13:26
Show Gist options
  • Save yutannihilation/27a17099155d6b65d6f08ad310567432 to your computer and use it in GitHub Desktop.
Save yutannihilation/27a17099155d6b65d6f08ad310567432 to your computer and use it in GitHub Desktop.
let steps = 100;
let offset = 0;
function drawStripeCircle(steps) {
clear();
let r = min(width, height);
let a = 2 * PI / steps;
for (let i = 0; i < steps; i++) {
// black
stroke(0);
fill(0);
arc(width / 2, height / 2, r, r, a * i + offset, a * (i + 0.5) + offset);
// white
noStroke();
fill(255);
arc(width / 2, height / 2, r, r, a * (i + 0.5) + offset, a * (i + 1) + offset);
}
}
function setup() {
createCanvas(windowWidth, windowHeight);
background(255);
}
function draw() {
drawStripeCircle(round(steps));
}
function mouseDragged() {
// change of the distance to the center
let cdist = dist(width / 2, height / 2, mouseX, mouseY);
let pdist = dist(width / 2, height / 2, pmouseX, pmouseY);
steps = constrain(steps + (cdist - pdist), 1, 255);
// change of the rotation
let crot = atan2(mouseY - height / 2, mouseX - width / 2);
let prot = atan2(pmouseY - height / 2, pmouseX - width / 2);
offset = offset + (crot - prot);
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
}
@yutannihilation
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment