wondering about beginRecord() on some buffer (P2D PGraphics, SVG, PDF, PApplet)
in
Programming Questions
•
10 months ago
hi!
I need some practical way to handle a drawing in both screen and some offscreen pgraphics with the same method.
I have seen that the super cool P8gGraphicsSVG and the PDF exporter works nice with beginRecord/endRecord but not the normal PGraphics (that I need for showing the screenshot) with P2D.
For now I have a dirty adapter class in which i have wrote some basic wrapper (i'm using only push/popMatrix, line, ellipse, transate, scale, fill and stroke). But I don't really like it.
So i basically have something like this:
- Adapter a_screen = new Adapter();
- a_screen.setPApplet(this); // this is PApplet instance
-
- PGraphics offScreen = createGraphics(width, height, P2D);
- Adapter a_offScreen = new Adapter();
- screenshot.setPGraphics(offScreen);
-
- PGraphics pdf = createGraphics(width, height, PDF, "test.pdf");
- Adapter a_pdf = new Adapter();
- a_pdf.setPGraphics(pdf);
-
- drawImage(a_screen);
- drawImage(a_offScreen);
- drawImage(a_pdf);
-
- ...
-
- void drawImage(Adapter a) {
- a.fill(...);
- a.pushMatrix();
- a.translate(...);
- a.rect(...);
- a.popMatrix();
- }
but i'm having some problem (with translations and push/popmatrix i think)
EDIT: with P8gGraphicsSVG works perfectly
I don't find some information about this so i thought to ask here..
1