Token error
in
Programming Questions
•
1 year ago
Hi, i have this script that alters an image but it doesn't save the altered image. I've tried to add the saving and pdf export part but processing tells the error " unexpected token" in the saving part in the setup line. I really hope you can help me out!
Thanks!
PImage img;
int increment=2;
void setup() {
size(2304, 1728);
img = loadImage("d.JPG");
image(img, 2304, 1728, width, height);
loadPixels();
for (int x = 0; x < ((width*height)-(increment+2)); x+=increment) {
quicksort(pixels, x, x+increment);
}
updatePixels();
glitcher();
}
void draw() {
}
void glitchIt(int jump) {
image(img, 0, 0, 2304, 1728);
loadPixels();
for (int x = 0; x < ((width*height)-(jump+1)); x+=jump) {
quicksort(pixels, x, x+jump);
}
updatePixels();
}
void glitcher() {
float x = 20 ;
float y = 350;
int val1 = int((sqrt(x*y))*2);
glitchIt(val1);
}
int partition(int x[], int left, int right) {
int i = left;
int j = right;
int temp;
int pivot = x[(left+right)/2];
while (i <= j) {
while (x[i] < pivot) {
i++;
}
while (x[j] > pivot) {
j--;
}
if (i <= j) {
temp = x[i];
x[i] = x[j];
x[j] = temp;
i++;
j--;
}
}
return i;
}
void quicksort(int x[], int left, int right) {
int index = partition(x, left, right);
if (left < index - 1) {
quicksort(x, left, index-1);
}
if (index < right) {
quicksort(x, index, right);
}
import processing.pdf.*;
void setup() {
size(400, 400);
noLoop();
beginRecord(PDF, "filename.pdf");
}
void draw() {
// Draw something good here
line(0, 0, width/2, height);
endRecord();
}
}
1