function [r,g,b] = showcmplx(f,minrl,maxrl,mincmplx,maxcmplx,del,maxcoldist)
%
% showcmplx - produces a color plot of the complex function f
% On input:
%     f: complex function of one complex variable
%     minrl: minimum real value in domain
%     maxrl: maximum real value in domain
%     mincmplx: minimum complex value in domain
%     maxcmplx: maximum complex value in domain
%     del: step size in domain
%     maxcoldist: maximum distance from origin (this is used to scale 
%                 magnitude into [0,1]
% On output:
%     r: red value (scaled magnitude of function at given point)
%     g: green value (scaled orientation of function at given point)
%     b: blue value (fixed at 0)
% Call:
%     [r,g,b] = showcmplx(f,minrl,maxrl,mincmplx,maxcmplx,del,maxcoldist)
%

minrow = 1; mincol = 1; pi2 = 2*pi;
maxrow = ceil((maxcmplx-mincmplx)/del);
maxcol = ceil((maxrl-minrl)/del);
r = zeros(maxrow,maxcol);
g = zeros(maxrow,maxcol);
b = zeros(maxrow,maxcol);

for row = minrow:maxrow
  fcmplxin = maxcmplx - del*(row-1);
  for col = mincol:maxcol
    frlin = minrl + del*(col-1);
    fin = frlin + i*fcmplxin;
    fout = feval(f,fin);
    r(row,col) = min(norm(fout)/maxcoldist,1);
    g(row,col) = posori(atan2(imag(fout),real(fout)))/pi2;
  end
end
