|
|
@@ -539,7 +539,7 @@ class FM extends Shader { |
|
|
|
|
|
|
|
|
|
|
|
int rw, rh; |
|
|
|
void apply() { |
|
|
|
void apply() { |
|
|
|
do_blend = boolean(int(params.get(0).value)); |
|
|
|
blend_mode = blends[(int)params.get(1).value]; |
|
|
|
omega = map(sqrt(params.get(2).value), 0, 1, min_omega, max_omega); |
|
|
@@ -581,7 +581,7 @@ class FM extends Shader { |
|
|
|
for (int y=0; y<renderer.height; y++) { |
|
|
|
int off = y * renderer.width; |
|
|
|
|
|
|
|
//reset filters each line |
|
|
|
//reset filters each line |
|
|
|
lpf1.resetFilter(map(pxls[i][off], 0, 255, min_phase, max_phase)); |
|
|
|
lpf2.resetFilter(map(pxls[i][off], 0, 255, min_phase, max_phase)); |
|
|
|
lpf3.resetFilter(map(pxls[i][off], 0, 255, min_phase, max_phase)); |
|
|
@@ -600,7 +600,7 @@ class FM extends Shader { |
|
|
|
|
|
|
|
float m = cos(omega * x + sig_int); // modulate signal |
|
|
|
|
|
|
|
if ( quantval > 0) { |
|
|
|
if ( quantval > 0) { |
|
|
|
m = map((int)map(m, -1, 1, 0, quantval), 0, quantval, -1, 1); // quantize |
|
|
|
} |
|
|
|
|
|
|
@@ -656,11 +656,11 @@ class FM extends Shader { |
|
|
|
alpha = timeInterval / (tau + timeInterval); |
|
|
|
} |
|
|
|
|
|
|
|
void resetFilter(float val) { |
|
|
|
void resetFilter(float val) { |
|
|
|
prev = val; |
|
|
|
} |
|
|
|
|
|
|
|
void resetFilter() { |
|
|
|
void resetFilter() { |
|
|
|
resetFilter(0); |
|
|
|
} |
|
|
|
|
|
|
@@ -980,10 +980,10 @@ class AUECHO extends Shader { |
|
|
|
color origColor = history[i]; |
|
|
|
color toColor = color( |
|
|
|
r = r + red(origColor) > 255 ? r + red(origColor) - 255 : r + red(origColor), // simulate overflow ;) |
|
|
|
g = g + green(origColor) > 255 ? g + green(origColor) - 255 : g + green(origColor), |
|
|
|
g = g + green(origColor) > 255 ? g + green(origColor) - 255 : g + green(origColor), |
|
|
|
b = b + blue(origColor) > 255 ? b + blue(origColor) - 255 : b + blue(origColor) ); |
|
|
|
|
|
|
|
//renderer.pixels[i] = history[i] = toColor; |
|
|
|
//renderer.pixels[i] = history[i] = toColor; |
|
|
|
renderer.pixels[i] = history[i] = blendColor(origColor, toColor, blendMode); |
|
|
|
} |
|
|
|
renderer.updatePixels(); |
|
|
@@ -1043,7 +1043,7 @@ class SLITSCAN extends Shader { |
|
|
|
fxnum = (int)random(depth); //// |
|
|
|
fynum = (int)random(depth); //// |
|
|
|
|
|
|
|
fx = new int[fxnum+1]; |
|
|
|
fx = new int[fxnum+1]; |
|
|
|
fy = new int[fynum+1]; |
|
|
|
sx = new int[fxnum+1]; |
|
|
|
sy = new int[fynum+1]; |
|
|
@@ -1244,8 +1244,8 @@ class PHASER extends Shader { |
|
|
|
params.add(new Param ("phase", FLOATVAL, 0, TWO_PI, new int[]{TRIANG, SINE, RAMPUPDOWN })); |
|
|
|
params.add(new Param ("stages", INTVAL, 1, 24, new int[]{TRIANG, SINE, RAMPUPDOWN })); |
|
|
|
params.add(new Param ("sample rate", FLOATVAL, 512, 92230, new int[]{TRIANG, SINE, RAMPUPDOWN })); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//params.add(new Param ("frequency offset", FLOATVAL, 0, 1, new int[]{TRIANG, SINE, RAMPUPDOWN })); |
|
|
|
} |
|
|
|
/* |
|
|
@@ -1261,28 +1261,28 @@ class PHASER extends Shader { |
|
|
|
void apply() { |
|
|
|
mode = (int)params.get(0).value; |
|
|
|
float mFreq = params.get(1).value; |
|
|
|
|
|
|
|
|
|
|
|
int mDryWet = 255; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int mDepth = (int)params.get(2).value; |
|
|
|
int mFeedback = (int)params.get(3).value; |
|
|
|
float mPhase = params.get(4).value; |
|
|
|
|
|
|
|
|
|
|
|
//these two are only changed if mode = 1 |
|
|
|
int mStages = 2; |
|
|
|
float mSampleRate = samplerate; |
|
|
|
|
|
|
|
|
|
|
|
renderer.beginDraw(); |
|
|
|
renderer.colorMode(RGB); |
|
|
|
renderer.loadPixels(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//constants |
|
|
|
float phaserlfoshape = 4.0; |
|
|
|
int lfoskipsamples = 20; //how many samples are processed before recomputing lfo |
|
|
|
int numStages = 24; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//getParams |
|
|
|
/* |
|
|
@@ -1337,8 +1337,8 @@ class PHASER extends Shader { |
|
|
|
rgb[ci] = (float) (( m * mDryWet + in * (255-mDryWet)) / 255); |
|
|
|
} |
|
|
|
color rc = color( |
|
|
|
map(rgb[0], 0, 1, 0, 255), |
|
|
|
map(rgb[1], 0, 1, 0, 255), |
|
|
|
map(rgb[0], 0, 1, 0, 255), |
|
|
|
map(rgb[1], 0, 1, 0, 255), |
|
|
|
map(rgb[2], 0, 1, 0, 255)); |
|
|
|
renderer.pixels[i] = rc; |
|
|
|
} |
|
|
@@ -1350,12 +1350,12 @@ class PHASER extends Shader { |
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
ECHO |
|
|
|
|
|
|
|
*/ |
|
|
|
ECHO |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
class ECHO extends Shader{ |
|
|
|
class ECHO extends Shader { |
|
|
|
int mode = 0; |
|
|
|
PImage result; |
|
|
|
ECHO() { |
|
|
@@ -1367,7 +1367,7 @@ class ECHO extends Shader{ |
|
|
|
} |
|
|
|
void apply() { |
|
|
|
mode = (int)params.get(0).value; |
|
|
|
|
|
|
|
|
|
|
|
int xp = (int)params.get(1).value; |
|
|
|
int yp = (int)params.get(2).value; |
|
|
|
|
|
|
@@ -1381,8 +1381,8 @@ class ECHO extends Shader{ |
|
|
|
} |
|
|
|
renderer.endDraw(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PImage auEcho(PImage img, int xp, int yp) { |
|
|
|
result.resize(img.width, img.height); |
|
|
|
float _delay = map(xp, 0, 100, 0.001, 1.0); |
|
|
@@ -1403,9 +1403,9 @@ class ECHO extends Shader{ |
|
|
|
float b = blue(fromColor) * decay; |
|
|
|
color origColor = history[i]; |
|
|
|
color toColor = color( |
|
|
|
r + red(origColor), |
|
|
|
g + green(origColor), |
|
|
|
b + blue(origColor) ); |
|
|
|
r + red(origColor), |
|
|
|
g + green(origColor), |
|
|
|
b + blue(origColor) ); |
|
|
|
|
|
|
|
result.pixels[i] = history[i] = blendColor(origColor, toColor, blendMode); |
|
|
|
} |
|
|
@@ -1445,9 +1445,9 @@ class ECHO extends Shader{ |
|
|
|
history[histPos+ri] = rgb[ri] = rgb[ri] + history[histPos+ri] * decay; |
|
|
|
} |
|
|
|
color out = color( |
|
|
|
(int)map(rgb[0], 0, 1, 0, 255), |
|
|
|
(int)map(rgb[1], 0, 1, 0, 255), |
|
|
|
(int)map(rgb[2], 0, 1, 0, 255)); |
|
|
|
(int)map(rgb[0], 0, 1, 0, 255), |
|
|
|
(int)map(rgb[1], 0, 1, 0, 255), |
|
|
|
(int)map(rgb[2], 0, 1, 0, 255)); |
|
|
|
result.pixels[i] = out; |
|
|
|
} |
|
|
|
|
|
|
@@ -1455,6 +1455,78 @@ class ECHO extends Shader{ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
Darker |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
class DARKER extends Shader { |
|
|
|
float thresh = 127; |
|
|
|
float darken = 150; |
|
|
|
int mode = 1; |
|
|
|
int bangCount = 0; |
|
|
|
DARKER() { |
|
|
|
name = "fxDarker"; |
|
|
|
params.add(new Param("count", INTVAL, 1, 4, new int[]{TRIANG, SINE, RAMPUPDOWN, TAN, TANINVERSE})); |
|
|
|
params.add(new Param("threshold", INTVAL, 60, 180, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE})); |
|
|
|
params.add(new Param("frequency", INTVAL, 140, 220, new int[]{TRIANG, SINE, RAMPUPDOWN })); |
|
|
|
params.add(new Param("mode", INTVAL, 0, 1, new int[]{SQUAR, RANDOM})); |
|
|
|
|
|
|
|
|
|
|
|
//thresh = int(random(60, 180)); |
|
|
|
//darken = int(random(140, 220)); |
|
|
|
} |
|
|
|
|
|
|
|
void apply() { |
|
|
|
// bright = knobZero; |
|
|
|
int count = int(params.get(0).value); |
|
|
|
darken = int(params.get(1).value); |
|
|
|
thresh = int(params.get(2).value); |
|
|
|
mode = int(params.get(3).value); |
|
|
|
|
|
|
|
renderer.beginDraw(); |
|
|
|
renderer.colorMode(HSB); |
|
|
|
colorMode(HSB); |
|
|
|
renderer.loadPixels(); |
|
|
|
|
|
|
|
if (mode == 0) { |
|
|
|
for (int h = 1; h < count+1; h++) { |
|
|
|
for (int i = 0; i < renderer.width*renderer.height; i++) { |
|
|
|
float hue = hue(renderer.pixels[i]); |
|
|
|
float sat = saturation(renderer.pixels[i]); |
|
|
|
float bright = brightness(renderer.pixels[i]); |
|
|
|
|
|
|
|
if (bright > thresh/h) { |
|
|
|
bright -= darken/h; |
|
|
|
constrain(bright, 0, 255); |
|
|
|
} |
|
|
|
color c = color(hue, sat, bright); |
|
|
|
renderer.pixels[i] = c; |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (mode == 1) { |
|
|
|
for (int h = 1; h < count+1; h++) { |
|
|
|
for (int i = 0; i < renderer.width*renderer.height; i++) { |
|
|
|
float hue = hue(renderer.pixels[i]); |
|
|
|
float sat = saturation(renderer.pixels[i]); |
|
|
|
float bright = brightness(renderer.pixels[i]); |
|
|
|
|
|
|
|
if (bright < thresh/h) { |
|
|
|
bright -= darken/h; |
|
|
|
constrain(bright, 0, 255); |
|
|
|
} |
|
|
|
color c = color(hue, sat, bright); |
|
|
|
renderer.pixels[i] = c; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
renderer.updatePixels(); |
|
|
|
renderer.endDraw(); |
|
|
|
colorMode(RGB); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1488,22 +1560,22 @@ class ECHO extends Shader{ |
|
|
|
// name |
|
|
|
String getColorspaceName(int cs) { |
|
|
|
switch(cs) { |
|
|
|
case OHTA: |
|
|
|
case OHTA: |
|
|
|
return "OHTA"; |
|
|
|
case CMY: |
|
|
|
return "CMY"; |
|
|
|
case XYZ: |
|
|
|
case CMY: |
|
|
|
return "CMY"; |
|
|
|
case XYZ: |
|
|
|
return "XYZ"; |
|
|
|
case YXY: |
|
|
|
case YXY: |
|
|
|
return "YXY"; |
|
|
|
case HCL: |
|
|
|
case HCL: |
|
|
|
return "HCL"; |
|
|
|
case LUV: |
|
|
|
case LUV: |
|
|
|
return "LUV"; |
|
|
|
case LAB: |
|
|
|
case LAB: |
|
|
|
return "LAB"; |
|
|
|
case HWB: |
|
|
|
return "HWB"; |
|
|
|
case HWB: |
|
|
|
return "HWB"; |
|
|
|
case HSB: |
|
|
|
return "HSB"; |
|
|
|
case RGGBG: |
|
|
@@ -1518,7 +1590,7 @@ String getColorspaceName(int cs) { |
|
|
|
return "Greyscale"; |
|
|
|
case YUV: |
|
|
|
return "YUV"; |
|
|
|
default: |
|
|
|
default: |
|
|
|
return "RGB"; |
|
|
|
} |
|
|
|
} |
|
|
@@ -1526,21 +1598,21 @@ String getColorspaceName(int cs) { |
|
|
|
// colorspace converters |
|
|
|
color fromColorspace(color c, int cs) { |
|
|
|
switch(cs) { |
|
|
|
case OHTA: |
|
|
|
case OHTA: |
|
|
|
return fromOHTA(c); |
|
|
|
case CMY: |
|
|
|
return fromCMY(c); |
|
|
|
case XYZ: |
|
|
|
case CMY: |
|
|
|
return fromCMY(c); |
|
|
|
case XYZ: |
|
|
|
return fromXYZ(c); |
|
|
|
case YXY: |
|
|
|
case YXY: |
|
|
|
return fromYXY(c); |
|
|
|
case HCL: |
|
|
|
case HCL: |
|
|
|
return fromHCL(c); |
|
|
|
case LUV: |
|
|
|
case LUV: |
|
|
|
return fromLUV(c); |
|
|
|
case LAB: |
|
|
|
case LAB: |
|
|
|
return fromLAB(c); |
|
|
|
case HWB: |
|
|
|
case HWB: |
|
|
|
return fromHWB(c); |
|
|
|
case HSB: |
|
|
|
return fromHSB(c); |
|
|
@@ -1555,29 +1627,29 @@ color fromColorspace(color c, int cs) { |
|
|
|
case GS: |
|
|
|
return tofromGS(c); |
|
|
|
case YUV: |
|
|
|
return fromYUV(c); |
|
|
|
default: |
|
|
|
return fromYUV(c); |
|
|
|
default: |
|
|
|
return c; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
color toColorspace(color c, int cs) { |
|
|
|
switch(cs) { |
|
|
|
case OHTA: |
|
|
|
return toOHTA(c); |
|
|
|
case CMY: |
|
|
|
case OHTA: |
|
|
|
return toOHTA(c); |
|
|
|
case CMY: |
|
|
|
return toCMY(c); |
|
|
|
case XYZ: |
|
|
|
case XYZ: |
|
|
|
return toXYZ(c); |
|
|
|
case YXY: |
|
|
|
case YXY: |
|
|
|
return toYXY(c); |
|
|
|
case HCL: |
|
|
|
case HCL: |
|
|
|
return toHCL(c); |
|
|
|
case LUV: |
|
|
|
case LUV: |
|
|
|
return toLUV(c); |
|
|
|
case LAB: |
|
|
|
case LAB: |
|
|
|
return toLAB(c); |
|
|
|
case HWB: |
|
|
|
case HWB: |
|
|
|
return toHWB(c); |
|
|
|
case HSB: |
|
|
|
return toHSB(c); |
|
|
@@ -1592,52 +1664,52 @@ color toColorspace(color c, int cs) { |
|
|
|
case YUV: |
|
|
|
return toYUV(c); |
|
|
|
case GS: |
|
|
|
return tofromGS(c); |
|
|
|
default: |
|
|
|
return tofromGS(c); |
|
|
|
default: |
|
|
|
return c; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Colorspace converters |
|
|
|
|
|
|
|
final int getR(color c) { |
|
|
|
final int getR(color c) { |
|
|
|
return (c & 0xff0000) >> 16; |
|
|
|
} |
|
|
|
final int getG(color c) { |
|
|
|
final int getG(color c) { |
|
|
|
return (c & 0xff00) >> 8; |
|
|
|
} |
|
|
|
final int getB(color c) { |
|
|
|
final int getB(color c) { |
|
|
|
return c & 0xff; |
|
|
|
} |
|
|
|
|
|
|
|
final int getLuma(color c) { |
|
|
|
final int getLuma(color c) { |
|
|
|
return constrain((int)(0.2126*getR(c)+0.7152*getG(c)+0.0722*getB(c)), 0, 255); |
|
|
|
} |
|
|
|
|
|
|
|
int getChannel(color c, int ch) { |
|
|
|
switch(ch) { |
|
|
|
case 0 : |
|
|
|
case 0 : |
|
|
|
return getR(c); |
|
|
|
case 1 : |
|
|
|
case 1 : |
|
|
|
return getG(c); |
|
|
|
case 2 : |
|
|
|
case 2 : |
|
|
|
return getB(c); |
|
|
|
default: |
|
|
|
default: |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// normalized versions |
|
|
|
final float getNR(color c) { |
|
|
|
final float getNR(color c) { |
|
|
|
return r255[(c & 0xff0000) >> 16]; |
|
|
|
} |
|
|
|
final float getNG(color c) { |
|
|
|
final float getNG(color c) { |
|
|
|
return r255[(c & 0xff00) >> 8]; |
|
|
|
} |
|
|
|
final float getNB(color c) { |
|
|
|
final float getNB(color c) { |
|
|
|
return r255[c & 0xff]; |
|
|
|
} |
|
|
|
final float getNLuma(color c) { |
|
|
|
final float getNLuma(color c) { |
|
|
|
return r255[getLuma(c)]; |
|
|
|
} |
|
|
|
|
|
|
@@ -1667,7 +1739,7 @@ final static float Vmax = 0.615 * 255.0; |
|
|
|
|
|
|
|
color toYUV(color c) { |
|
|
|
int R = getR(c); |
|
|
|
int G = getG(c); |
|
|
|
int G = getG(c); |
|
|
|
int B = getB(c); |
|
|
|
|
|
|
|
int Y = (int)( 0.299*R+0.587*G+0.114*B); |
|
|
@@ -1678,7 +1750,7 @@ color toYUV(color c) { |
|
|
|
} |
|
|
|
|
|
|
|
color fromYUV(color c) { |
|
|
|
int Y = getR(c); |
|
|
|
int Y = getR(c); |
|
|
|
float U = map(getG(c), 0, 255, -Umax, Umax); |
|
|
|
float V = map(getB(c), 0, 255, -Vmax, Vmax); |
|
|
|
|
|
|
@@ -1695,7 +1767,7 @@ color fromYUV(color c) { |
|
|
|
|
|
|
|
color toYDbDr(color c) { |
|
|
|
int R = getR(c); |
|
|
|
int G = getG(c); |
|
|
|
int G = getG(c); |
|
|
|
int B = getB(c); |
|
|
|
|
|
|
|
int Y = (int)( 0.299*R+0.587*G+0.114*B); |
|
|
@@ -1706,7 +1778,7 @@ color toYDbDr(color c) { |
|
|
|
} |
|
|
|
|
|
|
|
color fromYDbDr(color c) { |
|
|
|
int Y = getR(c); |
|
|
|
int Y = getR(c); |
|
|
|
float Db = (getG(c)-127.5)*2.666; |
|
|
|
float Dr = (getB(c)-127.5)*2.666; |
|
|
|
|
|
|
@@ -1723,7 +1795,7 @@ color fromYDbDr(color c) { |
|
|
|
|
|
|
|
color toYCbCr(color c) { |
|
|
|
int R = getR(c); |
|
|
|
int G = getG(c); |
|
|
|
int G = getG(c); |
|
|
|
int B = getB(c); |
|
|
|
|
|
|
|
int Y = (int)( 0.2988390*R+0.5868110*G+0.1143500*B); |
|
|
@@ -1734,7 +1806,7 @@ color toYCbCr(color c) { |
|
|
|
} |
|
|
|
|
|
|
|
color fromYCbCr(color c) { |
|
|
|
int Y = getR(c); |
|
|
|
int Y = getR(c); |
|
|
|
float Cb = getG(c) - 127.5; |
|
|
|
float Cr = getB(c) - 127.5; |
|
|
|
|
|
|
@@ -1750,7 +1822,7 @@ color fromYCbCr(color c) { |
|
|
|
**************/ |
|
|
|
|
|
|
|
color toYPbPr(color c) { |
|
|
|
int R = getR(c); |
|
|
|
int R = getR(c); |
|
|
|
int B = getB(c); |
|
|
|
|
|
|
|
int Y = getLuma(c); |
|
|
@@ -1762,7 +1834,7 @@ color toYPbPr(color c) { |
|
|
|
} |
|
|
|
|
|
|
|
color fromYPbPr(color c) { |
|
|
|
int Y = getR(c); |
|
|
|
int Y = getR(c); |
|
|
|
int B = getG(c) + Y; |
|
|
|
int R = getB(c) + Y; |
|
|
|
if (R>255) R-=256; |
|
|
@@ -1779,7 +1851,7 @@ color fromYPbPr(color c) { |
|
|
|
**************/ |
|
|
|
|
|
|
|
color toRGGBG(color c) { |
|
|
|
int G = getG(c); |
|
|
|
int G = getG(c); |
|
|
|
int R = getR(c)-G; |
|
|
|
int B = getB(c)-G; |
|
|
|
if (R<0) R+=256; |
|
|
@@ -1788,7 +1860,7 @@ color toRGGBG(color c) { |
|
|
|
} |
|
|
|
|
|
|
|
color fromRGGBG(color c) { |
|
|
|
int G = getG(c); |
|
|
|
int G = getG(c); |
|
|
|
int R = getR(c)+G; |
|
|
|
int B = getB(c)+G; |
|
|
|
if (R>255) R-=256; |
|
|
@@ -1823,45 +1895,45 @@ color toHSB(color c) { |
|
|
|
color fromHSB(color c) { |
|
|
|
float S = getNG(c); |
|
|
|
float B = getNB(c); |
|
|
|
if (S == 0.0) return blendRGB(c, B, B, B); |
|
|
|
if (S == 0.0) return blendRGB(c, B, B, B); |
|
|
|
|
|
|
|
float h = 6.0 * getNR(c); |
|
|
|
float f = h-floor(h); |
|
|
|
float p = B*(1.0-S); |
|
|
|
float q = B*(1.0-S*f); |
|
|
|
float t = B*(1.0-(S*(1.0-f))); |
|
|
|
float t = B*(1.0-(S*(1.0-f))); |
|
|
|
|
|
|
|
float r, g, b; |
|
|
|
switch((int)h) { |
|
|
|
case 1: |
|
|
|
r=q; |
|
|
|
g=B; |
|
|
|
b=p; |
|
|
|
case 1: |
|
|
|
r=q; |
|
|
|
g=B; |
|
|
|
b=p; |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
r=p; |
|
|
|
g=B; |
|
|
|
b=t; |
|
|
|
case 2: |
|
|
|
r=p; |
|
|
|
g=B; |
|
|
|
b=t; |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
r=p; |
|
|
|
g=q; |
|
|
|
b=B; |
|
|
|
case 3: |
|
|
|
r=p; |
|
|
|
g=q; |
|
|
|
b=B; |
|
|
|
break; |
|
|
|
case 4: |
|
|
|
r=t; |
|
|
|
g=p; |
|
|
|
b=B; |
|
|
|
case 4: |
|
|
|
r=t; |
|
|
|
g=p; |
|
|
|
b=B; |
|
|
|
break; |
|
|
|
case 5: |
|
|
|
r=B; |
|
|
|
g=p; |
|
|
|
b=q; |
|
|
|
case 5: |
|
|
|
r=B; |
|
|
|
g=p; |
|
|
|
b=q; |
|
|
|
break; |
|
|
|
default: |
|
|
|
r=B; |
|
|
|
g=t; |
|
|
|
b=p; |
|
|
|
default: |
|
|
|
r=B; |
|
|
|
g=t; |
|
|
|
b=p; |
|
|
|
break; |
|
|
|
} |
|
|
|
return blendRGB(c, r, g, b); |
|
|
@@ -1905,35 +1977,35 @@ color fromHWB(color c) { |
|
|
|
float n = whiteness+f*(v-whiteness); |
|
|
|
float r, g, b; |
|
|
|
switch(i) { |
|
|
|
case 1: |
|
|
|
r=n; |
|
|
|
g=v; |
|
|
|
b=whiteness; |
|
|
|
case 1: |
|
|
|
r=n; |
|
|
|
g=v; |
|
|
|
b=whiteness; |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
r=whiteness; |
|
|
|
g=v; |
|
|
|
b=n; |
|
|
|
case 2: |
|
|
|
r=whiteness; |
|
|
|
g=v; |
|
|
|
b=n; |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
r=whiteness; |
|
|
|
g=n; |
|
|
|
b=v; |
|
|
|
case 3: |
|
|
|
r=whiteness; |
|
|
|
g=n; |
|
|
|
b=v; |
|
|
|
break; |
|
|
|
case 4: |
|
|
|
r=n; |
|
|
|
g=whiteness; |
|
|
|
b=v; |
|
|
|
case 4: |
|
|
|
r=n; |
|
|
|
g=whiteness; |
|
|
|
b=v; |
|
|
|
break; |
|
|
|
case 5: |
|
|
|
r=v; |
|
|
|
g=whiteness; |
|
|
|
b=n; |
|
|
|
case 5: |
|
|
|
r=v; |
|
|
|
g=whiteness; |
|
|
|
b=n; |
|
|
|
break; |
|
|
|
default: |
|
|
|
r=v; |
|
|
|
g=n; |
|
|
|
b=whiteness; |
|
|
|
default: |
|
|
|
r=v; |
|
|
|
g=n; |
|
|
|
b=whiteness; |
|
|
|
break; |
|
|
|
} |
|
|
|
return blendRGB(c, r, g, b); |
|
|
@@ -2034,7 +2106,7 @@ final float PerceptibleReciprocal(float x) { |
|
|
|
float sgn = x < 0.0 ? -1.0 : 1.0; |
|
|
|
if ((sgn * x) >= mepsilon) return (1.0 / x); |
|
|
|
return (sgn/mepsilon); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
color toLUV(color c) { |
|
|
|
PVector xyz = _toXYZ(getNR(c), getNG(c), getNB(c)); |
|
|
@@ -2132,9 +2204,9 @@ color toYXY(color c) { |
|
|
|
float sum = xyz.x + xyz.y + xyz.z; |
|
|
|
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), |
|
|
|
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)); |
|
|
|
} |
|
|
|
|
|
|
@@ -2160,16 +2232,16 @@ PVector _toXYZ(float rr, float gg, float bb) { |
|
|
|
float r = correctionxyz(rr); |
|
|
|
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, |
|
|
|
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); |
|
|
|
} |
|
|
|
|
|
|
|
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), |
|
|
|
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)); |
|
|
|
} |
|
|
|
|
|
|
@@ -2241,26 +2313,26 @@ color toOHTA(color c) { |
|
|
|
//// |
|
|
|
// 1/n table for n=0..255 - to speed up color conversions things |
|
|
|
final static float[] r255 = { |
|
|
|
0.0, 0.003921569, 0.007843138, 0.011764706, 0.015686275, 0.019607844, 0.023529412, 0.02745098, 0.03137255, 0.03529412, 0.039215688, |
|
|
|
0.043137256, 0.047058824, 0.050980393, 0.05490196, 0.05882353, 0.0627451, 0.06666667, 0.07058824, 0.07450981, 0.078431375, 0.08235294, |
|
|
|
0.08627451, 0.09019608, 0.09411765, 0.09803922, 0.101960786, 0.105882354, 0.10980392, 0.11372549, 0.11764706, 0.12156863, 0.1254902, |
|
|
|
0.12941177, 0.13333334, 0.13725491, 0.14117648, 0.14509805, 0.14901961, 0.15294118, 0.15686275, 0.16078432, 0.16470589, 0.16862746, |
|
|
|
0.17254902, 0.1764706, 0.18039216, 0.18431373, 0.1882353, 0.19215687, 0.19607843, 0.2, 0.20392157, 0.20784314, 0.21176471, 0.21568628, |
|
|
|
0.21960784, 0.22352941, 0.22745098, 0.23137255, 0.23529412, 0.23921569, 0.24313726, 0.24705882, 0.2509804, 0.25490198, 0.25882354, |
|
|
|
0.2627451, 0.26666668, 0.27058825, 0.27450982, 0.2784314, 0.28235295, 0.28627452, 0.2901961, 0.29411766, 0.29803923, 0.3019608, 0.30588236, |
|
|
|
0.30980393, 0.3137255, 0.31764707, 0.32156864, 0.3254902, 0.32941177, 0.33333334, 0.3372549, 0.34117648, 0.34509805, 0.34901962, 0.3529412, |
|
|
|
0.35686275, 0.36078432, 0.3647059, 0.36862746, 0.37254903, 0.3764706, 0.38039216, 0.38431373, 0.3882353, 0.39215687, 0.39607844, 0.4, |
|
|
|
0.40392157, 0.40784314, 0.4117647, 0.41568628, 0.41960785, 0.42352942, 0.42745098, 0.43137255, 0.43529412, 0.4392157, 0.44313726, |
|
|
|
0.44705883, 0.4509804, 0.45490196, 0.45882353, 0.4627451, 0.46666667, 0.47058824, 0.4745098, 0.47843137, 0.48235294, 0.4862745, 0.49019608, |
|
|
|
0.49411765, 0.49803922, 0.5019608, 0.5058824, 0.50980395, 0.5137255, 0.5176471, 0.52156866, 0.5254902, 0.5294118, 0.53333336, 0.5372549, |
|
|
|
0.5411765, 0.54509807, 0.54901963, 0.5529412, 0.5568628, 0.56078434, 0.5647059, 0.5686275, 0.57254905, 0.5764706, 0.5803922, 0.58431375, |
|
|
|
0.5882353, 0.5921569, 0.59607846, 0.6, 0.6039216, 0.60784316, 0.6117647, 0.6156863, 0.61960787, 0.62352943, 0.627451, 0.6313726, 0.63529414, |
|
|
|
0.6392157, 0.6431373, 0.64705884, 0.6509804, 0.654902, 0.65882355, 0.6627451, 0.6666667, 0.67058825, 0.6745098, 0.6784314, 0.68235296, |
|
|
|
0.6862745, 0.6901961, 0.69411767, 0.69803923, 0.7019608, 0.7058824, 0.70980394, 0.7137255, 0.7176471, 0.72156864, 0.7254902, 0.7294118, |
|
|
|
0.73333335, 0.7372549, 0.7411765, 0.74509805, 0.7490196, 0.7529412, 0.75686276, 0.7607843, 0.7647059, 0.76862746, 0.77254903, 0.7764706, |
|
|
|
0.78039217, 0.78431374, 0.7882353, 0.7921569, 0.79607844, 0.8, 0.8039216, 0.80784315, 0.8117647, 0.8156863, 0.81960785, 0.8235294, 0.827451, |
|
|
|
0.83137256, 0.8352941, 0.8392157, 0.84313726, 0.84705883, 0.8509804, 0.85490197, 0.85882354, 0.8627451, 0.8666667, 0.87058824, 0.8745098, |
|
|
|
0.8784314, 0.88235295, 0.8862745, 0.8901961, 0.89411765, 0.8980392, 0.9019608, 0.90588236, 0.9098039, 0.9137255, 0.91764706, 0.92156863, |
|
|
|
0.9254902, 0.92941177, 0.93333334, 0.9372549, 0.9411765, 0.94509804, 0.9490196, 0.9529412, 0.95686275, 0.9607843, 0.9647059, 0.96862745, |
|
|
|
0.0, 0.003921569, 0.007843138, 0.011764706, 0.015686275, 0.019607844, 0.023529412, 0.02745098, 0.03137255, 0.03529412, 0.039215688, |
|
|
|
0.043137256, 0.047058824, 0.050980393, 0.05490196, 0.05882353, 0.0627451, 0.06666667, 0.07058824, 0.07450981, 0.078431375, 0.08235294, |
|
|
|
0.08627451, 0.09019608, 0.09411765, 0.09803922, 0.101960786, 0.105882354, 0.10980392, 0.11372549, 0.11764706, 0.12156863, 0.1254902, |
|
|
|
0.12941177, 0.13333334, 0.13725491, 0.14117648, 0.14509805, 0.14901961, 0.15294118, 0.15686275, 0.16078432, 0.16470589, 0.16862746, |
|
|
|
0.17254902, 0.1764706, 0.18039216, 0.18431373, 0.1882353, 0.19215687, 0.19607843, 0.2, 0.20392157, 0.20784314, 0.21176471, 0.21568628, |
|
|
|
0.21960784, 0.22352941, 0.22745098, 0.23137255, 0.23529412, 0.23921569, 0.24313726, 0.24705882, 0.2509804, 0.25490198, 0.25882354, |
|
|
|
0.2627451, 0.26666668, 0.27058825, 0.27450982, 0.2784314, 0.28235295, 0.28627452, 0.2901961, 0.29411766, 0.29803923, 0.3019608, 0.30588236, |
|
|
|
0.30980393, 0.3137255, 0.31764707, 0.32156864, 0.3254902, 0.32941177, 0.33333334, 0.3372549, 0.34117648, 0.34509805, 0.34901962, 0.3529412, |
|
|
|
0.35686275, 0.36078432, 0.3647059, 0.36862746, 0.37254903, 0.3764706, 0.38039216, 0.38431373, 0.3882353, 0.39215687, 0.39607844, 0.4, |
|
|
|
0.40392157, 0.40784314, 0.4117647, 0.41568628, 0.41960785, 0.42352942, 0.42745098, 0.43137255, 0.43529412, 0.4392157, 0.44313726, |
|
|
|
0.44705883, 0.4509804, 0.45490196, 0.45882353, 0.4627451, 0.46666667, 0.47058824, 0.4745098, 0.47843137, 0.48235294, 0.4862745, 0.49019608, |
|
|
|
0.49411765, 0.49803922, 0.5019608, 0.5058824, 0.50980395, 0.5137255, 0.5176471, 0.52156866, 0.5254902, 0.5294118, 0.53333336, 0.5372549, |
|
|
|
0.5411765, 0.54509807, 0.54901963, 0.5529412, 0.5568628, 0.56078434, 0.5647059, 0.5686275, 0.57254905, 0.5764706, 0.5803922, 0.58431375, |
|
|
|
0.5882353, 0.5921569, 0.59607846, 0.6, 0.6039216, 0.60784316, 0.6117647, 0.6156863, 0.61960787, 0.62352943, 0.627451, 0.6313726, 0.63529414, |
|
|
|
0.6392157, 0.6431373, 0.64705884, 0.6509804, 0.654902, 0.65882355, 0.6627451, 0.6666667, 0.67058825, 0.6745098, 0.6784314, 0.68235296, |
|
|
|
0.6862745, 0.6901961, 0.69411767, 0.69803923, 0.7019608, 0.7058824, 0.70980394, 0.7137255, 0.7176471, 0.72156864, 0.7254902, 0.7294118, |
|
|
|
0.73333335, 0.7372549, 0.7411765, 0.74509805, 0.7490196, 0.7529412, 0.75686276, 0.7607843, 0.7647059, 0.76862746, 0.77254903, 0.7764706, |
|
|
|
0.78039217, 0.78431374, 0.7882353, 0.7921569, 0.79607844, 0.8, 0.8039216, 0.80784315, 0.8117647, 0.8156863, 0.81960785, 0.8235294, 0.827451, |
|
|
|
0.83137256, 0.8352941, 0.8392157, 0.84313726, 0.84705883, 0.8509804, 0.85490197, 0.85882354, 0.8627451, 0.8666667, 0.87058824, 0.8745098, |
|
|
|
0.8784314, 0.88235295, 0.8862745, 0.8901961, 0.89411765, 0.8980392, 0.9019608, 0.90588236, 0.9098039, 0.9137255, 0.91764706, 0.92156863, |
|
|
|
0.9254902, 0.92941177, 0.93333334, 0.9372549, 0.9411765, 0.94509804, 0.9490196, 0.9529412, 0.95686275, 0.9607843, 0.9647059, 0.96862745, |
|
|
|
0.972549, 0.9764706, 0.98039216, 0.9843137, 0.9882353, 0.99215686, 0.99607843, 1.0 |
|
|
|
}; |