# Using void in PGraphics

**URL:** <https://discourse.processing.org/t/using-void-in-pgraphics/4045>\
**Category:** Coding Questions\
**Created:** [October 2, 2018, 12:26pm UTC](https://discourse.processing.org/t/using-void-in-pgraphics/4045 "2018-10-02T12:26:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lore](https://avatars.discourse-cdn.com/v4/letter/l/9dc877/32.png) [@Lore](https://discourse.processing.org/u/Lore)\
**Post date:** [October 2, 2018, 12:26pm UTC](https://discourse.processing.org/t/using-void-in-pgraphics/4045/1 "2018-10-02T12:26:32Z")

</div>

Hello,

I have this section of code here

```auto
void myArc(float cx, float cy) 
{
  float r = size / 2;
  float yOffset = (4*r) / (3*PI);
  
  circles.beginDraw();
  circles.pushMatrix();
  circles.translate(cx, cy - yOffset);
  circles.arc(0, 0, size, size, 0, PI, CHORD);
  circles.popMatrix();
  circles.endDraw();
  
  pushMatrix();
  translate(cx, cy - yOffset);
  arc(0, 0, size, size, 0, PI, CHORD);
  popMatrix();
}

```

but when I try to put it in my PGraphics layer, it doesn’t work

```auto
circles.beginDraw();
    circles.noStroke();
    circles.fill(col);
    circles.myArc(mouseX, mouseY);
    circles.endDraw();

```

it says the function myArc doesn’t exist. How do I fix this? (I want to draw myArc on my PGraphics layer)

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [October 2, 2018, 12:41pm UTC](https://discourse.processing.org/t/using-void-in-pgraphics/4045/2 "2018-10-02T12:41:29Z")

</div>

> [@Lore](#):
>
> circles.myArc(mouseX, mouseY);

try  
myArc(mouseX, mouseY);  
only

---

<div class="post-metadata">

**Author:** ![Lore](https://avatars.discourse-cdn.com/v4/letter/l/9dc877/32.png) [@Lore](https://discourse.processing.org/u/Lore)\
**Post date:** [October 2, 2018, 3:49pm UTC](https://discourse.processing.org/t/using-void-in-pgraphics/4045/3 "2018-10-02T15:49:53Z")

</div>

It works, but does not have the intended effect. In my full code, I want to only draw the arc when the mouse is pressed. This makes it draw when the mouse isn’t pressed.

---

<div class="post-metadata">

**Author:** ![TheWizardBear](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/thewizardbear/32/3552_2.png) [@TheWizardBear](https://discourse.processing.org/u/TheWizardBear)\
**Post date:** [October 2, 2018, 6:01pm UTC](https://discourse.processing.org/t/using-void-in-pgraphics/4045/4 "2018-10-02T18:01:40Z")

</div>

try:

```auto
if(mousePressed){
  myArc(mouseX, mouseY);
}
```

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [October 4, 2018, 4:44am UTC](https://discourse.processing.org/t/using-void-in-pgraphics/4045/5 "2018-10-04T04:44:33Z")

</div>

Please, no need to create duplicates of your posts. For your function to work, you need to provide the exact parameters. You can find the information in the reference. For instance, [here] is the info for arc.

Kf
