int x=0; //defines center int y=0; //defines center int xX=0; //defines center int yY=0; //defines center int r=125; //radius 1 float I=r*5/7; //multiplier to calculate x,y position on 45 degree angles float rr=r*12/7; // radius 2 float ii=r*2.5/7; //2nd multiplier to calculate x,y position on 25 degree angles float iii=r*6/7; //3nd multiplier to calculate x,y position on 25 degree angles int j=r*2/5; //add on to shift color float II=I+j; //multiplier to calculate grey dot location int T=80; //Alpha int C=80; //Color variable int H1=0; //Hue variable int H2=10; //Hue variable int H3=20; //Hue variable int H4=30; //Hue variable int H5=40; //Hue variable int H6=50; //Hue variable int H7=60; //Hue variable int H8=70; //Hue variable void setup(){ size(400,400); smooth(); colorMode(HSB,C,C,C,T); background(C); strokeWeight(r/2.5); strokeCap(ROUND); frameRate(61); } void draw(){ int x=mouseX; int y=mouseY; int xX=width/2; //defines center int yY=height/2; //defines center fill(0,0,80,T); rect(0,0,width,height); ////////////////////////////////////// H1=mouseX/5; //the below "if" statements are to ensure that the color shifts remain accurate //even if the mouse position returns a value outside of the color gamut. //After coding it this way, I discovered the modulo tool, which I would use //to make this more efficient if I were to reprogram this sketch. if (H1 >= 70){ //2 H2=H1-70; } else{ H2=H1+10; } /////////////////////// 3 if (H1 >= 60){ H3=(H1-60); } else{ H3=H1+20; } /////////////////////// 4 if (H1 >= 50){ H4=H1-50; } else{ H4=H1+30; } /////////////////////// 5 if (H1 >= 40){ H5=(H1-40); } else{ H5=H1+40; } /////////////////////// 6 if (H1 >= 30){ H6=(H1-30); } else{ H6=H1+50; } /////////////////////// 7 if (H1 >= 20){ H7=H1-20; } else{ H7=H1+60; } /////////////////////// 8 if (H1 >= 10){ H8=(H1-10); } else{ H8=H1+70; } /////////////////////// //the below "if" statement causes the screen to toggle into Psychedelic //mode, where the shapes leave trails as they move around. This toggles on //and off with a mouse click. if (mousePressed==true){ T=5;} else{ T=80; } //////////////////////////////below are all the actual lines. Rather than //entering numeric values, everthing is entered as variables which relate to //the mouse position. This way the sketch elements move around with the mouse. //Further down there are some lines that are anchored on one end. They are //pulling values from the anchored xX and yY variables rather than from the //dynamic x and y variables. //first group of inner lines strokeWeight(50); stroke(H1,C*4/5,C*4/5,C*3/8); //color 1 line(x, y, x+r, y); //starting line, from origin to the right side of screen stroke(H2,C*4/5,C*4/5,C*3/8); //color 2 line(x, y, x+I,y+I); stroke(H3,C*4/5,C*4/5,C*3/8); //color 3 line(x, y, x, y+r); stroke(H4,C*4/5,C*4/5,C*3/8); //color 4 line(x, y, x-I, y+I); stroke(H5,C*4/5,C*4/5,C*3/8); //color 5 line(x, y, x-r, y); stroke(H6,C*4/5,C*4/5,C*3/8); //color 6 line(x, y, x-I, y-I); stroke(H7,C*4/5,C*4/5,C*3/8); //color 7 line(x, y, x, y-r); stroke(H8,C*4/5,C*4/5,C*3/8); //color 8 line(x, y, x+I, y-I); //second group of lines strokeWeight(r/4); stroke(H4,75,50,C*3/8); //color 4b line(x+ii, y-iii, xX+ii*2, yY-iii*2); line(x+ii, y-iii, xX+ii*2+j, yY-iii*2-j); strokeWeight(r/4); stroke(H5,75,50,C*3/8); //color 5b line(x+iii, y-ii, xX+iii*2, yY-ii*2); line(x+iii, y-ii, xX+iii*2+j, yY-ii*2-j); strokeWeight(r/4); stroke(H6,75,50,C*3/8); //color 6b line(x+iii, y+ii, xX+iii*2, yY+ii*2); line(x+iii, y+ii, xX+iii*2+j, yY+ii*2+j); strokeWeight(r/4); stroke(H7,75,50,C*3/8); //color 7b line(x+ii, y+iii, xX+ii*2, yY+iii*2); line(x+ii, y+iii, xX+ii*2+j, yY+iii*2+j); strokeWeight(r/4); stroke(H8,75,50,C*3/8); //color 8b line(x-ii, y+iii, xX-ii*2, yY+iii*2); line(x-ii, y+iii, xX-ii*2-j, yY+iii*2+j); strokeWeight(r/4); stroke(H1,75,50,C*3/8); //color 1b line(x-iii, y+ii, xX-iii*2, yY+ii*2); line(x-iii, y+ii, xX-iii*2-j, yY+ii*2+j); strokeWeight(r/4); stroke(H2,75,50,C*3/8); //color 2b line(x-iii, y-ii, xX-iii*2, yY-ii*2); line(x-iii, y-ii, xX-iii*2-j, yY-ii*2-j); strokeWeight(r/4); stroke(H3,75,50,C*3/8); //color 3b line(x-ii, y-iii, xX-ii*2, yY-iii*2); line(x-ii, y-iii, xX-ii*2-j, yY-iii*2-j); // grey dots noStroke(); ellipseMode(CENTER); fill(0,7); ellipse(xX+II, yY+II,j,j); fill(0,5.5); ellipse(xX+II+j/4, yY+II+j/4,1.25*j,1.25*j); fill(0,4); ellipse(xX+II+j/2, yY+II+j/2,1.5*j,1.5*j); fill(0,3); ellipse(xX+II+j/1.15, yY+II+j/1.15,2*j,2*j); //corner 1 fill(0,7); ellipse(xX+II, yY-II,j,j); fill(0,5.5); ellipse(xX+II+j/4, yY-II-j/4,1.25*j,1.25*j); fill(0,4); ellipse(xX+II+j/2, yY-II-j/2,1.5*j,1.5*j); fill(0,3); ellipse(xX+II+j/1.15, yY-II-j/1.15,2*j,2*j); //corner 2 fill(0,7); ellipseMode(CENTER); ellipse(xX-II, yY-II,j,j); fill(0,5.5); ellipse(xX-II-j/4, yY-II-j/4,1.25*j,1.25*j); fill(0,4); ellipse(xX-II-j/2, yY-II-j/2,1.5*j,1.5*j); fill(0,3); ellipse(xX-II-j/1.15, yY-II-j/1.15,2*j,2*j); //corner 3 fill(0,7); ellipse(xX-II, yY+II,j,j); fill(0,5.5); ellipse(xX-II-j/4, yY+II+j/4,1.25*j,1.25*j); fill(0,4); ellipse(xX-II-j/2, yY+II+j/2,1.5*j,1.5*j); fill(0,3); ellipse(xX-II-j/1.15, yY+II+j/1.15,2*j,2*j); //corner 4 fill(0,7); ellipse(xX+II+j*1.1, yY,j,j); fill(0,5.5); ellipse(xX+II+j*1.45, yY,1.25*j,1.25*j); fill(0,4); ellipse(xX+II+j*1.8, yY,1.5*j,1.5*j); //edge 1 fill(0,7); ellipse(xX, yY+II+j*1.1,j,j); fill(0,5.5); ellipse(xX, yY+II+j*1.45,1.25*j,1.25*j); fill(0,4); ellipse(xX, yY+II+j*1.8,1.5*j,1.5*j); //edge 2 fill(0,7); ellipse(xX-II-j*1.1, yY,j,j); fill(0,5.5); ellipse(xX-II-j*1.45, yY,1.25*j,1.25*j); fill(0,4); ellipse(xX-II-j*1.8, yY,1.5*j,1.5*j); //edge 3 fill(0,7); ellipse(xX, yY-II-j*1.1,j,j); fill(0,5.5); ellipse(xX, yY-II-j*1.45,1.25*j,1.25*j); fill(0,4); ellipse(xX, yY-II-j*1.8,1.5*j,1.5*j); //edge 4 }