canvas.size and canvas.save

100 views
Skip to first unread message

Mauro

unread,
Aug 20, 2011, 7:51:04 AM8/20/11
to NodeBox for OpenGL
Hi,

I'm playing with with this beautiful library, really fun to use.

I'm using a custom draw function to generate images that i save with
the canvas.save method.
My problem is that if i choose a canvas size bigger than my screen,
only the visibile portion is drawn and saved to file.
Any idea on how to accomplish draw/save of parts not visible in the
screen?

Thanks a lot!

Mauro

Tom De Smedt

unread,
Aug 23, 2011, 6:56:31 PM8/23/11
to NodeBox for OpenGL
shader.py has an OffscreenBuffer. Instead of drawing directly to the
canvas, you could draw into a buffer. This is handled by the render()
command. For example:

from nodebox.graphics import *
def draw():
background(0.5)
ellipse(x=1024, y=1024, width=1200, height=1200)
img = render(draw, width=2048, height=2048)
img.save('big.png')

Note: there are drawbacks when drawing into a buffer. Lines (i.e.
line(), BezierPath(), ...) will appear more jagged. The colors may be
off when you render an image with a transparent background.

Hope that helps,
Tom

Mauro Bianchi

unread,
Aug 23, 2011, 9:38:13 PM8/23/11
to nodebox-f...@googlegroups.com, NodeBox for OpenGL
Hi Tom,
Thanks for your hint, I'll give it a try.
Another workaround i was thinking about is using the Layer object and its clipping options, but probably I'm on the wrong path...

Best regards
Mauro

Reply all
Reply to author
Forward
0 new messages