Need Help with "unexpected token:void"
in
Programming Questions
•
1 year ago
I want to make somekind of "screenshots" and export them as PDF, in order to map them in another step on a shape.
here you can see the code of a pattern i made and try to export those frames i choose by Mouse pressed.
It would be great if someone could help! Thank you(i work with processing 1.5)
import processing.pdf.*;
import processing.opengl.*;
int anzahl = 3;
float[] x = new float[anzahl];
float[] y = new float[anzahl];
float[] z = new float[anzahl];
float[] speedX = new float[anzahl];
float[] speedY = new float[anzahl];
float[] speedZ = new float[anzahl];
// A boolean variable that when set to true triggers the PDF recording process
boolean recordPDF = false;
void setup() {
// OPENGL or P3D mode requires the use of beginRaw() and endRaw() instead of beginRecord() and endRecord().
size(400, 400, OPENGL);
smooth();
for(int i = 0; i<anzahl;i++){
x[i] = random(100,300);
y[i] = random(100,300);
z[i] = random(100,300);
speedX[i] = random(0.1,2);
speedY[i] = random(0.1,2);
speedZ[i] = random(0.1,2);
}
}
void draw() {
// Begin making the PDF
if (recordPDF) {
beginRaw(PDF, "3D.pdf" ); // If you include "####" in the filename -- "3D-####.pdf" -- separate, numbered PDFs will be made for each frame that is rendered.
}
//background(120);
for(int i = 0; i<anzahl;i++){
x[i] = x[i]+speedX[i];
y[i] = y[i]+speedY[i];
for(int j = 0; j<anzahl;j++){
float d = dist(x[i],y[i],x[j],y[j]);
if(d<150){
stroke(0,map(d,350,350,455,0)/5);
triangle(x[i],y[i],x[j],y[j],x[i],y[j]);
}
}
if(x[i]>width)speedX[i] = speedX[i]*-1;
if(x[i]<0)speedX[i] = speedX[i]*-1;
if(y[i]>height)speedY[i] = speedY[i]*-1;
if(y[i]<0)speedY[i] = speedY[i]*-1;
// End making the PDF
if (recordPDF) {
endRaw();
recordPDF = false;
}
}
// Make the PDF when the mouse is pressed-this is the line i get the"unexpected token"
void mousePressed() {
recordPDF = true;
}
}
}
here you can see the code of a pattern i made and try to export those frames i choose by Mouse pressed.
It would be great if someone could help! Thank you(i work with processing 1.5)
import processing.pdf.*;
import processing.opengl.*;
int anzahl = 3;
float[] x = new float[anzahl];
float[] y = new float[anzahl];
float[] z = new float[anzahl];
float[] speedX = new float[anzahl];
float[] speedY = new float[anzahl];
float[] speedZ = new float[anzahl];
// A boolean variable that when set to true triggers the PDF recording process
boolean recordPDF = false;
void setup() {
// OPENGL or P3D mode requires the use of beginRaw() and endRaw() instead of beginRecord() and endRecord().
size(400, 400, OPENGL);
smooth();
for(int i = 0; i<anzahl;i++){
x[i] = random(100,300);
y[i] = random(100,300);
z[i] = random(100,300);
speedX[i] = random(0.1,2);
speedY[i] = random(0.1,2);
speedZ[i] = random(0.1,2);
}
}
void draw() {
// Begin making the PDF
if (recordPDF) {
beginRaw(PDF, "3D.pdf" ); // If you include "####" in the filename -- "3D-####.pdf" -- separate, numbered PDFs will be made for each frame that is rendered.
}
//background(120);
for(int i = 0; i<anzahl;i++){
x[i] = x[i]+speedX[i];
y[i] = y[i]+speedY[i];
for(int j = 0; j<anzahl;j++){
float d = dist(x[i],y[i],x[j],y[j]);
if(d<150){
stroke(0,map(d,350,350,455,0)/5);
triangle(x[i],y[i],x[j],y[j],x[i],y[j]);
}
}
if(x[i]>width)speedX[i] = speedX[i]*-1;
if(x[i]<0)speedX[i] = speedX[i]*-1;
if(y[i]>height)speedY[i] = speedY[i]*-1;
if(y[i]<0)speedY[i] = speedY[i]*-1;
// End making the PDF
if (recordPDF) {
endRaw();
recordPDF = false;
}
}
// Make the PDF when the mouse is pressed-this is the line i get the"unexpected token"
void mousePressed() {
recordPDF = true;
}
}
}
1