Browse Source

asdfpixelsort now has a direction parameter

master
Victor Giers 2 years ago
parent
commit
fbe437c08b
2 changed files with 75 additions and 48 deletions
  1. 1
    1
      data/saves.sav
  2. 74
    47
      effects.pde

+ 1
- 1
data/saves.sav View File

@@ -1,2 +1,2 @@
//globals
uptime = 116688775
uptime = 116694051

+ 74
- 47
effects.pde View File

@@ -5,39 +5,66 @@
*/

class ASDFPIXELSORT extends Shader {
PGraphics canvas;
ASDFPIXELSORT() {
name = "fxASDFPixelSort";
params.add(new Param("black", INTVAL, -17000000, -2000000, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANG}));
params.add(new Param("target", INTVAL, 0, 2, new int[]{RANDOM}));
params.add(new Param("direction", INTVAL, 0, 3, new int[]{RANDOM}));
canvas = createGraphics(renderer.width, renderer.height);
}
int previousMode;
int previousDir;
void apply() {
if (previousMode != int(params.get(1).value)) {
if (params.get(1).value == 0) changeParam(0, new Param("black", INTVAL, -17000000, -2000000, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANG}));
if (params.get(1).value == 1) changeParam(0, new Param("brightness", INTVAL, 0, 200, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANG}));
if (params.get(1).value == 2) changeParam(0, new Param("white", INTVAL, -15000000, -700000, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANG}));
}
previousMode = int(params.get(1).value);
previousMode = (int)params.get(1).value;

