We have finally begun working with P5 in javascript. Today was the first day of just messing around with the library and its different capabilities. I just started by messing with colors and different shapes and making them move across the screen. My first drawing will be posted below, it looks like a fun mess. But that's the best way to find ones way around a new program.
Source Code:
Source Code:
function setup() {
createCanvas(600, 600);
}
var i = 0;
var a = 0;
//RGB values to start at
var r = 25;
var g = 255;
var b = 100;
var reverse = true;
function draw() {
strokeWeight(1);
background(r,g,b);
fill(255,255,255);
//triangle(10, 20, 40, 50, 70, 40);
triangle(100, 40, 30, 50, 60, 40);
triangle(0, 0, 100, 100, 500, 50);
strokeWeight(5);
quad(100, 100, 200, 400, 100, 300, 0, 200);
strokeWeight(1);
rect(i,100,a,100);
rect(i,100,50,50,15,15,15,15);
fill(255-a, 255-g, 255-b);
//shape of H
beginShape();
vertex(0+a, 350);
vertex(10+a, 350);
vertex(10+a, 330);
vertex(20+a, 330);
vertex(20+a, 350);
vertex(30+a, 350);
vertex(30+a, 300);
vertex(20+a, 300);
vertex(20+a, 320);
vertex(10+a, 320);
vertex(10+a, 300);
vertex(0+a, 300);
vertex(0+a, 350);
endShape();
//bottom of I
beginShape();
vertex(40+a, 350);
vertex(40+a, 330);
vertex(50+a, 330);
vertex(50+a, 350);
vertex(40+a, 350);
endShape();
//dot the I!!
beginShape();
vertex(40+a, 320);
vertex(40+a, 310);
vertex(50+a, 310);
vertex(50+a, 320);
vertex(40+a, 320);
endShape();
if (i == 600)
{
i = 0;
}
if (a == 100)
{
//reverse = true
a=0;
}
else{
//reverse = false;
}
if (b == 255){
resetColor();
}
i++;
a++;
r++;
g--;
b++;
}
function resetColor(){
r = 25;
g = 255;
b = 100;
}

Comments
Post a Comment