#Matlab, 255 245 231 bytes
Matlab, 255 245 231 bytes
This expects the image name first, then y and then x.
I=@input;i=imread(I('','s'));[r,c]=size(i);m=zeros(r,c);m(I(''),I(''))=1;M=m;d=m;K=[1,2,1];for k=1:r*c;d(m&~M)=k;M=m;m=~~conv2(m,K'*K>1,'s');m(~i)=0;end;z=max(d(:));v=[1,1,3];imshow(ind2rgb(d,hsv(z)).*repmat(m,v)+repmat(~d&i,v),[])
I implemented the flood filling (or 'dijkstra for 4-neighbourhoods' if you want) roughly by first creating a mask where the seed pixel is set to 1 and with a distance accumulator (both of the size of the image) and then repeating following steps:
- convolute the mask with a 4 neighbourhood kernel (this is the very inefficient part)
- set all nonzero pixels of the mask to 1
- set all the black pixels of the image to zero
- set all values in the accumulator where the mask has changed in this step to
k - increase
k - repeat until there are no more changes in the mask (I actually do not check this condition, but just use the number of pixels in the image as an upper bound, which is usually a very bad upper bound, but this is codegolf=)
This leaves us with the manhattan distances of every pixel to the seed pixel in the distance accumulator. Then we create a new image by going throu the given range of colours and map the "first" hue to the value zero and the "last" hue to the maximal distance.
#Examples
Examples
As a bonus, here a pretty picture of how the distance gets calculated. brighter = farther away.




