# Basic drawing of circles with segments of lines doesn't function - must be really basic

**URL:** <https://discourse.processing.org/t/basic-drawing-of-circles-with-segments-of-lines-doesnt-function-must-be-really-basic/43161>\
**Category:** Beginners\
**Created:** [November 7, 2023, 3:10pm UTC](https://discourse.processing.org/t/basic-drawing-of-circles-with-segments-of-lines-doesnt-function-must-be-really-basic/43161 "2023-11-07T15:10:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![amundsen](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/amundsen/32/2497_2.png) [@amundsen](https://discourse.processing.org/u/amundsen)\
**Post date:** [November 7, 2023, 3:10pm UTC](https://discourse.processing.org/t/basic-drawing-of-circles-with-segments-of-lines-doesnt-function-must-be-really-basic/43161/1 "2023-11-07T15:10:26Z")

</div>

Hello,

Tthis sketch doesn’t draw circles using segments of lines as it is expected to do. The positions do not evolve and I don’t understand why. It must be as plain as the nose on your face but I can’t see it…

🤨

```auto
float diameterX, diameterY, startX, startY, endX, endY;
int step;

void setup() {
  size(1000, 1000);
  background(64);
  step = 99;
  stroke(255,0,0);
  strokeWeight(20);
}

void draw() {
  step+=1;
  if (step > 99) {
    delay(1000);
    step = 0;
    background(64);
    diameterX = random(width/2)+width/2;
    diameterY = random(height/2)+height/2;
    startX = sin(0)*diameterX/2; // or sin(0) or 0
    startY = cos(0)*diameterY/2;
    println("diameterx: "+diameterX+" / diametery: "+diameterY);  
  }  
  endX = sin((step+1)/100 * TWO_PI)*diameterX/2;
  endY = cos((step+1)/100 * TWO_PI)*diameterY/2;
  println("step: "+step+" / startX: "+startX+" / startY: "+startY+" / endX: "+endX+" / endY: "+endY);
  line((int)(startX+width/2), (int)(startY+height/2), (int)(endX+width/2), (int)(endY+height/2));
  startX = endX;
  startY = endY;
}

```

---

<div class="post-metadata">

**Author:** ![scudly](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/scudly/32/5597_2.png) [@scudly](https://discourse.processing.org/u/scudly)\
**Post date:** [November 7, 2023, 4:03pm UTC](https://discourse.processing.org/t/basic-drawing-of-circles-with-segments-of-lines-doesnt-function-must-be-really-basic/43161/2 "2023-11-07T16:03:33Z")

</div>

Integer division returns an integer.  
`(step+1)/100` will be zero when step is less than 99.

Make “step” a float instead of an integer. Or multiply by the float `TWO_PI` before doing the `/100`.

---

<div class="post-metadata">

**Author:** ![amundsen](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/amundsen/32/2497_2.png) [@amundsen](https://discourse.processing.org/u/amundsen)\
**Post date:** [November 7, 2023, 4:06pm UTC](https://discourse.processing.org/t/basic-drawing-of-circles-with-segments-of-lines-doesnt-function-must-be-really-basic/43161/3 "2023-11-07T16:06:48Z")

</div>

Of course! Thanks a lot @scudly !
