# oscP5, can't draw shapes from inside the oscEvent function

**URL:** <https://discourse.processing.org/t/oscp5-cant-draw-shapes-from-inside-the-oscevent-function/26309>\
**Category:** Libraries\
**Created:** [December 16, 2020, 8:04pm UTC](https://discourse.processing.org/t/oscp5-cant-draw-shapes-from-inside-the-oscevent-function/26309 "2020-12-16T20:04:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![adamstephensun](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@adamstephensun](https://discourse.processing.org/u/adamstephensun)\
**Post date:** [December 16, 2020, 8:04pm UTC](https://discourse.processing.org/t/oscp5-cant-draw-shapes-from-inside-the-oscevent-function/26309/1 "2020-12-16T20:04:40Z")

</div>

I am fairly new to processing but have experience in other languages. I am using the oscP5 library to send coordinates from Unity to processing over osc.

However, I am having an issue with drawing shapes from within the oscEvent function. This snippet is from within the oscEvent function.

```auto
    else if(theOscMessage.addrPattern().equals(ballPattern)){
        float oscX = theOscMessage.get(0).floatValue();
        float oscY = theOscMessage.get(1).floatValue();
        
        println("#OSC# Recieved message: "+theOscMessage.addrPattern()+" x:"+oscX+" y:"+oscY);
        drawPaintball(oscX,oscY);
    }

```

When drawPaintball() is called, the data is sent through and processed properly (I can see it is correct in the console and debug menu) but the ellipse is not drawn.

```auto
void drawPaintball(float x, float y)
{
  float newX = abs(x) * (width * 2);
  float newY = abs(y) * (height * 2);
 
  println("Paintball on "+newX+" "+newY); 
  ellipse(newX,newY, 40, 40);
}

```

When I call this function from outside the oscEvent function, it works as is intended. I have also tried calling the ellipse() function within the oscEvent function and hard-coding the values, which also doesn’t draw an ellipse().

I appreciate any help.

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [December 16, 2020, 8:30pm UTC](https://discourse.processing.org/t/oscp5-cant-draw-shapes-from-inside-the-oscevent-function/26309/2 "2020-12-16T20:30:03Z")

</div>

> [@adamstephensun](#):
>
> When I call this function from outside the **oscEvent function()**, it works as is intended.

> [@Stumped by something simple](https://discourse.processing.org/t/stumped-by-something-simple/10057/9):
>
> Even though Processing enqueues input events in a separate Thread, it dequeues them in the main “Animation” Thread. So it’s safe to “draw” when using Processing’s own input callbacks. Now, if a 3rd-party library deals w/ hardware, its callbacks got a very high chance to happen in a separate Thread. Therefore, it’s highly unsafe to mutate the main canvas under a separate Thread. In order to find out which Thread is executing a method, just place this statement there: println(Thread.currentTh…

---

<div class="post-metadata">

**Author:** ![adamstephensun](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@adamstephensun](https://discourse.processing.org/u/adamstephensun)\
**Post date:** [December 17, 2020, 8:19pm UTC](https://discourse.processing.org/t/oscp5-cant-draw-shapes-from-inside-the-oscevent-function/26309/3 "2020-12-17T20:19:17Z")

</div>

Thanks for the reply, this has helped a lot!
