Just a quick issue about PDF creation.
If you run the code below you will get 2 PDF files, one which is actually what you see on screen (lines on different weight and color) and another one which is not (all the lines in black a 1px weight).
Any idea how to get the
PGraphics to export weight and color of the strokes?
I'm working on a generative graphics app, and part of my screen is the interface, so I would prefer to use
PGraphics to export just the right area and avoid the PDF being bigger (xy size/format) than the necessary... in the example I'm just avoiding the right half of the screen, but the idea is that way I can also scale the output to the desired PDF size (so I don't need a huge screen if I want the output to be an A1 for instance)
- import processing.opengl.*;
- import processing.pdf.*;
- void setup() {
- size(500, 500, OPENGL);
- background(255);
- PGraphics pdf;
- pdf = createGraphics(250, 500, PDF, "wrong.pdf");
- pdf.beginDraw();
- beginRaw(PDF, "right.pdf");
- for (int i=1; i<25; i++) {
- strokeWeight(i);
- stroke(10*i);
- line(10, 10*i*2, width/2-10, 10*i*2);
- pdf.line(10, 10*i*2, width/2-10, 10*i*2);
- }
- // Switch off the exporter
- pdf.dispose();
- pdf.endDraw();
- endRaw();
- }
Any ideas on how to solve this, or achieve it in other way, will be much appreciated.
1