Plotting 2D color function on the plane [duplicate]

This question already has an answer here:

Suppose p is a some point in the plane. The function f[q] defined as

f[q_]:= Block[{d = Norm[p-q]}, RGBColor[1 - d/(1 + d), 0, d/(1 + d)]]


Continuously colors points in the plane by thier distance from p. What is the easiest way to plot this in 2D? I tried DensityPlot but that's not exactly what I'm looking for. Basically I want to specify some color function for points in the plane and plot it. Contours would be a bonus.

Apologies if this exact question has been asked before.

-

marked as duplicate by Öskå, Artes, Sjoerd C. de Vries, RunnyKine, Mr.Wizard♦Aug 14 '14 at 21:00

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

I guess you are looking for something like this Coloring a shape according to a function. – Artes Aug 14 '14 at 16:49
Yes. I think that will work. RegionPlot looks like the solution. Mebbe I should delete this question. – amcalde Aug 14 '14 at 16:51
OK I can't get this to work for a simple example. I put p = {2,3}, f as above, then RegionPlot[True, {x, 1, 4}, {y, 1, 4}, ColorFunction -> Function[{x, y}, f@{x, y}]] Doesn't work, gives a solid square. – amcalde Aug 14 '14 at 18:35
Add ColorFunctionScaling->False to your plot and see if that does what you'd like. – bobthechemist Aug 14 '14 at 19:33
That did it, thaks @bobthechemist! – amcalde Aug 14 '14 at 19:35

1 Answer

Just for fun, try this

ControllerManipulate[
RegionPlot[True, {x, 1, 4}, {y, 1, 4}, ColorFunctionScaling -> False,
ColorFunction ->
Function[{x, y},
Block[{d = Norm[l - #]},
RGBColor[1 - d/(1 + d), 0, d/(1 + d)]] & @{x, y}]], {{l, {2,
2}}, Locator, Appearance -> None}]


-