xxxxxxxxxx
142
var t = 0,d=5;
let m1 = 1,m2=1,m3=1,m4=1,m5=1,m6=1,m7=1,m8=1,m9=1,m10=1;
let r1 = 80, r2=160;
function setup() {
createCanvas(400, 400);
s = width/2;
button1 = createButton('H_line');
button1.position(10, 2*s+20);
button1.mousePressed(changeM1);
button2 = createButton('Bowtie');
button2.position(70, 2*s+20);
button2.mousePressed(changeM2);
button3 = createButton('Eyeline');
button3.position(130, 2*s+20);
button3.mousePressed(changeM3);
button4 = createButton('Circle');
button4.position(190, 2*s+20);
button4.mousePressed(changeM4);
button5 = createButton('Ellipse');
button5.position(250, 2*s+20);
button5.mousePressed(changeM5);
button6 = createButton('Walking_Sq');
button6.position(310, 2*s+20);
button6.mousePressed(changeM6);
button7 = createButton('Diagonal');
button7.position(10, 2*s+50);
button7.mousePressed(changeM7);
button7 = createButton('2xcircle');
button7.position(70, 2*s+50);
button7.mousePressed(changeM8);
button8 = createButton('4xcircle');
button8.position(130, 2*s+50);
button8.mousePressed(changeM9);
button9 = createButton('All Filters Off');
button9.position(s-20, 2*s);
button9.mousePressed(changeAll);
button10 = createButton('Squares');
button10.position(190, 2*s+50);
button10.mousePressed(changeM10);
button11 = createButton('Trace Path - circle/ellipse');
button11.position(300, 2*s+50);
button11.mousePressed(changePath);
stroke(0);
}
function draw() {
background(0);
stroke(0);
translate(width/2,height/2);
x = r1*sin(t);
y = r2*cos(t);
t = t+0.01;
line(0,0,x,y);
stroke(255);
noFill();
for (let i = 0; i<(width/d + 1); i++){
line(-s+d*i,-s,x,y);
line(-s,s-d*i,x,y);
line(s-d*i,s,x,y);
line(s,s-d*i,x,y);
if(m1 ==-1){
line(s,i*(-d),-s,i*(-d));
line(s,i*(d),-s,i*(d));
}
if(m2==-1){
line(-s,i*(d),s,i*(-d));
}
if(m3==-1){
line(-s,-s+i*d,-s+i*d,s);
line(-s+i*d,-s,s,-s+i*d);
}
if(m4==-1){
circle(0,0,i*d)
}
if(m5==-1) {
ellipse(0,0,i*d,i*20);
}
if(m6==-1) {
rect(-s+5*i,-s+5*i,i*10,i*10);
}
if(m7==-1){
line(-s+i*d,-s,-s,-s+i*d);
line(-s+d,s+i*d,s+d,-s+i*d);
}
if(m8==-1){
circle(-s/2,-s/2,i*d);
circle(s/2,s/2,i*d);
}
if(m9==-1){
circle(-s/2,-s/2,i*d);
circle(s/2,s/2,i*d);
circle(s/2,-s/2,i*d);
circle(-s/2,s/2,i*d);
}
if(m10 == -1){
rect(s-i*d,s-i*d,i*d,i*d)
}
}
}
function makeButton(){
}
function changeM1(){
m1 = -1*m1;
}
function changeM2(){
m2 = -1*m2;
}
function changeM3(){
m3 = -1*m3;
}
function changeM4(){
m4 = -1*m4;
}
function changeM5(){
m5 = -1*m5;
}
function changeM6(){
m6 = -1*m6;
}
function changeM7(){
m7 = -1*m7;
}
function changeM8(){
m8 = -1*m8;
}
function changeM9(){
m9 = -1*m9;
}
function changeM10(){
m10 = -1*m10;
}
function changeAll(){
m1=1,m2=1,m3=1,m4=1,m5=1,m6=1,m7=1,m8=1,m9=1,m10=1;
}
function changePath(){
if (r2==160){r2=80}else{r2=160};
}