p5(sketch => {
let system;
sketch.setup = function() {
sketch.createCanvas(1000, 1000);
};
sketch.draw = function() {
sketch.translate(sketch.width / 2, sketch.height / 2);
sketch.background(179, 128, 219);
let n = Math.floor(sketch.map(sketch.mouseY, 0, sketch.height, 2, 10))*2;
let proporcao = sketch.map(sketch.mouseX, 0, sketch.width, 0.5, 1);
let angulo = sketch.TWO_PI/n;
let raio = 250;
let raio2 = raio * proporcao;
sketch.fill(112, 23, 181);
sketch.stroke(255, 255, 255);
sketch.strokeWeight(5);
sketch.beginShape();
for(let i=0; i<n; i++) {
let raioUsado;
if(i%2==0){
raioUsado = raio;
} else{
raioUsado = raio2;
}
let x = raioUsado * sketch.cos(i*angulo);
let y = raioUsado * sketch.sin(i*angulo);
sketch.vertex(x,y);
}
sketch.endShape(sketch.CLOSE);
}
})