Rendering ControlP5 or CP5magic controls when exporting PDF
in
Contributed Library Questions
•
1 year ago
Hello,
I'm trying to export the whole canvas of my processing sketch as a pdf file.
Exporting what is being rendered behind the controlP5 controls works perfectly fine. However, what i want the CP5 controls to show in the PDF as well.
I'm using the marvelous CP5magic extension for eclipse for all controlP5 matters
Here's a short code snippet to serve as basis.
- package vicr_txt_test;
- //////////////////IMPORTS///////////////////
- import java.util.Calendar;
- import objimp.*;
- import processing.core.PApplet;
- import toxi.geom.Rect;
- import toxi.geom.Vec2D;
- import toxi.geom.Vec3D;
- import toxi.gui.GUIElement;
- import toxi.gui.GUIManager;
- import toxi.gui.Range;
- import toxi.physics2d.VerletParticle2D;
- import toxi.physics2d.VerletPhysics2D;
- import toxi.physics2d.behaviors.AttractionBehavior;
- import toxi.processing.ToxiclibsSupport;
- import controlP5.ControlGroup;
- import controlP5.ControlP5;
- import controlP5.ControlWindow;
- import processing.opengl.*;
- import controlP5.*;
- public class vicr_txt_test extends PApplet {
- /**********************************************/
- // _________________CP5_______________________//
- boolean savePDF = true;
- String cadSoftware, ext;
- ///CP5
- ControlP5 controlP5;
- public GUIManager gui;
- @GUIElement(label = "radius")
- @Range(min = 0, max = 1000)
- public float circleRadius = 1;
- // //////////////////////////////////////////
- public void setup() {
- size(1190, 841); // A3 proportions
- smooth();
- controlP5 = new ControlP5(this);
- initGUI();
- }
- public void draw() {
- startExport();
- background(255);
- ellipse(width/2, height/2, circleRadius, circleRadius);
- endExport();
- }
- public void keyReleased() {
- if (key == 'p') {
- savePDF = true;
- }
- if (key == 's')
- save(timestamp());
- }
- private void initGUI() {
- ControlP5 cp5 = new ControlP5(this);
- gui = new GUIManager(cp5);
- gui.createControllers(this, 20, 20, "Physics Control");
- for (int i = 0; i < cp5.getControllerList().length; i++) {
- cp5.getControllerList()[i].setColorLabel(0);
- }
- }
- public void startExport() {
- if (savePDF)
- beginRaw(PDF, "output/VICR_EXPORT_" + frameCounter + "_"
- + timestamp() + ".pdf");
- }
- public void endExport() {
- if (savePDF) {
- savePDF = false;
- endRecord();
- println("pdf saved...");
- }
- }
- // timestamp
- String timestamp() {
- Calendar now = Calendar.getInstance();
- return String.format("%1$ty%1$tm%1$td_%1$tH%1$tM%1$tS", now);
- }
- }
I've tried all i could think about, but i never managed to get the controls to export...
Would really appreciate some help here as i've got a deadline approaching fast. And really need the controls to appear in my exports.
I'd really rather not have to rely on the old printScreen solution...
1