# Parallel line that follows the mouse with circle

**URL:** <https://discourse.processing.org/t/parallel-line-that-follows-the-mouse-with-circle/8909>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [March 3, 2019, 7:24pm UTC](https://discourse.processing.org/t/parallel-line-that-follows-the-mouse-with-circle/8909 "2019-03-03T19:24:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JasJones](https://avatars.discourse-cdn.com/v4/letter/j/ea5d25/32.png) [@JasJones](https://discourse.processing.org/u/JasJones)\
**Post date:** [March 3, 2019, 7:24pm UTC](https://discourse.processing.org/t/parallel-line-that-follows-the-mouse-with-circle/8909/1 "2019-03-03T19:24:07Z")

</div>

How can I fix the ellipse in the middle / left outside of the background-window?  
Here is my code until now:

```auto
void setup(){
  size(100,100);
}
void draw(){
  background(200);
  line(mouseX,0,mouseX,100);
  ellipseMode(CORNER);
  ellipse(0,0,mouseX,mouseX);
}

```

* * *

This is the exercise in words:

Draw a line that is parallel to the y-axis and always follows the mouse. In the area between the line and the left edge, a circle should be drawn in the middle, which exactly hits the left and right.

* * *

THX!!! 🙂

---

<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:** [March 3, 2019, 8:25pm UTC](https://discourse.processing.org/t/parallel-line-that-follows-the-mouse-with-circle/8909/2 "2019-03-03T20:25:37Z")

</div>

to pin it in the middle change its y-position to `height / 2` minus its current radius

(when in `ellipseMode(CORNER);` mode)

---

<div class="post-metadata">

**Author:** ![mrmendez](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@mrmendez](https://discourse.processing.org/u/mrmendez)\
**Post date:** [March 5, 2019, 3:00am UTC](https://discourse.processing.org/t/parallel-line-that-follows-the-mouse-with-circle/8909/3 "2019-03-05T03:00:55Z")

</div>

If U want a Circle in the middle, use CENTER, this means the (h,k) coordinates. (x – h)2 + (y – k)2 = r2 , it’s mean ( h , k ) the center.

```auto
void setup(){
   size(100,100);
   ellipseMode(CENTER);
}
void draw(){
   background(200);
   line(mouseX,0,mouseX,height);
   ellipse((mouseX)/2,height/2,mouseX,mouseX);
}

```

![CircleCenter](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/3/35ca44baed2471d5f727272a2d1a9eb3cd6501ea.png)

---

<div class="post-metadata">

**Author:** ![JasJones](https://avatars.discourse-cdn.com/v4/letter/j/ea5d25/32.png) [@JasJones](https://discourse.processing.org/u/JasJones)\
**Post date:** [March 6, 2019, 7:32pm UTC](https://discourse.processing.org/t/parallel-line-that-follows-the-mouse-with-circle/8909/4 "2019-03-06T19:32:42Z")

</div>

Thank you so much!!! 😆
