Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

yutannihilation commented Apr 22, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.