Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
lazyfattree
lazyfattree's Profile
1
Posts
0
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
Save PDF on keypress
[1 Reply]
30-Jan-2013 11:04 AM
Forum:
Core Library Questions
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.
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);
}
«Prev
Next »
Moderate user : lazyfattree
Forum