Print Ready Sketch Py5

Dear All,

I started to use Py5 ( Creating static and dynamic visual is going according to plan and I’m very happy with the Python version of Processing. However still one (important) challenge remains before starting to use Py5 full swing and add it to my drawing pipeline: creating a print-ready export.

I’m aware of multiple tutorials on this topic, for example:

I have seen examples with PGraphics. However all of them are based on other implementations of processing.

I also looked at the ‘PY5 Magics’ but they seem to server other purposes. Or I’m mistaking?

Question 1: Is their an example on how to create print ready sketches (static – via setup as well as dynamic – via draw)?

Question 2: If there are no examples which road would be the one to follow to get this done?

1 Like

Hi @sweetart !

It is possible to create high resolution images with py5, but perhaps the documentation and tutorials for how to do so are a bit lacking. Since py5 is internally using the Processing jars, it should be able to do all the things Processing can do. Let’s talk about this and come up with a good way to do this that fits in your workflow.

First, you mentioned the py5 magics. Did you see the %%py5drawsvg and %%py5drawpdf magics? Both can be used to create svg and pdf files (ie vector graphics).

The other examples in the “Print” tutorial you cited use Processing’s beginRecord() method. py5 also has this feature, called begin_record().

You can also use create_graphics() to create a large off-screen buffer.

Does one of these options look like it would be a good fit for you?


Hi @hx2A,

Thank you for your answer. The documentation might be a little bit challenging when you have no ‘real’ idea to start with this issue. I think the documentation in general is very cgood.

The PY5 Magics do not seem to integrate with my workflow. However, later this week I will try how they work and see what the result is.

I implemented a ‘quick-and-dirty’ begin_record. Which now works with a PDF but I get an empty SVG. But this might have something todo with pixels versus vectors or the use photos? I will also check this out later this week.

The create_graphics puzzles me the most. Because it seems I have to adjust all the code to get this to work.

When I did some experimenting I will come back to this thread.

I recommend making some small prototypes to explore the different options. With the begin_record() approaches, try making something small that just draws a rectangle to verify that you are getting the output you expect and that you understand how to use it. Once that works, add more complexity to it.

Yes, using create_graphics() can involve changing a lot of code but that approach works very well. Your question gives me an idea though for a feature to add to a future version of py5…

1 Like