# createGraphics save the whole sketch

**URL:** <https://discourse.processing.org/t/creategraphics-save-the-whole-sketch/13594>\
**Category:** Coding Questions\
**Created:** [August 25, 2019, 7:50pm UTC](https://discourse.processing.org/t/creategraphics-save-the-whole-sketch/13594 "2019-08-25T19:50:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![l3ehfar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/l3ehfar/32/4074_2.png) [@l3ehfar](https://discourse.processing.org/u/l3ehfar)\
**Post date:** [August 25, 2019, 7:50pm UTC](https://discourse.processing.org/t/creategraphics-save-the-whole-sketch/13594/1 "2019-08-25T19:50:41Z")

</div>

how can I pass the whole sketch as a function to the createGraphics variable and not get the error as “img.pattern is not a function”?

---

<div class="post-metadata">

**Author:** ![Tiemen](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tiemen/32/5477_2.png) [@Tiemen](https://discourse.processing.org/u/Tiemen)\
**Post date:** [August 26, 2019, 11:35am UTC](https://discourse.processing.org/t/creategraphics-save-the-whole-sketch/13594/2 "2019-08-26T11:35:13Z")

</div>

Do you have some code or an online example for us to take a look at?

---

<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:** [August 26, 2019, 11:44am UTC](https://discourse.processing.org/t/creategraphics-save-the-whole-sketch/13594/3 "2019-08-26T11:44:12Z")

</div>

[https://p5js.org/reference/#/p5/createGraphics](https://p5js.org/reference/#/p5/createGraphics) ,  
i think the idea is to create a add buffer and draw INTO it.  
( other as the example:  
-a- create in setup()  
-b- draw into it in setup also if static  
-c- draw in draw()  
later you can show it in draw…

so create a canvas first by normal draw()…  
and then copy it into a Graphics buffer  
? what sense would it make, even if possible.

* * *

for save canvas to picture file pls use  
[https://p5js.org/reference/#/p5/saveCanvas](https://p5js.org/reference/#/p5/saveCanvas)

---

<div class="post-metadata">

**Author:** ![l3ehfar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/l3ehfar/32/4074_2.png) [@l3ehfar](https://discourse.processing.org/u/l3ehfar)\
**Post date:** [August 26, 2019, 11:44am UTC](https://discourse.processing.org/t/creategraphics-save-the-whole-sketch/13594/4 "2019-08-26T11:44:35Z")

</div>

Actually this is a huge project:

> **[l3ehfar/Patternitecture](https://Github.com/l3ehfar/Patternitecture)**
>
> A semi-generative pattern study as a collaborative project between an architect, a coder and a sound designer. We simply wired the project to the floor with a piezo so as the viewer walks close by...

  
I have this function called “mainShow(n)” and I want it to show in my createGraphics “pg” as=\> pg.mainShow(n); but I got the error that it is not a function

---

<div class="post-metadata">

**Author:** ![l3ehfar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/l3ehfar/32/4074_2.png) [@l3ehfar](https://discourse.processing.org/u/l3ehfar)\
**Post date:** [August 26, 2019, 12:02pm UTC](https://discourse.processing.org/t/creategraphics-save-the-whole-sketch/13594/5 "2019-08-26T12:02:39Z")

</div>

saving canvas as a picture file causes my code to crash! and as I mention below my my project is huge, I put the whole project in seperate function and I wanna add that function into createGraphics but it does’t let me so

---

<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:** [August 26, 2019, 12:17pm UTC](https://discourse.processing.org/t/creategraphics-save-the-whole-sketch/13594/6 "2019-08-26T12:17:40Z")

</div>

> [@l3ehfar](#):
>
> my project is huge

yes, but here for the forum and easy understanding,  
you should make a extra small example of your problem  
to show what you try to do.

> [@l3ehfar](#):
>
> I have this function … and I want it to show in my createGraphics “pg” as=\> pg.mainShow(n); but I got the error that it is not a function

a class could have a function a graphics buffer not.
