# Can someone help me with getting this clock right?

**URL:** <https://discourse.processing.org/t/can-someone-help-me-with-getting-this-clock-right/28012>\
**Category:** Coding Questions\
**Created:** [February 23, 2021, 1:47am UTC](https://discourse.processing.org/t/can-someone-help-me-with-getting-this-clock-right/28012 "2021-02-23T01:47:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cocopuffs](https://avatars.discourse-cdn.com/v4/letter/c/6a8cbe/32.png) [@cocopuffs](https://discourse.processing.org/u/cocopuffs)\
**Post date:** [February 23, 2021, 1:47am UTC](https://discourse.processing.org/t/can-someone-help-me-with-getting-this-clock-right/28012/1 "2021-02-23T01:47:59Z")

</div>

At the moment, I have dots/ellipses around the clock as marks for the numbers. I’m trying to make them as lines, like a normal analog clock has, but I’m not sure how to do this. So how do I make the dots/ellipses as lines?

int hourHand = 135;  
int minHand = 210;  
int secHand = 250;  
int centerX = 350;  
int centerY =350;  
float angle;  
float x;  
float y;

void setup() {  
size(700, 700);  
}

void draw () {

stroke(255);  
background(0);  
float quarterCircle = PI/2;

// for the ellipse  
for (int i=1; i\<=60; i++) {  
angle = i \* PI / 30.0;  
float x = (centerX + cos(angle)\* secHand);  
float y =(centerY + sin(angle)\* secHand);  
if(i % 5 != 0) {  
point(x,y);  
}  
else {  
ellipse(x, y, 5, 5);  
}  
}  
//hour hand  
strokeWeight(1);  
stroke(255);  
line(centerX, centerY, x, y);  
angle = ((2 \* PI/12) \* hour()) + ((2 \* PI/720) \* minute()) - quarterCircle ;  
x = centerX + hourHand \* cos(angle);  
y = centerY + hourHand \* sin(angle);

//minute hand  
strokeWeight(4);  
stroke(255);  
line(centerX, centerY , x, y);  
angle = ((2 \* PI/60) \* minute()) - quarterCircle;  
x = centerX + minHand \* cos(angle);  
y = centerY + minHand \* sin(angle);

//second hand  
strokeWeight(2);  
stroke(255);  
line(centerX, centerY , x, y);  
angle = ((2 \* PI/60) \* second()) - quarterCircle;  
x = centerX + secHand \* cos(angle);  
y = centerY + secHand \* sin(angle);  
}

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [February 23, 2021, 9:25am UTC](https://discourse.processing.org/t/can-someone-help-me-with-getting-this-clock-right/28012/2 "2021-02-23T09:25:11Z")

</div>

Hello,

you can use the points (x,y) you already have for the new line.

Then you calculate another point x2,y2 nearer the clock’s center (just a smaller radius).

connect both points with a line : `line(x, y, x2, y2);`

Warm regards,

Chrisir

```auto
int hourHand = 135;
int minHand = 210;
int secHand = 250;
int centerX = 350;
int centerY =350;
float angle;
float x;
float y;

void setup() {
  size(700, 700);
}

void draw () {

  stroke(255);
  background(0);
  float quarterCircle = PI/2;

  // for the ellipse
  for (int i=1; i<=60; i++) {
    angle = i * PI / 30.0;
    float x = (centerX + cos(angle)* secHand);
    float y = (centerY + sin(angle)* secHand);

    float x2 = (centerX + cos(angle)* (secHand-11));
    float y2 = (centerY + sin(angle)* (secHand-11));

    if (i % 5 != 0) {
      //point(x, y);
      line(x, y, 
        x2, y2);
    } else {
      line(x, y, 
        x2, y2);
      ellipse(x, y, 5, 5);
    }
  }
  //hour hand
  strokeWeight(1);
  stroke(255);
  line(centerX, centerY, x, y);
  angle = ((2 * PI/12) * hour()) + ((2 * PI/720) * minute()) - quarterCircle ;
  x = centerX + hourHand * cos(angle);
  y = centerY + hourHand * sin(angle);

  //minute hand
  strokeWeight(4);
  stroke(255);
  line(centerX, centerY, x, y);
  angle = ((2 * PI/60) * minute()) - quarterCircle;
  x = centerX + minHand * cos(angle);
  y = centerY + minHand * sin(angle);

  //second hand
  strokeWeight(2);
  stroke(255);
  line(centerX, centerY, x, y);
  angle = ((2 * PI/60) * second()) - quarterCircle;
  x = centerX + secHand * cos(angle);
  y = centerY + secHand * sin(angle);
}

```
