Parker Glynn-Adey

P5.js Test-Run

Posted in Computers, geometry by pgadey on 2020/04/19

I played around with P5.js today. It is really nice software! There is an in-browser P5.js editor, so you can start playing around instantaneously.

canvas

function setup() {
angleMode(RADIANS); // Change the mode to RADIANS
createCanvas(200, 130);
}

function draw() {
background(256);

v1 = [1,0];
v2 = [cos(PI/3),sin(PI/3)];

n=0;
m=0;

while (n <= 5){
while (m <= 5){
p = [20+(20*v1[0]*n)+(20*v2[0]*m), 20+(20*v1[1]*n)+(20*v2[1]*m)]

if ( (n*m) % 2 == 0){
circle(p[0],p[1],20);
fill(200, 0, 0);
} else {
circle(p[0],p[1],20);
fill(0, 0, 200);
}
m += 1;
}
m = 0;
n += 1;
}
}

Tagged with: , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: