I am trying to render the given sketch into a PDF. Everything Works but when I Export it the PDF is full Black.
Here is the Code
/*
* Author :: Aswin Mohan
* Twitter :: @aswinmohanme
*
* Render an Image of Marlin Monroe with Cirlces , Just Learning
*/
import processing.pdf.*;
import hype.*;
import hype.extended.colorist.*;
HEllipse e;
HImage img;
HPixelColorist colors;
void setup() {
size(500 , 600);
H.init(this)
.background(#000000)
;
// Record PDF
beginRecord(PDF,"marlin.pdf");
// Load the Image and the Colors
img = new HImage("Marlin.gif");
colors = new HPixelColorist(img);
int radius = 10;
int padding = 10;
int numberShapesX = width / ((radius+padding));
int numberShapesY = height / ((radius+padding));
for (int i=0; i < numberShapesX; ++i){
for (int j=0; j < numberShapesY; ++j) {
e = new HEllipse();
e.strokeWeight(0)
.loc(i*(radius+padding)+radius ,j*(radius+padding) + radius)
.size(radius)
.anchorAt(H.CENTER)
;
colors.applyColor(e);
H.add(e);
}
}
}
void draw() {
H.drawStage();
}
void keyPressed() {
if (key == 's'){
endRecord();
exit();
}
}
I'm able to get the Output as PNG using saveFrame() but when I export to PDF , the file gets created but the the Contents are Black.
When I run with noLoop(); before the beginRecording(); , and press 's' , the Following Error Message gets shown.
java.lang.RuntimeException: missing a pushMatrix() to go with that popMatrix()
at processing.awt.PGraphicsJava2D.popMatrix(PGraphicsJava2D.java:2147)
at processing.pdf.PGraphicsPDF.endDraw(Unknown Source)
at processing.core.PApplet.endRecord(PApplet.java:10580)
at MarlinMonroe_Circles.keyPressed(MarlinMonroe_Circles.java:78)
at processing.core.PApplet.keyPressed(PApplet.java:3071)
at processing.core.PApplet.handleKeyEvent(PApplet.java:2947)
at processing.core.PApplet.dequeueEvents(PApplet.java:2621)
at processing.core.PApplet.postEvent(PApplet.java:2607)
at processing.awt.PSurfaceAWT.nativeKeyEvent(PSurfaceAWT.java:1346)
at processing.awt.PSurfaceAWT$10.keyPressed(PSurfaceAWT.java:1399)
at java.awt.Component.processKeyEvent(Component.java:6491)
at java.awt.Component.processEvent(Component.java:6310)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1954)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:806)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1074)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:945)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:771)
at java.awt.Component.dispatchEventImpl(Component.java:4760)
at java.awt.Container.dispatchEventImpl(Container.java:2294)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Finished.
How do I fix this.