function clr=colorwrap(x,y,scalenum)
zy=y;zx=x;
dxy=y-x;
for dimv=1:3
  if dxy(dimv)==0
    clr1(:,dimv)=zeros(scalenum,1)+y(dimv);
  else
    try
      clr1(:,dimv)=x(dimv):dxy(dimv)/(scalenum-1):y(dimv);
    catch
      clr1(:,dimv)=x(dimv):-dxy(dimv)/(scalenum-1):y(dimv);
    end
  end
end
clr=[clr1];