xxxxxxxxxx
50
var nRef = 9 ;
let cnvs;
function setup() {
cnvs = createCanvas(600, 600);
sel = createSelect();
sel.position(10, width+10);
for(i = 3;i<43;i++){
sel.option(i);
}
sel.selected(9);
sel.changed(mySelectEvent);
button = createButton('save');
button.position(60, width+10);
button.mousePressed(saveF);
angleMode(DEGREES)
stroke(255);
fill(255);
background(0);
theta = 360/nRef
}
function draw() {
r = 0.5
translate(width/2,width/2)
for (let i = 0;i<nRef;i++){
push()
rotate(i*theta)
circle(mouseX-width/2,mouseY-width/2,r)
push()
scale(1, -1);
circle(mouseX-width/2,mouseY-width/2,r)
pop()
pop()
}
}
function keyPressed() {
background(0)
}
function mySelectEvent(){
background(0)
nRef = sel.value();
theta = 360/nRef
}
function saveF(){
saveCanvas(cnvs, 'myReflect', 'jpg');
}