// Plotter.pde (part of Cubicles) // Dave Bollinger, Sep 2006 // http://www.davebollinger.com // for Processing 0115 Beta color mix(color c1, color c2, int t) { int s = 256-t; int r = ((((c1&0xFF0000)*s) + ((c2&0xFF0000)*t)) >> 8) & 0xFF0000; int g = ((((c1&0xFF00)*s) + ((c2&0xFF00)*t)) >> 8) & 0xFF00; int b = ((((c1&0xFF)*s) + ((c2&0xFF)*t)) >> 8) & 0xFF; return 0xFF000000 | r | g | b; } void plot(float fx, float fy, color c) { fx -= 0.5; fy -= 0.5; int ix = (int)floor(fx); int iy = (int)floor(fy); if ((ix<-1) || (iy<-1) || (ix>=width) || (iy>=height)) return; float fx2 = fx - (float)(ix); float fy2 = fy - (float)(iy); float fx1 = 1.0 - fx2; float fy1 = 1.0 - fy2; int idx11 = iy * width + ix; int idx21 = idx11 + 1; int idx12 = idx11 + width; int idx22 = idx12 + 1; float alf = alpha(c); int t11 = int(fx1 * fy1 * alf); int t21 = int(fx2 * fy1 * alf); int t12 = int(fx1 * fy2 * alf); int t22 = int(fx2 * fy2 * alf); if (iy >= 0) { if (ix>=0) pixels[idx11] = mix(pixels[idx11], c, t11); if (ix=0) pixels[idx12] = mix(pixels[idx12], c, t12); if (ix