Thursday, 1 October 2020

LSD Coding

 Hello everyone! I hope ya'll doing well in this meme times.

I'm back again with another insanity. I'm also very tired because brain dead coding and everything. 



Tried my hands on doing something more mathematical and with more input this time around, so here ya'll go:

Code:


//values to vary the size of the main shape

float pulse = .5;

int sizeValue;

//shake value for the background

float shake = .1;

//dynamic multiplier value controlling a massive amount of interativity in the sketch

float multiplier = 1;

float animationDuration = .5;

//another dynamic value controlling the location of the shape on the sketch

float valueX = width/2;

float valueY = height/2;

//rotation value used for the spinning motion

float rotateV;

//setup the size and general settings of the sketch

void setup(){

  size(1000,1000);

  noStroke();

  

}


void draw(){

  //call for the background

  squareGradient();

  //pushes and calls a translation of the pellet asset

  push();

  translate(width/2,height/2);

  pellet();

  pop();

  //create a variation of the spinning shape

  push();

  translate(width/2,height/2);

  scale(random(.1,1));

  pellet();

  pop();

  println(keyCode);

  

}

//creation of the main spinning asset

void pellet(){

  //for loops for rgb

  for(int blue = 200; blue > 100; blue-=10){

    for(int green = 150; green > 10; green-=30){

      for(int red = 50; red > random(10,15); red-=30){

        for(int spiralIntensity = 0; spiralIntensity < 3; spiralIntensity++){

          //push for ellipse shape

          push();

          fill(red,green,blue);   

          rotate(radians(-(rotateV*1)));

          ellipse(spiralIntensity*valueX,valueY,cos(sizeValue*.1)+multiplier,cos(sizeValue*.1)+multiplier);

          fill(red/2,green/2,blue/2,1);

          rect(valueY,spiralIntensity*valueX,cos(sizeValue*.2)+multiplier,cos(sizeValue*.2)+multiplier);

          pop();

          //motion dynamic values

          sizeValue+=pulse;

          rotateV+=animationDuration;

        }

      }

    }

  }

}


//reuse of old asset, values changed to fit the sketch

void squareGradient(){

  //simple gradient pattern in the background

  //also for loops to create the gradient background

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

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

      push();

      fill((w/7)*multiplier,(w+u)/8,(w/multiplier)-(valueX/multiplier),10);

      rectMode(CENTER);

      rect(width/2,height/2,u,w,radians(multiplier*360),radians((multiplier*360)),radians(multiplier*360),radians(multiplier*360));

      pop();

      //creates random variables to shake the shapes

      w += random(-shake,shake);

      u += random(-shake,shake);

    }

  }

}


//interactivity values.

void keyPressed(){

  //setup the usage of special keys

  if (key == CODED)

  {

    //moves the shape

    if (keyCode == LEFT && valueX > 0)

    {

       valueX= valueX-(multiplier/4);    

    }

    else if (keyCode == RIGHT && valueX < width)

    {

       valueX= valueX+(multiplier/4);

    }

    else if (keyCode == DOWN && valueY < height)

    {

       valueY= valueY+(multiplier/4);

    }

    else if (keyCode == UP && valueY > 0)

    {

       valueY= valueY-(multiplier/4);

    }

  }

  //this changes the value of the multiplier

  if (keyPressed){

    if (key == 'u'){

      multiplier = multiplier+1;

    }

    else if (key == 'j'){

      multiplier = multiplier-1;

    }

  }


}

I swear there must be an easier way to do this, but heres the extent of what I can do given some restrictions


Anyways too da loo 

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...