Browse Source

added fxWrongQSort

master
Victor Giers 1 year ago
parent
commit
003d4f837c
3 changed files with 118 additions and 2 deletions
  1. 1
    1
      data/saves.sav
  2. 110
    0
      effects.pde
  3. 7
    1
      statics_and_lists.pde

+ 1
- 1
data/saves.sav View File

@@ -1,2 +1,2 @@
//globals
uptime = 116775809
uptime = 116778844

+ 110
- 0
effects.pde View File

@@ -2715,6 +2715,116 @@ class DRIPDRIP extends Shader {
}
}

/*

WRONGQSORT
*/

class WRONGQSORT extends Shader {
int max_display_size = 800; // viewing window size (regardless image size)

boolean mode = L; // L or R, which sort part is broken

boolean do_blend = false; // blend image after process
int blend_mode = OVERLAY; // blend type

static final boolean L = true;
static final boolean R = false;

// working buffer
PGraphics buffer;

// image
PImage img;

float random_point = 0.5;
int len;

//bei mausmove
WRONGQSORT() {
name = "fxWrongQSort";
params.add(new Param ("x", FLOATVAL, 0, 1, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE}));
params.add(new Param ("y", FLOATVAL, 0, 1, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE}));
params.add(new Param ("randomize", FLOATVAL, 0.1, 0.9, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE}));
params.add(new Param ("direction", INTVAL, 0, 3, new int[]{RANDOM}));
directionParamIndex = 3;
/*
buffer = createGraphics(canvas.width, canvas.height);
buffer.beginDraw();
buffer.noStroke();
buffer.smooth(8);
buffer.background(0);
buffer.image(img, 0, 0);
buffer.endDraw();
*/
}

void apply() {
float x = params.get(0).value;
float y = params.get(1).value;
int v = (int)map(x*y, 0, 1, 1, len-1);
random_point = params.get(2).value;


canvas.beginDraw();
canvas.image(img, 0, 0);
canvas.endDraw();

canvas.loadPixels();
int x = 0;
while (x<len) {
if (x+v<len) quicksort(canvas.pixels, x, x+v);
else quicksort(canvas.pixels, x, len-1);
x+=v;
}
canvas.updatePixels();

if (do_blend) {
canvas.beginDraw();
canvas.blend(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height, blend_mode);
canvas.endDraw();
}
}


int partition(int x[], int left, int right) {
int i = left;
int j = right;
int temp;
int pivot = x [(int)map(random_point, 0, 1, left, right)];
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) {
if (left<right) {
int index = partition(x, left, right);
if (mode) {
if (left < index-1) quicksort(x, left, index-1);
if (right < index) quicksort(x, index, right);
} else {
if (left > index-1) quicksort(x, left, index-1);
if (right > index) quicksort(x, index, right);
}
}
}
}




+ 7
- 1
statics_and_lists.pde View File

@@ -20,6 +20,11 @@ final static int RAMPINVERSE = 8; //line for half the sequence up to 1, then sta
final static int RAMPUPDOWN = 9; //line up, stay, line down, stay
final static int RANDOM = 10;


// FLAGS, ALGORITHMS and EASING mathod by sulej for ultimate sort



//colorspaces from tomasz sulej's FM effect

final static int COLORSPACES = 16;
@@ -67,5 +72,6 @@ String availableFx[] = {
"fxDrawStrokes",
"fxDrawGenerative",
"fxPixelDrifter",
"fxDripDrip"
"fxDripDrip",
"fxWrongQSort"
};

Loading…
Cancel
Save