Blog: Comp Media

ITPG-GT 2233-002

Tutor: Luisa

WEEK 5

Aim to keep setup() and draw() as clean as possible, and do everything (all calculations, drawing, etc.) in functions that you create yourself.

Part I: 

An unstable state pattern forming something which looks satisfying.

Work title: Firework - some kind of

 

Preview picture:

week5.jpg

Work link - 

https://www.openprocessing.org/sketch/981301

A kind of remix of what I did last time, and still, moving the mouse left or right controls the size of the 'fire works'.

I basically took the small stars in the background and the bigger fireworks regrouped into two functions, and they work individually in their own function groups, having the own random values appearing on canvas.

P5 code:

var len

function setup() {
    createCanvas(windowWidth, windowHeight)
    background(20)
    frameRate(20)
}

function draw() {
    background(7,16,19,15)
    littleStars(random(width),random(height))
    stars(random(0,width),random(0,height),random(3,15))
}

function littleStars(pla,ola){
  noStroke()
  fill(255,200,200)
  ellipse(pla,ola,2)
}

function stars(x,y,z){  
  translate(x,y)
      var len = map(mouseX,0,width,z*10,random(z*25,z*50))
      for(var a=-10;a<10;a++){
            for(var i=0;i<120;i++){
                strokeWeight(0.2)
                stroke(random(x),random(y),random(z*10))
                line(a*z,0,0,len)
                rotate(PI/60)
          }
        }
}