Fusión de Flujo (Mi regalo de Reyes Magos para todos Vosotros) (1/3)

 



CÓDIGO

//(C)Sergio Salazar Latorre

// FDF - Fusion de Flujo 


let l = 600

let np = 100

let c = Array(np)

let s = Array(np)



function setup() {

  createCanvas(l,l);

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

    c[i] = new FDF(random(0,l),

                  random(0,l),

                  1)

    s[i] = new FDF(random(0,l),

                  random(0,l),

                  2)

  }

}


function draw() {

  background(0);

  noFill()

  stroke(255)

  

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

    c[i].dibuja()

    s[i].dibuja()

  }

  

  firma()

}


class FDF

{

  constructor(x,y,cc){

    this.x=x

    this.y=y

    this.cc=cc

    this.D=random(10,80)

    this.r=this.D/2

    this.naD=this.D*5/8

    this.na2D=this.D*3/8

    this.nar=this.r*5/8

    this.na2r=this.r*3/8

  }

  

  dibuja(){

    //cc=1 circulo

    //cc=2 cuadrado


      if(this.cc==1){

        this.dibujaCirculo()

      } else if(this.cc==2){

        this.dibujaCuadrado()

      }

    }

  dibujaCirculo(){

      circle(this.x, this.y, this.D)

    }

    

    dibujaCuadrado(){

      square(this.x, this.y, this.D)

  }

}


function firma(){

  push()

  fill(255,0,0)

  strokeWeight(3)

  stroke(255)

  text("FDF - Fusión de Flujo - 001 - Creacion de Particulas", 10, l-9*2)

  text("(C)Sergio Salazar Latorre", 10, l-5)

  pop()

}


Comentarios