// color --------------------------------------------------------------------------------------------------------------------- color dkBrownColor = color(77,47,31); color medBrownColor = color(125,88,64); color ltBrownColor = color(185,142,92); color medGreenColor = color(66,90,33); color ltGreenColor = color(122,140,66); color ltltGreenColor = color(169,190,99); color dkBlueColor = color(14,30,60); color medBlueColor = color(34,65,105); color ltBlueColor = color(54,100,150); color ltltBlueColor = color(74,135,195); color dkPurpleColor = color(57,24,51); color medPurpleColor = color(80,53,73); color dkRedColor = color(112,15,0); color medRedColor = color(146,54,38); color ltRedColor = color(180,90,76); color ltltRedColor = color(214,126,114); color orangeColor = color(186,92,38); color yellowColor = color(191,146,54); color offWhiteColor = color(255,255,243); color dkGrayColor = color(0); color medGrayColor = color(102); color ltGrayColor = color(204); color shift(color col, float r) { if (r>0) { return lerpColor(col,color(255,255,255,alpha(col)),r); } else { return lerpColor(col,color(0,0,0,alpha(col)),-r); } } color lighten(color col) {return shift(col,0.25);} color darken(color col) {return shift(col,-0.25);} color randomshift(color col) { return shift(col, random(-0.5,0.5)); } color transparency(color col, float f) { return color(red(col),green(col),blue(col),f*alpha(col)); } color desaturate(color col) { return color(brightness(col),brightness(col),brightness(col),alpha(col)); } color[] colormapcat(int N, color col1, color col2) {return colormapcat(N, new color[] {col1, col2});} color[] colormapcat(int N, color col1, color col2, color col3) {return colormapcat(N, new color[] {col1, col2, col3});} color[] colormapcat(int N, color col1, color col2, color col3, color col4) {return colormapcat(N, new color[] {col1, col2, col3, col4});} color[] colormapcat(int N, color col1, color col2, color col3, color col4, color col5) {return colormapcat(N, new color[] {col1, col2, col3, col4, col5});} color[] colormapcat(int N, color[] cols) { int N0 = cols.length; float[] R0 = new float[N0], G0 = new float[N0], B0 = new float[N0], ind0 = new float[N0]; for (int i=0; i0)); } boolean isnan(float[] x) { boolean found = false; for (int i=0; i X[0]) { dir = 1; failed = ((xiX[Nx-1])); } else { dir = -1; failed = ((xi>X[0]) || (xi 1) { if (dir==1) { if (xi>X[nmid]) { nbefore = nmid; } else { nafter = nmid; } } else { if (xi xmax) { yi[i] = interp1(x,y,xmax); } else { yi[i] = interp1(x,y,xi[i]); } } return yi; } // text ------------------------------------------------------------------------------------- String nicenum(float a) { if (a==round(a)) { return "" + round(a); } else { return "" + a; } } void textVAlign(String S, float x, float y) {textVAlign(S,x,y,"baseline");} void textVAlign(String S, float x, float y, String align) { if (align.equals("baseline")) { text(S,x,y); } else if (align.equals("middle")) { text(S,x,y+0.5*(textAscent())); } else if (align.equals("bottom")) { text(S,x,y-textDescent()); } else if (align.equals("top")) { text(S,x,y+textAscent()); } } int countLines(String S) { int c = 1; for (int i=0; i