Skip to content

Instantly share code, notes, and snippets.

@dongphilyoo
Created September 12, 2017 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dongphilyoo/3a37f24443876697a650281e1d6f87e5 to your computer and use it in GitHub Desktop.
Save dongphilyoo/3a37f24443876697a650281e1d6f87e5 to your computer and use it in GitHub Desktop.
p5.js code snippet
function setup() {
createCanvas(600, 850);
}
function draw() {
// background
background(225);
// draw outline
stroke(0, 0, 0);
strokeWeight(2);
// head
fill(153, 230, 0);
rect(250, 170, 100, 100);
// chest
fill(51, 187, 255);
rect(180, 270, 240, 140);
// right shoulder
fill(255, 128, 255);
rect(105,210,75,120);
// right arm
fill(255, 153, 51);
rect(105, 90, 75, 120);
// right fist
beginShape();
fill(255, 92, 51);
vertex(105, 40);
vertex(165, 40);
vertex(165, 60);
vertex(180, 60);
vertex(180, 90);
vertex(105, 90);
vertex(105, 40);
endShape();
// left shoulder
push();
// move the origin to the pivot point
translate(420, 310);
// then pivot the grid
rotate(radians(-40));
// draw rect at the new origin
fill(255, 92, 51);
rect(0, 0, 75, 120);
pop();
// left arm
push();
// move the origin to the pivot point
translate(480, 395);
// then pivot the grid
rotate(radians(20));
// draw rect at the new origin
fill(136, 77, 255);
rect(0, 0, 75, 120);
// left fist
beginShape();
fill(255, 153, 51);
vertex(0, 120);
vertex(0, 150);
vertex(15, 150);
vertex(15, 170);
vertex(75, 170);
vertex(75, 120);
vertex(0, 120);
endShape();
pop();
// pelvis
fill(230, 230, 0);
rect(180, 410, 240, 70);
// right thighs
beginShape();
fill(255, 153, 51);
vertex(180, 480);
vertex(300, 480);
vertex(300, 520);
vertex(280, 540);
vertex(280, 620);
vertex(180, 620);
vertex(180, 480);
endShape();
// right calf
fill(255, 128, 255);
rect(180, 620, 100, 130);
// right foot
fill(51, 187, 255);
rect(180, 750, 100, 45);
// left thighs
beginShape();
fill(136, 77, 255);
vertex(300, 480);
vertex(420, 480);
vertex(420, 620);
vertex(320, 620);
vertex(320, 540);
vertex(300, 520);
vertex(300, 480);
endShape();
// left calf
fill(153, 230, 0);
rect(320, 620, 100, 130);
// left foot
fill(230, 230, 0);
rect(320, 750, 100, 45);
// face
noFill();
ellipse(275, 205, 25, 25);
ellipse(325, 205, 25, 25);
fill(0);
ellipse(275, 205, 10, 10);
ellipse(325, 205, 10, 10);
stroke(0);
strokeWeight(11);
strokeCap(ROUND);
line(280, 240, 320, 240);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment