# How to access main p5.Renderer object?

**URL:** <https://discourse.processing.org/t/how-to-access-main-p5-renderer-object/34951>\
**Category:** Beginners\
**Created:** [February 3, 2022, 9:19am UTC](https://discourse.processing.org/t/how-to-access-main-p5-renderer-object/34951 "2022-02-03T09:19:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![benjaminmarkus](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/benjaminmarkus/32/7413_2.png) [@benjaminmarkus](https://discourse.processing.org/u/benjaminmarkus)\
**Post date:** [February 3, 2022, 9:19am UTC](https://discourse.processing.org/t/how-to-access-main-p5-renderer-object/34951/1 "2022-02-03T09:19:32Z")

</div>

Is there a way to refer to the main p5.Renderer object that draws to the canvas in a way one would refer to an object created with createGraphics()? An example:

```auto
//how it works when you created a Renderer:
var myRenderer = createGraphics(100,100);
myRenderer.ellipse(50,50,20,20);

//what I want (let's call the main Renderer canvasRenderer):
canvasRenderer.ellipse(50,50,20,20);
//and I want this to behave exactly like simply calling
ellipse(50,50,20,20);

```

So what I’m interested in is what to actually write instead of the made up name “canvasRenderer” to have this functionality.

My reason is that I have a function that draws stuff onto a Renderer I pass as an argument and it’s great when I intend to draw to a Renderer I created, but I’d like to use the same function to draw to the main canvas too, and for that I’d need to pass a reference to it.

---

<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:** [February 6, 2022, 12:42am UTC](https://discourse.processing.org/t/how-to-access-main-p5-renderer-object/34951/2 "2022-02-06T00:42:55Z")

</div>

> [@benjaminmarkus](#):
>
> Is there a way to refer to the main p5.Renderer object that draws to the canvas…

You can use _\_renderer_ or _\_currentElement_ for it.

Another option is _p5.instance_ which keeps the reference for the global sketch.
