build cool things with p5

28
Build Cool Things with p5.js

Upload: chiunhau-you

Post on 14-Apr-2017

335 views

Category:

Art & Photos


0 download

TRANSCRIPT

Page 1: Build cool things with p5

Build Cool Things with p5.js

Page 2: Build cool things with p5

Why p5.js is COOL?

Page 3: Build cool things with p5

NYU ITP

Page 4: Build cool things with p5

Example Code <3

Page 5: Build cool things with p5

function setup()

Page 6: Build cool things with p5

function draw()

Page 7: Build cool things with p5

function setup(){ createCanvas(500, 500);}

function draw(){ ellipse(100, 100, 50, 50);}

Page 8: Build cool things with p5

ellipse(x, y, width, height)

Page 9: Build cool things with p5

function setup(){ createCanvas(500, 500);}

function draw(){ ellipse(100, 100, 50, 50); ellipse(200, 100, 70, 70);}

Page 10: Build cool things with p5

fill(color(100, 200, 100));stroke(color(“red”));

// or no colornoFill();noStroke();

Page 11: Build cool things with p5

var xPos = 0;

function draw(){ ellipse(xPos, 100, 50, 50); xPos ++;}

Page 12: Build cool things with p5

function mouseClicked()

Page 13: Build cool things with p5

function mouseClicked(){ ellipse(mouseX, mouseY, 50, 50);}

Page 14: Build cool things with p5

Cool?

Page 15: Build cool things with p5

rect() triangle()

quad() bezier() vertex()

….

Page 16: Build cool things with p5

Advanced

Page 17: Build cool things with p5

Build a matrix

Page 18: Build cool things with p5

for(var i = 0; i < 9; i ++){ for(var j = 0; j < 9; j ++) { ellipse(i*50 , j*50, 30, 30) }}

Page 19: Build cool things with p5

for(var i = 0; i < 10; i ++){ for(var j = 0; j < 10; j ++) { if(i % 2 == 0) { fill(color(“blue”)); } else { fill(color(“red”)); } ellipse(i*50 ,j*50, 30, 30); }}

Page 20: Build cool things with p5

#PrayForParis

Page 21: Build cool things with p5

Using sin()

Page 22: Build cool things with p5
Page 23: Build cool things with p5

frameCount

Page 24: Build cool things with p5

function draw(){ ellipse(400, 400, sin(frameCount), sin(frameCount));}

Page 25: Build cool things with p5

function draw(){ var sinSeed = sin(frameCount * 0.01); ellipse(400, 400, sinSeed * 100, sinSeed * 100);}

Page 26: Build cool things with p5

sin() = Magic

Page 27: Build cool things with p5

Final Project

Page 28: Build cool things with p5

Terima Kasih!