# When using save() function my canvas is always grey

**URL:** <https://discourse.processing.org/t/when-using-save-function-my-canvas-is-always-grey/23492>\
**Category:** Processing.py\
**Created:** [August 25, 2020, 7:52pm UTC](https://discourse.processing.org/t/when-using-save-function-my-canvas-is-always-grey/23492 "2020-08-25T19:52:15Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![PutridGospel](https://avatars.discourse-cdn.com/v4/letter/p/ec9cab/32.png) [@PutridGospel](https://discourse.processing.org/u/PutridGospel)\
**Post date:** [August 25, 2020, 7:52pm UTC](https://discourse.processing.org/t/when-using-save-function-my-canvas-is-always-grey/23492/1 "2020-08-25T19:52:15Z")

</div>

Hey I could use a little help, as my title says I am having trouble getting some high resolution files of my artwork. Here is my code please let me know what I could do to get high resolution images of the artwork I make.

\<

t = 0  
points =

def setup():  
size(1260,800)  
save(“this3.jpg”)  
noStroke()

def draw():  
background(255)  
translate(width/2,height/2)  
points =   
t = 0  
while t \< 1000:  
points.append(harmonograph(t))  
t += 0.01

```
for i,p in enumerate(points):
    stroke(255,0,0) 
    if i < len(points) - 1:
        line(p[0],p[1], points[i+1][0],points[i+1][1])

```

def harmonograph(t):  
a1=a2=a3=a4 = 100  
f1,f2,f3,f4 = 2.01,3,3,2  
p1,p2,p3,p4 = -PI/2,0,-PI/16,0  
d1,d2,d3,d4 = 0.00085,0.0065,0,0  
x = a1_cos(f1_t + p1)_exp(-d1_t) + a3_cos(f3_t + p3)_exp(-d3_t)  
y = a2_sin(f2_t + p2)_exp(-d2_t) + a4_cos(f4_t + p4)_exp(-d4_t)  
return [x,y]

> 

Thank you, Drel

---

<div class="post-metadata">

**Author:** ![tabreturn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tabreturn/32/3697_2.png) [@tabreturn](https://discourse.processing.org/u/tabreturn)\
**Post date:** [August 25, 2020, 8:41pm UTC](https://discourse.processing.org/t/when-using-save-function-my-canvas-is-always-grey/23492/2 "2020-08-25T20:41:22Z")

</div>

Welcome, Drel

Your `save()` function is in the `setup()`. You’re saving an image before Processing has a chance to draw anything.

Perhaps you could activate this using a mouse-press instead:

```auto
def setup():
    size(1260,800)
    #save("this3.jpg")
    ...

def mousePressed():
    save("this3.jpg")

```

Alternatively, you could add a `save()` function to the `draw()`, but add some condition to avoid it saving every frame.

---

<div class="post-metadata">

**Author:** ![PutridGospel](https://avatars.discourse-cdn.com/v4/letter/p/ec9cab/32.png) [@PutridGospel](https://discourse.processing.org/u/PutridGospel)\
**Post date:** [August 26, 2020, 5:47pm UTC](https://discourse.processing.org/t/when-using-save-function-my-canvas-is-always-grey/23492/3 "2020-08-26T17:47:03Z")

</div>

Thank you @tabreturn, i shall use the mousePressed and try to work on my conditional statements, I like the latter but my coding rough.

---

<div class="post-metadata">

**Author:** ![PutridGospel](https://avatars.discourse-cdn.com/v4/letter/p/ec9cab/32.png) [@PutridGospel](https://discourse.processing.org/u/PutridGospel)\
**Post date:** [August 26, 2020, 5:53pm UTC](https://discourse.processing.org/t/when-using-save-function-my-canvas-is-always-grey/23492/4 "2020-08-26T17:53:59Z")

</div>

Does the save function warrant high resolution images or do I need to learn the create graphics function?

---

<div class="post-metadata">

**Author:** ![tabreturn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tabreturn/32/3697_2.png) [@tabreturn](https://discourse.processing.org/u/tabreturn)\
**Post date:** [August 26, 2020, 8:04pm UTC](https://discourse.processing.org/t/when-using-save-function-my-canvas-is-always-grey/23492/5 "2020-08-26T20:04:10Z")

</div>

What do mean by “high resolution images”? Your sketch 1260 × 800 pixels. You can just increase the values in your `size()` function for more pixels.

You can insert your `save()` function at the end of your `draw()` loop, followed by an `exit()` function. This way the window will save the graphic on the first frame then close again.

---

<div class="post-metadata">

**Author:** ![PutridGospel](https://avatars.discourse-cdn.com/v4/letter/p/ec9cab/32.png) [@PutridGospel](https://discourse.processing.org/u/PutridGospel)\
**Post date:** [September 3, 2020, 5:50pm UTC](https://discourse.processing.org/t/when-using-save-function-my-canvas-is-always-grey/23492/6 "2020-09-03T17:50:54Z")

</div>

By high resolution I meant, with keeping the window at a size I can view on my computer screen without blowing it past my screens borders ( ie 1260 x 800), i can successfully save now but when I go to zoom in the picture is bitmapped.

Would drawing to the Pgraphics and then saving to a vector format supersede my problem?

---

<div class="post-metadata">

**Author:** ![tabreturn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tabreturn/32/3697_2.png) [@tabreturn](https://discourse.processing.org/u/tabreturn)\
**Post date:** [September 3, 2020, 9:15pm UTC](https://discourse.processing.org/t/when-using-save-function-my-canvas-is-always-grey/23492/7 "2020-09-03T21:15:19Z")

</div>

A JPG is a raster/bitmap image. Zoom in far enough, and you’ll always see pixels.

I’m not sure why you’re using a `draw()` function? After all, you’re saving a single frame? Moreover, why does the Processing output need to fit within your screen borders? Here’s some code that generates and saves an image 5× the resolution of your screen and closes immediately:

```auto
size(6300, 4000)
circle(width/2, height/2, width/3)
save('this3.jpg')
exit()

```

You can always scale the JPG to fit your screen (in your image viewer or similar software); it’ll have the resolution to handle more ‘zooming in’ .

Alternatively, you could render an SVG (vector) version of the sketch:

```auto
add_library('svg')

def setup():
    size(1260, 800, SVG, 'this3.svg')

def draw():
    circle(width/2, height/2, width/3)
    exit()

```

You can leave that file as vector, or rasterize it at your desired resolution (using GIMP, Photoshop, etc.).

---

<div class="post-metadata">

**Author:** ![PutridGospel](https://avatars.discourse-cdn.com/v4/letter/p/ec9cab/32.png) [@PutridGospel](https://discourse.processing.org/u/PutridGospel)\
**Post date:** [September 9, 2020, 12:53pm UTC](https://discourse.processing.org/t/when-using-save-function-my-canvas-is-always-grey/23492/8 "2020-09-09T12:53:43Z")

</div>

Thank you for your response on making this clearer.

I thought I needed to include the draw() command for the software to produce anything on the screen.

Now I understand it’s just for doing more than one frame.

Disregard the notion of it only fitting in my screen boarders, you can scale in a viewfinder yes…. Thank you

I’m just starting out in processing and have made some pretty Frankenstein sketches just looking at what’s on the web and combining and writing.
