# Adjust pixels array but don't render on screen p5 js

**URL:** <https://discourse.processing.org/t/adjust-pixels-array-but-dont-render-on-screen-p5-js/9643>\
**Category:** Coding Questions\
**Created:** [March 26, 2019, 2:16pm UTC](https://discourse.processing.org/t/adjust-pixels-array-but-dont-render-on-screen-p5-js/9643 "2019-03-26T14:16:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Milky](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/milky/32/4334_2.png) [@Milky](https://discourse.processing.org/u/Milky)\
**Post date:** [March 26, 2019, 2:16pm UTC](https://discourse.processing.org/t/adjust-pixels-array-but-dont-render-on-screen-p5-js/9643/1 "2019-03-26T14:16:26Z")

</div>

Hello,

I want to train a neural network, which will use the pixels array as input but I don’t want it to constantly render it while I am training it. Is it possible to not render any of the lines and vertices I drew but let it keep adjusting the pixels array? I need the pixels array. I’m not sure if this is the right place to ask this, perhaps it has more to do with javascript than p5, but thought i’d ask here first

---

<div class="post-metadata">

**Author:** ![TfGuy44](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tfguy44/32/41_2.png) [@TfGuy44](https://discourse.processing.org/u/TfGuy44)\
**Post date:** [March 26, 2019, 11:24pm UTC](https://discourse.processing.org/t/adjust-pixels-array-but-dont-render-on-screen-p5-js/9643/2 "2019-03-26T23:24:10Z")

</div>

Can you create a `PGraphics` or `PImage` and use that object’s pixels array instead? Then there would be no need to display it.

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [March 28, 2019, 5:53pm UTC](https://discourse.processing.org/t/adjust-pixels-array-but-dont-render-on-screen-p5-js/9643/3 "2019-03-28T17:53:48Z")

</div>

> [@TfGuy44](#):
>
> Can you create a `PGraphics` or `PImage`

note that for p5.js this would be a p5.image, not a (java) PImage

> **[reference | p5.js](https://p5js.org/reference/#/p5.Image)**
>
> p5.js a JS client-side library for creating graphic and interactive experiences, based on the core principles of Processing.

---

<div class="post-metadata">

**Author:** ![Milky](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/milky/32/4334_2.png) [@Milky](https://discourse.processing.org/u/Milky)\
**Post date:** [March 29, 2019, 6:04am UTC](https://discourse.processing.org/t/adjust-pixels-array-but-dont-render-on-screen-p5-js/9643/4 "2019-03-29T06:04:48Z")

</div>

Thanks for the inputs! So, creating a P5.image, I would be creating a new “image” where I can set the background color and draw things like image.line(x,y) (let’s just say i called the p5.image object “image”) and it will just do that “in the background” without rendering anything and when I call its own pixels array I will be able to see the background color and this line that I drew? That’s pretty much what I need. Also, it will be more efficient right? I mean, it will take shorter time to draw a line let’s say because it won’t actually have to render anything, but rather just change the values in the pixels array

Ah, well guess I can just try it later today when I have time ahha

---

<div class="post-metadata">

**Author:** ![Milky](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/milky/32/4334_2.png) [@Milky](https://discourse.processing.org/u/Milky)\
**Post date:** [March 31, 2019, 1:11pm UTC](https://discourse.processing.org/t/adjust-pixels-array-but-dont-render-on-screen-p5-js/9643/5 "2019-03-31T13:11:46Z")

</div>

Ok, I just realized I can’t draw a line on an image, I can only adjust the individual pixels. I need to be able to draw a line, also I use curveVertex. I wanna create like a canvas object where I can interact just as I would the rendered canvas, but this one should just update the pixels array accordingly and not render anything on the screen  
edit: And my lines are not straight and not 1 pixel wide, I cant just draw a line manually by adjusting the pixels array myself

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [March 31, 2019, 3:23pm UTC](https://discourse.processing.org/t/adjust-pixels-array-but-dont-render-on-screen-p5-js/9643/6 "2019-03-31T15:23:23Z")

</div>

> [@Milky](#):
>
> I need to be able to draw a line

Then instead of a p5.Image, use createGraphics to create a p5.Renderer. That gets you the canvas methods as methods of the renderer object.

> Creates and returns a new p5.Renderer object. Use this class if you need to **draw into** an off-screen graphics buffer. [reference | p5.js](https://p5js.org/reference/#/p5/createGraphics)
