Save PDF on keypress
in
Core Library Questions
•
8 months ago
Hi,
Question,
How can I record with a keypress an another keypress to stop recording (the recording has to be a pdf or png but without the background).
This is what I already have.
Question,
How can I record with a keypress an another keypress to stop recording (the recording has to be a pdf or png but without the background).
This is what I already have.
float x,y,px,py;
float zachter = 0.01;
float diameter = 30;
int weight;
/**
* changing colors and size by moving the mouse
*
* MOUSE
* position x : size
* position y : color
*
* KEYS
* s : save png
* p : save pdf
*/
import java.util.Calendar;
import processing.pdf.*;
boolean savePDF = false;
void setup(){
size(800,800);
smooth();
color(225,223);
}
void draw() {
float targetX = mouseX;
float targetY = mouseY;
float targerY = mouseY;
y = y + (targetY - y) * zachter;
x = x + (targetX - x) * zachter;
strokeWeight(weight);
line(x, y , px, py);
px=y;
py=x;
// end of pdf recording
if (savePDF) {
savePDF = false;
endRecord();
}
}
void keyPressed() {
if (key=='s' || key=='S') saveFrame(timestamp()+"_##.png");
if (key=='p' || key=='P') savePDF = true;
}
String timestamp() {
Calendar now = Calendar.getInstance();
return String.format("%1$ty%1$tm%1$td_%1$tH%1$tM%1$tS", now);
}
1