GemaMachina DoubleParticleSystem V2.0

 




CÓDIGO

//(C)Sergio Salazar Latorre

//GemaMachina V2.0

//Sistema de Particulas


let epl=3 //elementos por lado

let l=600  //lado

let D = l/epl //Diametro de cada elemento

let r=D/2 //Radio de cada elemento

let x,y   //posiciones x e y de cada elemento

let np=epl*epl //numero de particulas

let pc=Array(np) //array del numero de particulas

let ps=Array(np) //array del numero de particulas

let n="GemaMachina DoubleParticleSystem V2.0"

let transparencia=3

function setup(){

  createCanvas(l,l);

  for(let i=0; i<np;i++){

    pc[i] = new GemaMachina(random(0,l), 

                          random(0,l),1)

    ps[i] = new GemaMachina(random(0,l), 

                          random(0,l),2)

  }

}


function draw() {

  background(0,transparencia);

  noFill()

  stroke(255)

  for(let i=0; i<np; i++){

    pc[i].ver()

    ps[i].ver()

  }

  push()

  stroke(255)

  strokeWeight(2)

  fill(0)

  text(n,10,l-10*3)

  text("(C)Sergio Salazar Latorre", 10, l-9*2)

  text("Dedicado a mi musa, mi reina, mi inspiracion. A mi mujer Gema", 10,l-5)

  strokeWeight(1)

}


class GemaMachina

{

  constructor(x,y,tipo){

    this.x=x

    this.y=y

    this.D=D

    this.r=r

    this.V = createVector(this.x, this.y)

    this.frecuencia = random(0.01, 0.009)

    this.mD=1

    this.c=this.colorAleatorio(2)

    this.tipo = tipo

  }

  

  ver(){

    this.modularD()

    this.actualizarVectores(2)

    if(this.tipo==2){

      //this.dibujarCirculo()

      this.dibujarCirculosConcentricos()

    } else {

      //this.dibujarCuadrado()

      this.dibujarCuadradosConcentricos()

    }

    //this.dibujarCuadrado()

    //this.dibujarCuadradosConcentricos()

  }

  modularD(){

    this.mD = sin(frameCount*this.frecuencia + 

                 1*dist(l/2,l/2, 

                        this.x, this.y))

  }

  actualizarVectores(cod){

    if(cod==1){ //Van Gogh

      this.V.add(random(-10,10), random(-10,10))

      if(this.V.x<0 || this.V.x>l ||

        this.V.y<0 || this.V.y>l){

        this.V.add(random(0,l), random(0,l))

      } else if(cod==2){

       this.V.mult(2,1)

      }

    }  

  }

  dibujarCirculo(){

    circle(this.V.x, this.V.y, this.mD*D)

  }

  dibujarCirculosConcentricos(){

    push()

    stroke(this.c)

    circle(this.V.x, this.V.y, this.mD*(D))

    

    circle(this.V.x, this.V.y, this.mD*(D/4*3))

    circle(this.V.x, this.V.y, this.mD*(D/4*2))

  }

  dibujarCuadrado(){

    stroke(this.c)

    square(this.V.x, this.V.y, this.mD*D)

  }

  dibujarCuadradosConcentricos(){


    stroke(this.c)

    square(this.V.x, this.V.y, this.mD*(D))

    

    square(this.V.x, this.V.y, this.mD*(D/4*3))

    square(this.V.x, this.V.y, this.mD*(D/4*2))

  }

  

  colorAleatorio(codc){

      if(codc==1){ //Rosa Rosae

        return color(random(100, 255),

                random(100,128),

                random(150,200))

      } else if(codc==3){ //Turquoise Fragance

        return color(random(255-100, 255-255),

                random(100,128),

                random(150,200))

      } else if(codc==4){ //Green Apple

        return color(random(255-100, 255-255),

                random(255-100,255128),

                random(150,200))

      } else if(codc==2){ //Love UltraViolet

        return color(random(255),

                random(-100,235-128),

                random(355-150,355-200))

      } else if(codc==5){ //Electric Sea

        return color(random(255-100, 255-255),

                random(255-100,255-128),

                random(255150,200))

      }

    

  }

  

  

}

Comentarios

Entradas populares