int direction = (int)params.get(2).value;
int cw = (direction == 0 || direction == 2) ? renderer.width : renderer.height;
int ch = (direction == 0 || direction == 2) ? renderer.height : renderer.width;
if (canvas.width != cw || canvas.height != ch) canvas = createGraphics(cw,ch);
canvas.beginDraw();
canvas.imageMode(CENTER);
canvas.clear();
canvas.pushMatrix();
canvas.translate(cw/2,ch/2);
canvas.rotate((PI/2)*direction);
canvas.image(renderer,0,0);
canvas.popMatrix();
canvas.endDraw();
row = 0;
column = 0;
renderer.beginDraw();
renderer.colorMode(RGB);
colorMode(RGB);
while (column < renderer.width-1) {
renderer.loadPixels();
canvas.beginDraw();
while (column < canvas.width-1) {
canvas.loadPixels();
sortColumn();
column++;
renderer.updatePixels();
canvas.updatePixels();
}

while (row < renderer.height-1) {
renderer.loadPixels();
while (row < canvas.height-1) {
canvas.loadPixels();
sortRow();
row++;
renderer.updatePixels();
canvas.updatePixels();
}

renderer.beginDraw();
renderer.imageMode(CENTER);
renderer.pushMatrix();
renderer.translate(renderer.width/2, renderer.height/2);
renderer.rotate(-(PI/2)*direction);
renderer.image(canvas, 0,0);
renderer.popMatrix();
renderer.imageMode(CORNER);
renderer.endDraw();
}

@@ -47,7 +74,7 @@ class ASDFPIXELSORT extends Shader {
int x = 0;
int y = row;
int xend = 0;
while (xend < renderer.width-1) {
while (xend < canvas.width-1) {
switch((int)params.get(1).value) {
case 0:
x = getFirstNotBlackX(x, y);
@@ -73,13 +100,13 @@ class ASDFPIXELSORT extends Shader {
color[] sorted = new color[sortLength];

for (int i=0; i<sortLength; i++) {
unsorted[i] = renderer.pixels[x + i + y * renderer.width];
unsorted[i] = canvas.pixels[x + i + y * canvas.width];
}

sorted = sort(unsorted);

for (int i=0; i<sortLength; i++) {
renderer.pixels[x + i + y * renderer.width] = sorted[i];
canvas.pixels[x + i + y * canvas.width] = sorted[i];
}

x = xend+1;
@@ -92,7 +119,7 @@ class ASDFPIXELSORT extends Shader {
int y = 0;
int yend = 0;

while (yend < renderer.height-1) {
while (yend < canvas.height-1) {
switch((int)params.get(1).value) {
case 0:
y = getFirstNotBlackY(x, y);
@@ -116,14 +143,14 @@ class ASDFPIXELSORT extends Shader {
color[] unsorted = new color[sortLength];
color[] sorted = new color[sortLength];
for (int i=0; i<sortLength; i++) {
unsorted[i] = renderer.pixels[x + (y+i) * renderer.width];
unsorted[i] = canvas.pixels[x + (y+i) * canvas.width];
}

sorted = sort(unsorted);


for (int i=0; i<sortLength; i++) {
renderer.pixels[x + (y+i) * renderer.width] = sorted[i];
canvas.pixels[x + (y+i) * canvas.width] = sorted[i];
}

y = yend+1;
@@ -136,9 +163,9 @@ class ASDFPIXELSORT extends Shader {
int x = _x;
int y = _y;
color c;
while ( (c = renderer.pixels[x + y * renderer.width]) < params.get(0).value) {
while ( (c = canvas.pixels[x + y * canvas.width]) < params.get(0).value) {
x++;
if (x >= renderer.width) return -1;
if (x >= canvas.width) return -1;
}
return x;
}
@@ -147,9 +174,9 @@ class ASDFPIXELSORT extends Shader {
int x = _x+1;
int y = _y;
color c;
while ( (c = renderer.pixels[x + y * renderer.width]) > params.get(0).value) {
while ( (c = canvas.pixels[x + y * canvas.width]) > params.get(0).value) {
x++;
if (x >= renderer.width) return renderer.width-1;
if (x >= canvas.width) return canvas.width-1;
}
return x-1;
}
@@ -159,9 +186,9 @@ class ASDFPIXELSORT extends Shader {
int x = _x;
int y = _y;
color c;
while (brightness (c = renderer.pixels[x + y * renderer.width]) < params.get(0).value) {
while (brightness (c = canvas.pixels[x + y * canvas.width]) < params.get(0).value) {
x++;
if (x >= renderer.width) return -1;
if (x >= canvas.width) return -1;
}
return x;
}
@@ -170,9 +197,9 @@ class ASDFPIXELSORT extends Shader {
int x = _x+1;
int y = _y;
color c;
while (brightness (c = renderer.pixels[x + y * renderer.width]) > params.get(0).value) {
while (brightness (c = canvas.pixels[x + y * canvas.width]) > params.get(0).value) {
x++;
if (x >= renderer.width) return renderer.width-1;
if (x >= canvas.width) return canvas.width-1;
}
return x-1;
}
@@ -182,9 +209,9 @@ class ASDFPIXELSORT extends Shader {
int x = _x;
int y = _y;
color c;
while ( (c = renderer.pixels[x + y * renderer.width]) > params.get(0).value) {
while ( (c = canvas.pixels[x + y * canvas.width]) > params.get(0).value) {
x++;
if (x >= renderer.width) return -1;
if (x >= canvas.width) return -1;
}
return x;
}
@@ -193,9 +220,9 @@ class ASDFPIXELSORT extends Shader {
int x = _x+1;
int y = _y;
color c;
while ( (c = renderer.pixels[x + y * renderer.width]) < params.get(0).value) {
while ( (c = canvas.pixels[x + y * canvas.width]) < params.get(0).value) {
x++;
if (x >= renderer.width) return renderer.width-1;
if (x >= canvas.width) return canvas.width-1;
}
return x-1;
}
@@ -206,10 +233,10 @@ class ASDFPIXELSORT extends Shader {
int x = _x;
int y = _y;
color c;
if (y < renderer.height) {
while ( (c = renderer.pixels[x + y * renderer.width]) < params.get(0).value) {
if (y < canvas.height) {
while ( (c = canvas.pixels[x + y * canvas.width]) < params.get(0).value) {
y++;
if (y >= renderer.height) return -1;
if (y >= canvas.height) return -1;
}
}
return y;
@@ -219,10 +246,10 @@ class ASDFPIXELSORT extends Shader {
int x = _x;
int y = _y+1;
color c;
if (y < renderer.height) {
while ( (c = renderer.pixels[x + y * renderer.width]) > params.get(0).value) {
if (y < canvas.height) {
while ( (c = canvas.pixels[x + y * canvas.width]) > params.get(0).value) {
y++;
if (y >= renderer.height) return renderer.height-1;
if (y >= canvas.height) return canvas.height-1;
}
}
return y-1;
@@ -233,10 +260,10 @@ class ASDFPIXELSORT extends Shader {
int x = _x;
int y = _y;
color c;
if (y < renderer.height) {
while (brightness (c = renderer.pixels[x + y * renderer.width]) < params.get(0).value) {
if (y < canvas.height) {
while (brightness (c = canvas.pixels[x + y * canvas.width]) < params.get(0).value) {
y++;
if (y >= renderer.height) return -1;
if (y >= canvas.height) return -1;
}
}
return y;
@@ -246,10 +273,10 @@ class ASDFPIXELSORT extends Shader {
int x = _x;
int y = _y+1;
color c;
if (y < renderer.height) {
while (brightness (c = renderer.pixels[x + y * renderer.width]) > params.get(0).value) {
if (y < canvas.height) {
while (brightness (c = canvas.pixels[x + y * canvas.width]) > params.get(0).value) {
y++;
if (y >= renderer.height) return renderer.height-1;
if (y >= canvas.height) return canvas.height-1;
}
}
return y-1;
@@ -260,10 +287,10 @@ class ASDFPIXELSORT extends Shader {
int x = _x;
int y = _y;
color c;
if (y < renderer.height) {
while ( (c = renderer.pixels[x + y * renderer.width]) > params.get(0).value) {
if (y < canvas.height) {
while ( (c = canvas.pixels[x + y * canvas.width]) > params.get(0).value) {
y++;
if (y >= renderer.height) return -1;
if (y >= canvas.height) return -1;
}
}
return y;
@@ -273,10 +300,10 @@ class ASDFPIXELSORT extends Shader {
int x = _x;
int y = _y+1;
color c;
if (y < renderer.height) {
while ( (c = renderer.pixels[x + y * renderer.width]) < params.get(0).value) {
if (y < canvas.height) {
while ( (c = canvas.pixels[x + y * canvas.width]) < params.get(0).value) {
y++;
if (y >= renderer.height) return renderer.height-1;
if (y >= canvas.height) return canvas.height-1;
}
}
return y-1;

Loading…
Cancel
Save