lerp = x < X/3 ? 0 : x > 2*X/3 ? 255 : (x-X/3)*Z/(X/3) r doug rdoug = Z-doug[X-x,y] (doug*lerp+rdoug*(Z-lerp))/Z d (rdoug*lerp+doug*(Z-lerp))/Z d