123

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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 Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              // setup() executes only once and at the very beginning

var x=290;
var y=164;
var speed=5;
var direction = 'left';
function setup() {
  createCanvas(500, 500);
  //var speed=40;
  //frameRate(1);
}

// draw() executes over and over once setup() has executed
function draw() {
  //background(0,1000,1000);

 
  
  
  var speed=40;
  c=color(50,204,93);
  fill(c);
  noStroke();
  smooth();
  ellipse(CENTER);
  ellipse(300,187,200,200);//head
 
  //fist
  ellipse(120,220,speed,speed);//left-fist
  ellipse(480,220,speed,speed);//right-fist
 
  //arms
  strokeWeight(14);
  stroke(50,204,93);
  line(120,220,240,380);//left-arm
  line(140,245,240,360);//left-arm-short
  line(480,220,380,380);//right-arm
  line(465,245,380,360);//right-arm-short
  //body
  strokeWeight(1);
  rectMode(CENTER);
  rect(300,280,200,200);//body
  
 
  //glass-band
  stroke(0);
  fill(0);
  rect(230,180,60,20);//glass-band-left
  rect(369.5,180,60,20);//glass-band-right

  ellipse(202,180,10,20);//glass-band-left-circle
  ellipse(400,180,10,20);//glass-band-right-circle

  //glass
  value=lightness(c);
  //fill(118,124,127);
  ellipse(300,180,80,80);//outliner
  fill(255);
  ellipse(300,180,60,60);//inter
  //buttom of eye-ball
  fill(c);
  noStroke();
  ellipse(300,199,45,21);
  //eye-ball
 fill(0);
 ellipse(x,y,25,25); 
  
  /*if(direction == 'left') {
    x = x - 0.5;
  } else {
    x = x + 0.5;
  }
  
  if(x < 290) {
    direction = 'right';
  } else if (x > 320 ) {
    direction = 'left'
  }*/
  
  if (x > 290 ){  
   speed=-3;
     
  } else if (x < 330) {

     speed=1.2;
   }
  x=x+speed;

  println(x)
  
  

  
  
  //ellipse(300,210,200,100);
  //mouse
  /*beginShape();
  curveVertex(270,350);
  curveVertex(250,100);
  curveVertex(300,150); 
  curveVertex(280,280);
  curveVertex(200,150);
  endShape();*/
  
  //Mouse
  fill(255);
  //stroke(255);
 arc(300,328,70,80,PI,PI,CHORD);//mouth-tip
  fill(0);
  noStroke();
  arc(300,335,100,80,PI,PI,CHORD);//mouse-outliner
  fill(242,120,130);
  arc(300,335,60,30,PI,PI,CHORD);//tougue
  fill(255);
  arc(300,293,30,40,0,PI,OPEN);//teeth-middle
  arc(274,300,30,25,-PI/6,PI-PI/6,OPEN);//teeth-left
  arc(326,300,30,25,PI/6,PI/6+PI,OPEN);//teeth-right
 // arc(320,304,30,10,PI,PI/6,OPEN);//teeth-right-fill
  fill(c);
  arc(300,365,80,70,PI,PI,CHORD);//tougue-buttom
  fill(255);
  
  //leg
  fill(183,50,252);
  rect(250,430,40,40);//leg-left
  rect(340,430,40,40);//leg-right
  
  
  //Pants
  
  arc(300,380,200,100,0,PI,CHORD);//whole-pants
  fill(c);
  arc(300,379,200,40,0,PI,CHORD);//whole-pants-up
 
  //shoes
  fill(0);
  arc(250,445,40,30,0,PI,CHORD);//left-shoes
  arc(340,445,40,30,0,PI,CHORD);//right-shoes
  
  
  //hair
  fill(0);
  beginShape();
  vertex(300,100);
  vertex(330,100);
  vertex(350,120);
  vertex(290,100);
  vertex(320,100);
  vertex(340,120);
  endShape();
 
  arc(300,106,120,40,PI,PI,CHORD);

}

// keyPressed() executes when a key is pressed
function keyPressed() {
}

// mousePressed() executes when a mouse button is pressed
function mousePressed() {
}
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console