cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
                <html>

  <head>
    <meta charset="UTF-8">
    <script language="javascript" type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/p5.js/0.4.23/p5.js"></script>
    </head>
    <body>
    </body>
            
          
!
            
              const FRAMES_BETWEEN_WINKS = 120;
const GRAY = 48;

var skinColor;
var earColor;
var scarfColor;

var isLeftEyeWinking = false;
var countdownToWink = FRAMES_BETWEEN_WINKS;
var countdownToUnwink;

function setup() {
  skinColor = color(191, 117, 88);
  scarfColor = color(58,92,134);
  createCanvas(400, 400);
  background(240);
}

function draw() {
  background(240);

  // TODO: remove this
  stroke('black');
  text(countdownToWink, 10, 10);

  if (!isLeftEyeWinking) {
    countdownToWink = countdownToWink - 1;
    if (countdownToWink == 0) {
      isLeftEyeWinking = true;
      countdownToUnwink = 60;
    }
  } else {
    countdownToUnwink = countdownToUnwink - 1;
    if (countdownToUnwink == 0) {
      isLeftEyeWinking = false;
      countdownToWink = FRAMES_BETWEEN_WINKS;
    }
  }
  

  drawFlannel();
  drawHorizontalScarf();
  drawVerticalScarf();
  drawEarlobe();
  drawEarlobe2();
  drawBeard();
  drawHead();
  drawNose();
  drawLeftEye();
  drawRightEye();
  drawMouth();
  drawHat();
  drawRim();
  drawPompom();
}

function drawFlannel() {
  drawShirt();
  drawVerticalStripe(0);
  drawVerticalStripe(45);
  drawVerticalStripe(90);
  drawHorizontalStripe(0);
  drawHorizontalStripe(40);
}

function drawFaceAndHat(){
  drawEarlobe();
  drawEarlobe2();
  drawHead();
  drawLeftEye();
  drawRightEye();
  drawMustache();
  drawBeard();
  drawBeard2();
  drawNose();
  drawMouth();
  drawHat();
  drawRim();

}


//shirt
function drawShirt() {
  fill(211, 49, 49);
  noStroke();
  ellipse(200, 380, 300, 200);

}

//Draw Vertical Stripe and add an offset on the x value
function drawVerticalStripe(xOffset) {
  fill(145, 35, 35);
  noStroke();
  rect(150 + xOffset, 300, 20, 100);
}

//Draw horizontal stripe and add an offset on the y value
function drawHorizontalStripe(yOffset) {
  fill(0,0,0, 40);
  noStroke();
  rect(80, 320 + yOffset, 240, 20, 40);
}


//scarf horizontal
function drawHorizontalScarf() {
  fill(scarfColor);
  noStroke();
  rect(140,280,100,50,4);
}

//scarf vertical
function drawVerticalScarf() {
  fill(scarfColor);
  noStroke();
  rect(210,280,50,110,4);
}

//earlobe-left
function drawEarlobe() {
  fill(178, 92, 85);
  noStroke();
  ellipse(270, 200, 30, 30);
}

//earlobe-right
function drawEarlobe2() {
  fill(178, 92, 85);
  noStroke();
  ellipse(130, 200, 30, 30);
}



//left eye
function drawLeftEye() {
  fill(255,181,161);
  noStroke();
  if (isLeftEyeWinking) {
    rect(160,190,20,4,4);
  } else {
    ellipse(170, 190, 10, 10);
  }
}

//right eye
function drawRightEye() {
  fill(255, 181, 161);
  noStroke();
  ellipse(225, 190, 10, 10);
}

//beard
function drawBeard() {
  fill(77,47,28);
  noStroke();
  ellipse(200, 220, 150, 180);

}
//head
function drawHead() {
  fill(skinColor);
  noStroke();
  rect(150, 160, 100, 60,6);
}
//nose
function drawNose() {
  fill(skinColor);
  noStroke();
  rect(190, 180, 20, 50,8);

}


//mouth
function drawMouth() {
  fill (255);
  noStroke();
  rect(170, 245, 60, 25,0,0,8,8);
 
}

//hat
function drawHat() {
  fill(GRAY);
  noStroke();
  rect(130, 90, 140, 85, 80, 80, 10, 5);

}

//hat rim
function drawRim() {
  fill(61);
  noStroke();
  rect(120, 165, 160, 20, 4);

}

//pompom
function drawPompom(){
  fill(GRAY);
  noStroke();
  ellipse(200,80,40,40,8);
}
            
          
!
999px
Loading ..................

Console