Pen Settings

HTML

CSS

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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

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.

HTML

            
              
            
          
!

CSS

            
              
            
          
!

JS

            
              //Sources:
//Dan Shiffman's Clocks Coding Challenge: https://www.youtube.com/watch?v=E4RyStef-gY&feature=youtu.be
//Gear logic from a Processing Sketch by Sho Uchida https://www.openprocessing.org/sketch/150628
//Watch illustration and Sketch file by Adil Ahmad https://www.sketchappsources.com/free-source/2256-hublot-big-bang-watch-mockup-sketch-freebie-resource.html

var gearSe1;
var gearSe2;
var gearMn1;
var gearMn2;
var img; //watch image
var img2; //seconds hand logo
var c;

function mousePressed(){
  c = mouseX; //debug
}

function preload(){
  img = loadImage('https://s3-us-west-2.amazonaws.com/s.cdpn.io/121795/hb2.png');
  img2 = loadImage('https://s3-us-west-2.amazonaws.com/s.cdpn.io/121795/seconds2.png')
}

function setup(){
  createCanvas(800, 800);
  angleMode(DEGREES);
  ellipseMode(CENTER);
  imageMode(CENTER);
}

function draw(){
  background(10);
  let hr = hour();
  let mn = minute();
  let se = second();
  let dt = day();
  let end1 = map(se, 0, 60, 0, 360);
  let end2 = map(mn, 0, 60, 0, 360);
  let end3 = map(hr%12, 0, 12, 0, 360);

push();
  translate(height/2, width/2);
  image(img, 20, 1, 500, 550);
  rotate(-90);

  strokeWeight(10);
  stroke(10);
  //arc (0, 0, 300, 300, 0, 360);

  //Draw gears
  strokeWeight(1);
  stroke(200,200);
  gearSe1 = new gear(0,0,120,40,29, -end1*360);
  fill(0);
  gearSe1.update();
  gearSe2 = new gear(-56,-68,120,50,43, end1*360);
  gearSe2.update();


  stroke(200,200);
  fill(0,255);
  ellipse(0,0,15,15);
  ellipse(-56,-68,80,80);
  stroke(200,180);
  rect(-56,-108,3,79);
  push();
  rotate(70);
  rect(-84,68,3,-50);
  pop();
  push();
  rotate(120);
  rect(-30,44,3,79);
  pop();
  fill(192);
  ellipse(-56,-68,30,30);
  noFill();
  gearMn2 = new gear(41,52,240,28,27,end1*360);
  gearMn1 = new gear(41,52,240,23,20,mn*360);
  stroke(192,192,192);
  gearMn1.update();
  gearMn2.update();

  //noStroke();
  fill(0,255);
  //ellipse(41,52,46,46);



  //Hour Markers and Date

  for (var i = 0; i<12; i++){
    noStroke();
    fill(255,255,0);
    rectMode(CENTER);
    rect (148,0,10,3)
    if (i==3){
      //noFill();
      stroke(192,192,192);
      noFill();
      strokeWeight(1);
      ellipse(120,1,34,34);
      textSize(17);
      noStroke();
      fill(192,190);
      text(dt, 110, 7);
    }
    rotate(30);
  }

    //Draw Minutes Hand
    push();
      rotate(end2);
      strokeWeight(6);
      stroke(255,255,0);
      line(0,0,130,0);
    pop();

    //Draw Hours Hand
    push();
      rotate(end3);
      strokeWeight(10);
      stroke(255,255,0);
      line(0,0,65,0);
    pop();

  //Draw Seconds Hand
  push();
    rotate(end1);
    strokeWeight(1);
    stroke(255,0,0);
    rectMode(CENTER);
    stroke(255,0,0);
    strokeWeight(2);
    line(-50,0,130,0);
    image(img2, -63 , 0, 25, 25);

    strokeWeight(1);
    stroke(255,0,0);
    fill(255);
    triangle(126,-3,126,4, 135,0 );
    fill(255,0,0);
    ellipse (0,0,15,15);
    stroke(255,255);
    strokeWeight(1);

    noStroke();
    fill(255,255);
    //rect(106,0,42,5);
    fill(0);
    ellipse (0,0,8,8);
  pop();

pop();

}

  function gear(x,y,vertexNum,rOut,rIn,c){
  this.pos = createVector(x, y);
  //this.r = r;
  this.vertexNum = vertexNum;
  this.rIn = rIn;
  this.rOut = rOut;
  this.c = c;

  this.update = function(){
    push();
      translate(this.pos.x,this.pos.y);
      rotate(radians(c));
      beginShape();
        for (var i = 0;i < this.vertexNum;i++) {
          if (i%4==2 || i%4==3) {
            var r = this.rOut;
          }
          else {
            var r = this.rIn;
          }
         
          vertex(r*cos(360*i/this.vertexNum), r*sin(360*i/this.vertexNum));

        }
      endShape(CLOSE);
    pop();
  }
}

            
          
!
999px

Console