Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int r=0;
- int g=0;
- int b=0;
- int direction = 2;
- int drawLength = 2;
- int counter = 0;
- int offset = 0;
- int xPos;
- int yPos;
- void setup(){
- size(800,800);
- background(255);
- frameRate(60000);
- xPos=width/2;
- yPos=height/2;
- }
- void makePoint(){
- stroke(r,g,b);
- point(xPos,yPos);
- }
- void doPoint(){
- if (direction == 0){
- xPos = xPos + 1;
- yPos = yPos + 1;
- }
- if (direction == 1){
- xPos = xPos - 1;
- yPos = yPos + 1;
- }
- if (direction == 2){
- xPos = xPos - 1;
- yPos = yPos - 1;
- }
- if (direction == 3){
- xPos = xPos + 1;
- yPos = yPos - 1;
- }
- }
- void updateVars(){
- counter++;
- r++;
- if (r > 255){
- r = 0;
- g++;
- }
- if (g > 255){
- g = 0;
- b++;
- }
- if (b > 255){
- b = 0;
- }
- if (counter >= drawLength){
- //drawLength starts at 2, counter starts at 0, after drawing 2 points, it will change directions, and build upon that, increasing drawLength with every new direction
- counter = 0;
- direction++;
- }
- if (direction == 2 && xPos == (width/2)){
- drawLength++;
- }
- if (direction == 4){
- direction = 0;
- drawLength++;
- }
- }
- void doPointOffset(){
- xPos++;
- yPos++;
- offset++;
- }
- void doPointOffset2(){
- xPos--;
- yPos++;
- offset++;
- }
- void colorChange(){
- if (r<255){
- r++;
- r=r%255;
- }
- if ((r%255)==0){
- g=g+1;
- }
- if ((g%255==0)){
- b=b+1;
- println(b);
- }
- }
- void directionChange(){
- if ((xPos <= width) || (yPos>=height)){
- makePoint();
- if (direction == 2 && drawLength == 2 && offset == 0){
- doPointOffset();
- }
- else if (direction == 2 && drawLength == 2 && offset == 1){
- doPointOffset2();
- }
- else{
- doPoint();
- updateVars();
- }
- }}
- void draw(){
- directionChange();
- //colorChange();
- }
Add Comment
Please, Sign In to add comment