Draw a line that links pixels with same color
in
Programming Questions
•
1 year ago
Hey! i want to modify this script by adding a function that draws a line that links all the pixels that have the same color, but after i loaded the pixel into x e y arrays i don't know how to go on.
Thanks
PImage img;
int increment=2;
void setup() {
size(2304, 1728);
img = loadImage("PROVA3.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() {
save ("my_picture.jpg");
}
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 = 150 ;
float y = 10;
int val1 = int((sqrt(x*y))*3);
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);
}
loadPixels ();
for (int f = 0 ; f < width; f++);
for (int g = 0; g < height; g++);
updatePixels;
void draw {
line (
}
1