xxxxxxxxxx
42
var strokeColor;
function setup() {
createCanvas(700, 700);
colorMode(HSB, 360, 100, 100, 100);
noFill();
strokeWeight(2);
strokeColor = color(0, 10);
}
function draw() {
if (mouseIsPressed && mouseButton == LEFT) {
// push();
translate(width / 2, height / 2);
var circleResolution = int(map(mouseY + 100, 0, height, 2, 10));
var radius = mouseX - width / 2;
var angle = TAU / circleResolution;
stroke(strokeColor);
beginShape();
for (var i = 0; i <= circleResolution; i++) {
var x = cos(angle * i) * radius;
var y = sin(angle * i) * radius;
vertex(x, y);
}
endShape();
// pop();
}
}
function keyReleased() {
if (keyCode == DELETE || keyCode == BACKSPACE) background(0, 0, 100);
if (key == 's' || key == 'S') saveCanvas(gd.timestamp(), 'png');
if (key == '1') strokeColor = color(0, 10);
if (key == '2') strokeColor = color(192, 100, 64, 10);
if (key == '3') strokeColor = color(52, 100, 71, 10);
}