# Help with some Crosshairs

**URL:** https://discourse.processing.org/t/help-with-some-crosshairs/32925
**Category:** Coding Questions
**Tags:** homework
**Created:** [October 19, 2021, 9:23am UTC](https://discourse.processing.org/t/help-with-some-crosshairs/32925 "2021-10-19T09:23:06Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Blaze](https://avatars.discourse-cdn.com/v4/letter/b/e274bd/32.png) [@Blaze](https://discourse.processing.org/u/Blaze)
#### Post date: [October 19, 2021, 9:23am UTC](https://discourse.processing.org/t/help-with-some-crosshairs/32925/1 "2021-10-19T09:23:06Z")

</div>

> please format code with \</\> button \* [homework policy](https://discourse.processing.org/faq/#homework) \* [asking questions](https://discourse.processing.org/t/2147)

So, as part of a class assessment I need to make a spooky halloween scene, so far my code is this

/  
if((mouseX \>= 100) && (mouseX \<= 700) && (mouseY \>= 100) && (mouseY \<= 500))  
{  
strokeWeight(5);  
line(mouseX,102,mouseX,498);  
line(102,mouseY,698,mouseY);  
}

My problem is, when I bring my mouse over the ellipse to change it’s colour, the crosshairs disappear, which isn’t too big an issue, the problem is they don’t reappear once I move the mouse back off, how can I fix this?

---

<div class="post-metadata">

### Author: ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)
#### Post date: [October 19, 2021, 8:26pm UTC](https://discourse.processing.org/t/help-with-some-crosshairs/32925/2 "2021-10-19T20:26:48Z")

</div>

Hi! Welcome to the forum! 👋

I guess you have more lines on your code - because I feel the rest of the code is causing the problem. More concretely, you may have `noStroke()` somewhere to hide lines. But then once `noStroke` is triggered, even once inside `if`, the stroke will not come back. You have to call `stroke(...)` to bring the stroke back, or wrap `noStroke()` inside `push()` / `pop()` to keep the style within the block. Just to illustrate the problem:

```auto
void setup() {
  size(400, 400);
}

void draw() {
  background(128);
  if (mousePressed) {
    noStroke();
    ellipse(100, 100, 50, 50);
  }
  strokeWeight(5);
  line(mouseX, mouseY, mouseX+10, mouseY);
}

```

Once you click, the line will be gone. I think this is the kind of problem you are having. One way to fix is

```auto
void setup() {
  size(400, 400);
}

void draw() {
  background(128);
  if (mousePressed) {
    noStroke();
    ellipse(100, 100, 50, 50);
  }
  stroke(0);
  strokeWeight(5);
  line(mouseX, mouseY, mouseX+10, mouseY);
}

```

and the other (elegant) solution

```auto
void setup() {
  size(400, 400);
}

void draw() {
  background(128);
  if (mousePressed) {
    push();
    noStroke();
    ellipse(100, 100, 50, 50);
    pop();
  }
  strokeWeight(5);
  line(mouseX, mouseY, mouseX+10, mouseY);
}

```

Anyways it’s always a good idea to show the entire code (if the project is big, make sure you make a small enough program to reproduce the problem…)
