Thursday, 24 September 2020

Trippy Coding


I am tired.

Well I tried to make some animated drawings in processing but it took very long lmao.


Image of me crying cuz im tired.

anyways heres the code:


float shake = .1;

float sizeValue;

float animationDuration = .5;

int circleX;

int circleY;

int squareX = 50;

int squareY = 50;

float mouseInput = random(mouseX);


//setup

void setup(){

    noStroke();

    frameRate(100);

    size(1000,1000);

}


void draw(){

  //calls on backgroundElement

    backgroundElement();

    //calls on the background gradient

    squareGradient();

    //fills and calls on 1 instance of cloudBorder

    fill(255,176,237);

    cloudBorder();

    //fills and calls on another instance of cloudBorder

    fill(10,17,81);

    cloudBorder();

    //calls on the planet

    planet();

}

void planet(){

  for (int o = 360; o > 0 ; o-=70){

    //outermost ring

     push();

     translate(width/2,height/2);

     rotate(radians(sizeValue*.7));

     ellipseMode(CENTER);

     fill(o*2,o/1.5,(o*10)/2);

     ellipse(0,0,600,100);

     pop();

     //innerring

     push();

     translate(width/2,height/2);

     rotate(radians(sizeValue*1));

     ellipseMode(CENTER);

     fill(o*5,o/2,4*o);

     ellipse(0,0,300,100);

     pop();

     //planet itself

     push();

     fill(220,100,219);

     translate(width/2,height/2);

     ellipse(0,0,200,200);

     pop();

     push();

     translate(width/2,height/2);

     rotate(radians(sizeValue*1));

     ellipseMode(CENTER);

     fill(212,88,202);

     ellipse(0,0,200,10);

     pop();

     sizeValue--;

  }

}

void cloudBorder(){

  //for loop to fill the borders

  for (int y = 0; y <= 1000; y += 50){

    

    //I dont know how to simplify this further at the moment. It eating the performance which is sad moment.

    //left border

    rect(circleX, circleY+y ,squareX*cos(sizeValue*.01) ,squareY*cos(sizeValue*.01));

    //bottom border

    rect(circleX+y, height+circleY ,squareX*cos(sizeValue*.01) ,squareY*cos(sizeValue*.01));

    //right border

    rect(width+circleX, circleY+y ,squareX*cos(sizeValue*.01) ,squareY*cos(sizeValue*.01));

    //top border

    rect(circleX+y, circleY ,squareX*cos(sizeValue*.01) ,squareY*cos(sizeValue*.01));

    sizeValue += animationDuration;

    circleX += random(-shake,shake);

    circleY += random(-shake,shake);

  }

}

void squareGradient(){

  //simple gradient pattern in the background

  //also for loops to create the gradient background

  for (int w = 1000; w > 0; w -= 100){

    for (int u = 1000; u > 0; u -= 100){

      fill(w/5,w/u,(w+u)/8);

      rectMode(CENTER);

      rect(width/2,height/2,u,w);

      //creates random variables to shake the shapes

      w += random(-shake,shake);

      u += random(-shake,shake);

    }

  }

}

//background element

void backgroundElement(){

  for (int w = 0; w <= 255; w++){

    background(w);

  }

}

No comments:

Post a Comment

Speedran Coding

Another day another monki moment. Had about 2 hours to make this until it is up and done! My idea was to create a looping hallway that never...