Problem with writing a PDF
in
Programming Questions
•
3 years ago
Hi, I'm new to the processing community and I started with coding some months ago. With one sketch I have a problem. I cannot write a PDF. Either I see just some single, tiny points or the lines are too thick.
I want to write a single PDF with that what I see on the screen after I used the mousePressed function.
Can anybody help me? That would be great!!
import processing.pdf.*;
float[] x = new float[100];
float[] y = new float[100];
PFont font;
void setup() {
size(800, 800);
smooth();
background (0);
fill (255);
textAlign (CENTER);
font = createFont ("Base4", 24);
textFont (font);
text ("bitte erst die alt-Taste, dann mit der Maus klicken", width/2, height/2);
beginRecord (PDF, "galaxis####.pdf");
// Initialisierung aller Elemente beider Arrays
for (int i = 0; i < 30; i++) {
x[i] = random(width);
y[i] = random(height);
}
}
void draw() {
// Zeichnen von Kreisen unter Einsatz einer Schleife und der Arrays
for (int i = 0; i < 100; i++) {
ellipse (x[i], y[i], 0.1, 0.1);
x[i] = x[i] + random (-5, 5);
y[i] = y[i] + random (-5, 5);
}
}
void mousePressed () {
for (int i = 0; i < 100; i++) {
beginShape ();
noFill ();
stroke (255);
strokeWeight (0.1);
curveVertex (x[i], y[i]);
curveVertex (x[i], y[i]);
curveVertex (width/2+ random (50), height/2+ random (150));
curveVertex (mouseX, mouseY);
curveVertex (mouseX, mouseY);
endShape ();
}
}
void keyPressed () {
if (key == 's') {
saveFrame ("strukturen-####.png");
}
if (key=='p' || key=='P') endRecord ();
if (key == CODED) {
if (keyCode == ALT) {
background (0);
}
}
}
1