Hi, i would like to write a PDF whenever i press the alt key with different numbered PDF's. In the moment i just get one PDF because i start the recording in setup. But when i write the code in draw () it writes too much PDF's and i cannot open them. I always have this problem, when the changings are not made in draw (). How can i do this better?
import processing.pdf.*;
boolean recordPDF = false;
PFont font;
String letter = "A";
void setup () {
size (800, 800);
background (255);
if (recordPDF == false) {
beginRecord (PDF, "buchstaben####.pdf");
println("recording started");
recordPDF = true;
}
font = createFont ("BirchStd", 10);
textFont (font);
textAlign (CENTER, CENTER);
}
void draw () {
}
void mouseMoved () {
background (255);
fill(mouseX-400, random (255), random (255), 100);
textSize ((mouseX-400)*5+1);
text (letter, width/2, mouseY);
}
void mouseDragged () {
fill(mouseX-400, random (255), random (255), 100);
textSize ((mouseX-400)*5+1);
text (letter, random (width), mouseY);
}
void keyReleased() {
if (keyCode == CONTROL) saveFrame(timeStamp()+"_##.png");
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));