added fxSlitScan without gui controls yet
This commit is contained in:
302
effects.pde
302
effects.pde
@@ -302,7 +302,7 @@ class DISTORTER extends Shader {
|
||||
PImage buffer;
|
||||
|
||||
final static int distortionMatrixSize = 512; //doesnt really make a difference, it's more or less "noise variety".. only kinda different if real low, like 2 or so
|
||||
|
||||
|
||||
int[][] distort = new int[2][distortionMatrixSize];
|
||||
final static float tick = 1.0/distortionMatrixSize;
|
||||
|
||||
@@ -314,7 +314,7 @@ class DISTORTER extends Shader {
|
||||
buffer = createImage(renderer.width, renderer.height, ARGB);
|
||||
initBufferW = buffer.width;
|
||||
initBufferH = buffer.height;
|
||||
|
||||
|
||||
name = "fxDistorter";
|
||||
params.add(new Param("width", FLOATVAL, 2, buffer.width/4-1, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANG}));
|
||||
params.add(new Param("height", FLOATVAL, 2, buffer.height/4-1, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANG}));
|
||||
@@ -331,16 +331,15 @@ class DISTORTER extends Shader {
|
||||
|
||||
|
||||
// prepare distortion pattern
|
||||
|
||||
|
||||
for (int i=0; i<distortionMatrixSize; i++) {
|
||||
distort[0][i] = (int)random(-128, 128);
|
||||
distort[1][i] = (int)random(-128, 128);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// ALL Channels, Nxxx stand for negative (255-value)
|
||||
// channels to work with
|
||||
final static int RED = 0;
|
||||
@@ -362,11 +361,11 @@ class DISTORTER extends Shader {
|
||||
buffer = renderer.get();
|
||||
buffer.resize(renderer.width, renderer.height);
|
||||
|
||||
float neww = map(params.get(0).value, 2,initBufferW-2, 2, buffer.width/4-2);
|
||||
float newh = map(params.get(1).value, 2,initBufferH-2, 2, buffer.height/4-2);
|
||||
|
||||
|
||||
|
||||
float neww = map(params.get(0).value, 2, initBufferW-2, 2, buffer.width/4-2);
|
||||
float newh = map(params.get(1).value, 2, initBufferH-2, 2, buffer.height/4-2);
|
||||
|
||||
|
||||
|
||||
do_blend = boolean(int(params.get(2).value));
|
||||
shift_amt = params.get(3).value;
|
||||
scalex = params.get(4).value;
|
||||
@@ -413,8 +412,8 @@ class DISTORTER extends Shader {
|
||||
colorMode(RGB, 255);
|
||||
}
|
||||
// buffer.fill(lerpColor(c,img.get(x,y),0.2));
|
||||
renderer.fill(c); //wärs nich effizienter die pixelmatrix zu ändern ?
|
||||
renderer.rect(x, y, 1, 1);
|
||||
renderer.fill(c); //wärs nich effizienter die pixelmatrix zu ändern ?
|
||||
renderer.rect(x, y, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -457,9 +456,9 @@ class DISTORTER extends Shader {
|
||||
|
||||
/*
|
||||
|
||||
FM
|
||||
|
||||
*/
|
||||
FM
|
||||
|
||||
*/
|
||||
|
||||
|
||||
class FM extends Shader {
|
||||
@@ -468,9 +467,9 @@ class FM extends Shader {
|
||||
int quantval = 30; // 0 - off, less - more glitch, more - more precision
|
||||
boolean do_blend = true; // blend image after process
|
||||
int blend_mode = OVERLAY; // blend type
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//unused parameters (giers):
|
||||
final static boolean first_channel_only = false; // for L.. or Y.. colorspaces set true to modulate only luma;
|
||||
final static boolean lowpass1_on = true; // on/off of first low pass filter
|
||||
@@ -484,7 +483,7 @@ class FM extends Shader {
|
||||
|
||||
|
||||
// working buffer
|
||||
|
||||
|
||||
PGraphics buffer;
|
||||
|
||||
// local variables
|
||||
@@ -500,9 +499,9 @@ class FM extends Shader {
|
||||
params.add(new Param("do blend", INTVAL, 0, 1, new int[]{RANDOM, SQUAR}));
|
||||
params.add(new Param ("blend_mode", INTVAL, 0, blends.length-1, new int[]{RANDOM}));
|
||||
params.add(new Param ("omega", FLOATVAL, 0, 1, new int[]{SINE, SAWTOOTH, TRIANG}));
|
||||
params.add(new Param ("phase", FLOATVAL, 0, 1, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE}));
|
||||
params.add(new Param ("phase", FLOATVAL, 0, 1, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE}));
|
||||
params.add(new Param ("colorspace", INTVAL, 0, 16, new int[]{RANDOM}));
|
||||
params.add(new Param ("quant", INTVAL, 0, 40, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE}));
|
||||
params.add(new Param ("quant", INTVAL, 0, 40, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE}));
|
||||
|
||||
buffer = createGraphics(renderer.width, renderer.height);
|
||||
buffer.beginDraw();
|
||||
@@ -547,16 +546,16 @@ class FM extends Shader {
|
||||
float phase = map(sq(params.get(3).value), 0, 1, min_phase_mult, max_phase_mult);
|
||||
colorspace = (int)params.get(4).value;
|
||||
quantval = (int) params.get(5).value;
|
||||
|
||||
|
||||
|
||||
|
||||
if (rw != renderer.width || rh != renderer.height) {
|
||||
rw = renderer.width;
|
||||
rh = renderer.height;
|
||||
min_omega = TWO_PI/(0.05*renderer.width);
|
||||
max_omega = TWO_PI/(300.0*renderer.width);
|
||||
}
|
||||
prepareData();
|
||||
|
||||
prepareData();
|
||||
|
||||
buffer.setSize(renderer.width, renderer.height);
|
||||
//buffer = renderer.get(0, 0, renderer.width, renderer.height);
|
||||
|
||||
@@ -681,9 +680,9 @@ class FM extends Shader {
|
||||
|
||||
/*
|
||||
|
||||
WZIP
|
||||
|
||||
*/
|
||||
WZIP
|
||||
|
||||
*/
|
||||
|
||||
|
||||
class WZIP extends Shader {
|
||||
@@ -705,9 +704,9 @@ class WZIP extends Shader {
|
||||
WZIP() {
|
||||
|
||||
name = "fxWZIP";
|
||||
params.add(new Param ("scale", FLOATVAL, 0.1, 1000, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE}));
|
||||
params.add(new Param ("factor in", FLOATVAL, 0.01, 1, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE}));
|
||||
params.add(new Param ("factor out", FLOATVAL, 0.01, 1, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE}));
|
||||
params.add(new Param ("scale", FLOATVAL, 0.1, 1000, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE}));
|
||||
params.add(new Param ("factor in", FLOATVAL, 0.01, 1, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE}));
|
||||
params.add(new Param ("factor out", FLOATVAL, 0.01, 1, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE}));
|
||||
params.add(new Param("hsb/rgb", INTVAL, 0, 1, new int[]{RANDOM, SQUAR}));
|
||||
params.add(new Param("mode", INTVAL, 0, 1, new int[]{RANDOM, SQUAR}));
|
||||
|
||||
@@ -728,12 +727,12 @@ class WZIP extends Shader {
|
||||
raw2 = new float[s];
|
||||
raw3 = new float[s];
|
||||
renderer.beginDraw();
|
||||
|
||||
|
||||
|
||||
|
||||
renderer.background(0);
|
||||
renderer.noStroke();
|
||||
|
||||
|
||||
|
||||
|
||||
if (boolean((int)params.get(3).value)) { /////////////////////
|
||||
renderer.colorMode(HSB, 255);
|
||||
colorMode(HSB, 255);
|
||||
@@ -744,9 +743,9 @@ class WZIP extends Shader {
|
||||
|
||||
scalingfactorin = map(params.get(1).value, 0, 1, 0, params.get(0).value); /////////////////////
|
||||
scalingfactorout = map(params.get(2).value, 0, 1, 0, params.get(0).value); /////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int iter=0;
|
||||
int iter2 = 0;
|
||||
for (int y=0; y<img.height; y++) {
|
||||
@@ -797,21 +796,21 @@ class WZIP extends Shader {
|
||||
in2[i] = raw2[s-1];
|
||||
in3[i] = raw3[s-1];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (boolean((int)params.get(4).value)) option1(); /////////////////////
|
||||
else option2();
|
||||
|
||||
|
||||
|
||||
|
||||
renderer.colorMode(RGB);
|
||||
colorMode(RGB);
|
||||
|
||||
|
||||
|
||||
|
||||
renderer.endDraw();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// void printOption() {
|
||||
// String str1, str2;
|
||||
// if (do_hsb) {
|
||||
@@ -938,9 +937,9 @@ class WZIP extends Shader {
|
||||
|
||||
/*
|
||||
|
||||
AUECHO
|
||||
|
||||
*/
|
||||
AUECHO
|
||||
|
||||
*/
|
||||
|
||||
|
||||
class AUECHO extends Shader {
|
||||
@@ -948,9 +947,9 @@ class AUECHO extends Shader {
|
||||
AUECHO() {
|
||||
name = "fxAUecho";
|
||||
params.add(new Param("mode", INTVAL, 0, 1, new int[]{RANDOM, SQUAR}));
|
||||
params.add(new Param ("echo", FLOATVAL, 0.001, 1, new int[]{TRIANG, SINE, RAMPUPDOWN, }));
|
||||
params.add(new Param ("decay", FLOATVAL, 0.001, 1, new int[]{TRIANG, SINE, RAMPUPDOWN }));
|
||||
params.add(new Param ("blend mode", INTVAL, 0, this.blends.length-1, new int[]{RANDOM }));
|
||||
params.add(new Param ("echo", FLOATVAL, 0.001, 1, new int[]{TRIANG, SINE, RAMPUPDOWN, }));
|
||||
params.add(new Param ("decay", FLOATVAL, 0.001, 1, new int[]{TRIANG, SINE, RAMPUPDOWN }));
|
||||
params.add(new Param ("blend mode", INTVAL, 0, this.blends.length-1, new int[]{RANDOM }));
|
||||
}
|
||||
void apply() {
|
||||
renderer.beginDraw();
|
||||
@@ -962,10 +961,10 @@ class AUECHO extends Shader {
|
||||
colorMode(RGB);
|
||||
}
|
||||
renderer.loadPixels();
|
||||
|
||||
|
||||
float _delay = params.get(1).value;
|
||||
float decay = params.get(2).value;
|
||||
|
||||
|
||||
int delay = (int)(renderer.pixels.length * _delay);
|
||||
color[] history = new color[renderer.pixels.length];
|
||||
int blendMode =this.blends[(int)params.get(3).value];
|
||||
@@ -985,8 +984,7 @@ class AUECHO extends Shader {
|
||||
b = b + blue(origColor) > 255 ? b + blue(origColor) - 255 : b + blue(origColor) );
|
||||
|
||||
//renderer.pixels[i] = history[i] = toColor;
|
||||
renderer.pixels[i] = history[i] = blendColor(origColor, toColor, blendMode);
|
||||
|
||||
renderer.pixels[i] = history[i] = blendColor(origColor, toColor, blendMode);
|
||||
}
|
||||
renderer.updatePixels();
|
||||
if (boolean((int)params.get(0).value)) {
|
||||
@@ -1000,9 +998,9 @@ class AUECHO extends Shader {
|
||||
|
||||
/*
|
||||
|
||||
SLITSCAN
|
||||
|
||||
*/
|
||||
SLITSCAN
|
||||
|
||||
*/
|
||||
|
||||
|
||||
class SLITSCAN extends Shader {
|
||||
@@ -1027,51 +1025,6 @@ class SLITSCAN extends Shader {
|
||||
ft[1][i] = 0.5*1.0/ft[0][i];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
void animate() {
|
||||
|
||||
buffer.resize(renderer.width, renderer.height);
|
||||
buffer = renderer.get(0, 0, renderer.width, renderer.height);
|
||||
int s = buffer.width>buffer.height?buffer.height:buffer.width;
|
||||
depth = (int)(log(s)/log(2));
|
||||
fxnum = (int)random(depth);
|
||||
fynum = (int)random(depth);
|
||||
|
||||
|
||||
fx = new int[fxnum+1];
|
||||
fy = new int[fynum+1];
|
||||
sx = new int[fxnum+1];
|
||||
sy = new int[fynum+1];
|
||||
|
||||
phx = new float[fxnum+1];
|
||||
phy = new float[fynum+1];
|
||||
|
||||
skipfx = new boolean[fxnum+1];
|
||||
skipfy = new boolean[fynum+1];
|
||||
|
||||
|
||||
for (int i=0; i<fxnum; i++) {
|
||||
//fx[i]=(int)random(6);
|
||||
fx[i]=(int)random(6);
|
||||
phx[i] = random(1);
|
||||
skipfx[i] = random(1)<0.2;
|
||||
sx[i] = random(1)<0.2?-1:1;
|
||||
}
|
||||
for (int i=0; i<fynum; i++) {
|
||||
fy[i]=(int)random(6);
|
||||
//fy[i]=6;
|
||||
phy[i] = random(1);
|
||||
skipfy[i] = random(1)<0.2;
|
||||
sy[i] = random(1)<0.2?-1:1;
|
||||
}
|
||||
dox = random(1)<0.8;
|
||||
doy = dox?random(1)<0.8:true;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
void apply() {
|
||||
renderer.beginDraw();
|
||||
@@ -1079,45 +1032,46 @@ class SLITSCAN extends Shader {
|
||||
renderer.noStroke();
|
||||
colorMode(RGB);
|
||||
renderer.fill(255);
|
||||
buffer.resize(renderer.width, renderer.height);
|
||||
buffer = renderer.get(0, 0, renderer.width, renderer.height);
|
||||
|
||||
//int s = buffer.width>buffer.height?buffer.height:buffer.width;
|
||||
int s = min(buffer.width,buffer.height);
|
||||
|
||||
// buffer = createImage(renderW, renderH, ARGB);
|
||||
buffer.resize(renderer.width, renderer.height);
|
||||
buffer = renderer.get(0, 0, renderer.width, renderer.height);
|
||||
// int s = buffer.width>buffer.height?buffer.height:buffer.width;
|
||||
// depth = (int)(log(s)/log(2));
|
||||
// fxnum = (int)map(knobZero, 0, 255, 0, depth);
|
||||
// fynum = (int)map(knobOne, 0, 255, 0, depth);
|
||||
// fx = new int[fxnum+1];
|
||||
// fy = new int[fynum+1];
|
||||
// sx = new int[fxnum+1];
|
||||
// sy = new int[fynum+1];
|
||||
//
|
||||
// phx = new float[fxnum+1];
|
||||
// phy = new float[fynum+1];
|
||||
//
|
||||
// skipfx = new boolean[fxnum+1];
|
||||
// skipfy = new boolean[fynum+1];
|
||||
//
|
||||
//
|
||||
// for (int i=0; i<fxnum; i++) {
|
||||
// fx[i]=(int)random(6);
|
||||
// phx[i] = random(1);
|
||||
// skipfx[i] = random(1)<0.2;
|
||||
// sx[i] = random(1)<0.2?-1:1;
|
||||
// }
|
||||
// for (int i=0; i<fynum; i++) {
|
||||
// fy[i]=(int)random(6);
|
||||
// phy[i] = random(1);
|
||||
// skipfy[i] = random(1)<0.2;
|
||||
// sy[i] = random(1)<0.2?-1:1;
|
||||
// }
|
||||
// dox = random(1)<0.8;
|
||||
// doy = dox?random(1)<0.8:true;
|
||||
// } else {
|
||||
// println("ratatata");
|
||||
// buffer = createImage(renderW, renderH, ARGB);
|
||||
// buffer = renderer.get(0, 0, renderer.width, renderer.height);
|
||||
depth = (int)(log(s)/log(2));
|
||||
|
||||
fxnum = (int)random(depth); ////
|
||||
fynum = (int)random(depth); ////
|
||||
|
||||
fx = new int[fxnum+1];
|
||||
fy = new int[fynum+1];
|
||||
sx = new int[fxnum+1];
|
||||
sy = new int[fynum+1];
|
||||
phx = new float[fxnum+1];
|
||||
phy = new float[fynum+1];
|
||||
skipfx = new boolean[fxnum+1];
|
||||
skipfy = new boolean[fynum+1];
|
||||
for (int i=0; i<fxnum; i++) {
|
||||
|
||||
fx[i]=(int)random(6);
|
||||
phx[i] = random(1);
|
||||
skipfx[i] = random(1)<0.2;
|
||||
sx[i] = random(1)<0.2?-1:1;
|
||||
|
||||
}
|
||||
for (int i=0; i<fynum; i++) {
|
||||
|
||||
fy[i]=(int)random(6);
|
||||
phy[i] = random(1);
|
||||
skipfy[i] = random(1)<0.2;
|
||||
sy[i] = random(1)<0.2?-1:1;
|
||||
|
||||
}
|
||||
|
||||
dox = random(1)<0.8;
|
||||
doy = dox?random(1)<0.8:true;
|
||||
|
||||
|
||||
|
||||
float v=0;
|
||||
for (int y=0; y<buffer.height; y++)
|
||||
@@ -1418,23 +1372,23 @@ color toYUV(color c) {
|
||||
int R = getR(c);
|
||||
int G = getG(c);
|
||||
int B = getB(c);
|
||||
|
||||
|
||||
int Y = (int)( 0.299*R+0.587*G+0.114*B);
|
||||
int U = (int)map(-0.14713*R-0.28886*G+0.436*B,-Umax,Umax,0,255);
|
||||
int V = (int)map(0.615*R-0.51499*G-0.10001*B,-Vmax,Vmax,0,255);
|
||||
int U = (int)map(-0.14713*R-0.28886*G+0.436*B, -Umax, Umax, 0, 255);
|
||||
int V = (int)map(0.615*R-0.51499*G-0.10001*B, -Vmax, Vmax, 0, 255);
|
||||
|
||||
return blendRGB(c, Y, U, V);
|
||||
}
|
||||
|
||||
color fromYUV(color c) {
|
||||
int Y = getR(c);
|
||||
float U = map(getG(c),0,255,-Umax,Umax);
|
||||
float V = map(getB(c),0,255,-Vmax,Vmax);
|
||||
|
||||
float U = map(getG(c), 0, 255, -Umax, Umax);
|
||||
float V = map(getB(c), 0, 255, -Vmax, Vmax);
|
||||
|
||||
int R = (int)(Y + 1.13983*V);
|
||||
int G = (int)(Y - 0.39465*U - 0.58060*V);
|
||||
int B = (int)(Y + 2.03211*U);
|
||||
|
||||
|
||||
return blendRGB(c, R, G, B);
|
||||
}
|
||||
|
||||
@@ -1446,7 +1400,7 @@ color toYDbDr(color c) {
|
||||
int R = getR(c);
|
||||
int G = getG(c);
|
||||
int B = getB(c);
|
||||
|
||||
|
||||
int Y = (int)( 0.299*R+0.587*G+0.114*B);
|
||||
int Db = (int)(127.5+(-0.450*R-0.883*G+1.333*B)/2.666);
|
||||
int Dr = (int)(127.5+(-1.333*R+1.116*G+0.217*B)/2.666);
|
||||
@@ -1458,11 +1412,11 @@ color fromYDbDr(color c) {
|
||||
int Y = getR(c);
|
||||
float Db = (getG(c)-127.5)*2.666;
|
||||
float Dr = (getB(c)-127.5)*2.666;
|
||||
|
||||
|
||||
int R = (int)(Y + 9.2303716147657e-05*Db-0.52591263066186533*Dr);
|
||||
int G = (int)(Y - 0.12913289889050927*Db+0.26789932820759876*Dr);
|
||||
int B = (int)(Y + 0.66467905997895482*Db-7.9202543533108e-05*Dr);
|
||||
|
||||
|
||||
return blendRGB(c, R, G, B);
|
||||
}
|
||||
|
||||
@@ -1474,7 +1428,7 @@ color toYCbCr(color c) {
|
||||
int R = getR(c);
|
||||
int G = getG(c);
|
||||
int B = getB(c);
|
||||
|
||||
|
||||
int Y = (int)( 0.2988390*R+0.5868110*G+0.1143500*B);
|
||||
int Cb = (int)(-0.168736*R-0.3312640*G+0.5000000*B+127.5);
|
||||
int Cr = (int)( 0.5000000*R-0.4186880*G-0.0813120*B+127.5);
|
||||
@@ -1486,11 +1440,11 @@ color fromYCbCr(color c) {
|
||||
int Y = getR(c);
|
||||
float Cb = getG(c) - 127.5;
|
||||
float Cr = getB(c) - 127.5;
|
||||
|
||||
|
||||
int R = (int)(Y + 1.402*Cr)+1; // some fix
|
||||
int G = (int)(Y-0.344136*Cb-0.714136*Cr);
|
||||
int B = (int)(Y+1.772000*Cb)+1; // some fix
|
||||
|
||||
|
||||
return blendRGB(c, R, G, B);
|
||||
}
|
||||
|
||||
@@ -1501,12 +1455,12 @@ color fromYCbCr(color c) {
|
||||
color toYPbPr(color c) {
|
||||
int R = getR(c);
|
||||
int B = getB(c);
|
||||
|
||||
|
||||
int Y = getLuma(c);
|
||||
int Pb = B - Y;
|
||||
int Pr = R - Y;
|
||||
if(Pb<0) Pb+=256;
|
||||
if(Pr<0) Pr+=256;
|
||||
if (Pb<0) Pb+=256;
|
||||
if (Pr<0) Pr+=256;
|
||||
return blendRGB(c, Y, Pb, Pr);
|
||||
}
|
||||
|
||||
@@ -1514,11 +1468,11 @@ color fromYPbPr(color c) {
|
||||
int Y = getR(c);
|
||||
int B = getG(c) + Y;
|
||||
int R = getB(c) + Y;
|
||||
if(R>255) R-=256;
|
||||
if(B>255) B-=256;
|
||||
|
||||
if (R>255) R-=256;
|
||||
if (B>255) B-=256;
|
||||
|
||||
int G = (int)((Y-0.2126*R-0.0722*B)/0.7152);
|
||||
|
||||
|
||||
return blendRGB(c, R, G, B);
|
||||
}
|
||||
|
||||
@@ -1531,8 +1485,8 @@ color toRGGBG(color c) {
|
||||
int G = getG(c);
|
||||
int R = getR(c)-G;
|
||||
int B = getB(c)-G;
|
||||
if(R<0) R+=256;
|
||||
if(B<0) B+=256;
|
||||
if (R<0) R+=256;
|
||||
if (B<0) B+=256;
|
||||
return blendRGB(c, R, G, B);
|
||||
}
|
||||
|
||||
@@ -1540,8 +1494,8 @@ color fromRGGBG(color c) {
|
||||
int G = getG(c);
|
||||
int R = getR(c)+G;
|
||||
int B = getB(c)+G;
|
||||
if(R>255) R-=256;
|
||||
if(B>255) B-=256;
|
||||
if (R>255) R-=256;
|
||||
if (B>255) B-=256;
|
||||
return blendRGB(c, R, G, B);
|
||||
}
|
||||
|
||||
@@ -1882,9 +1836,9 @@ color toYXY(color c) {
|
||||
float x = xyz.x > 0 ? xyz.x / sum : 0.0;
|
||||
float y = xyz.y > 0 ? xyz.y / sum : 0.0;
|
||||
return blendRGB(c,
|
||||
(int)map(xyz.y, 0, RANGE_Y, 0, 255),
|
||||
(int)map(x, 0.0, 1.0, 0, 255),
|
||||
(int)map(y, 0.0, 1.0, 0, 255));
|
||||
(int)map(xyz.y, 0, RANGE_Y, 0, 255),
|
||||
(int)map(x, 0.0, 1.0, 0, 255),
|
||||
(int)map(y, 0.0, 1.0, 0, 255));
|
||||
}
|
||||
|
||||
color fromYXY(color c) {
|
||||
@@ -1910,16 +1864,16 @@ PVector _toXYZ(float rr, float gg, float bb) {
|
||||
float g = correctionxyz(gg);
|
||||
float b = correctionxyz(bb);
|
||||
return new PVector(r * 0.4124 + g * 0.3576 + b * 0.1805,
|
||||
r * 0.2126 + g * 0.7152 + b * 0.0722,
|
||||
r * 0.0193 + g * 0.1192 + b * 0.9505);
|
||||
r * 0.2126 + g * 0.7152 + b * 0.0722,
|
||||
r * 0.0193 + g * 0.1192 + b * 0.9505);
|
||||
}
|
||||
|
||||
color toXYZ(color c) {
|
||||
PVector xyz = _toXYZ(getNR(c), getNG(c), getNB(c));
|
||||
return blendRGB(c,
|
||||
(int)map(xyz.x, 0, RANGE_X, 0, 255),
|
||||
(int)map(xyz.y, 0, RANGE_Y, 0, 255),
|
||||
(int)map(xyz.z, 0, RANGE_Z, 0, 255));
|
||||
(int)map(xyz.x, 0, RANGE_X, 0, 255),
|
||||
(int)map(xyz.y, 0, RANGE_Y, 0, 255),
|
||||
(int)map(xyz.z, 0, RANGE_Z, 0, 255));
|
||||
}
|
||||
|
||||
float recorrectionxyz(float n) {
|
||||
|
||||
Reference in New Issue
Block a user