From 07ed9f12b1eef5d9ca6080b6328c2bf437cca0b7 Mon Sep 17 00:00:00 2001 From: benfry Date: Sat, 5 Jun 2010 17:42:13 +0000 Subject: [PATCH] fix for "PDF library matrix is not reset between frames" (bug #1227) --- pdf/src/processing/pdf/PGraphicsPDF.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pdf/src/processing/pdf/PGraphicsPDF.java b/pdf/src/processing/pdf/PGraphicsPDF.java index 9a1c9b007..25c238eb1 100644 --- a/pdf/src/processing/pdf/PGraphicsPDF.java +++ b/pdf/src/processing/pdf/PGraphicsPDF.java @@ -127,6 +127,10 @@ public class PGraphicsPDF extends PGraphicsJava2D { } // System.out.println("beginDraw " + (System.currentTimeMillis() - t0)); super.beginDraw(); + + // Also need to push the matrix since the matrix doesn't reset on each run + // http://dev.processing.org/bugs/show_bug.cgi?id=1227 + pushMatrix(); } @@ -211,6 +215,10 @@ public class PGraphicsPDF extends PGraphicsJava2D { public void endDraw() { + // Also need to pop the matrix since the matrix doesn't reset on each run + // http://dev.processing.org/bugs/show_bug.cgi?id=1227 + popMatrix(); + // This needs to be overridden so that the endDraw() from PGraphicsJava2D // is not inherited (it calls loadPixels). // http://dev.processing.org/bugs/show_bug.cgi?id=1169 @@ -272,6 +280,7 @@ public class PGraphicsPDF extends PGraphicsJava2D { */ public void nextPage() { PStyle savedStyle = getStyle(); + endDraw(); g2.dispose(); try { @@ -285,9 +294,8 @@ public class PGraphicsPDF extends PGraphicsJava2D { } else if (textMode == MODEL) { g2 = content.createGraphics(width, height, mapper); } + beginDraw(); style(savedStyle); - - // should there be a beginDraw/endDraw in here? }