# Coloring a shape according to a function

I would like to create a $2D$ shape, say an ellipse, where each point in the ellipse is colored according a RGB function, so at point x and y the color would be:

RGBColor[ u[x,y], v[x,y], w[x,y]]


I am sure there has to be an easy way to do this, but I have not had much luck.

u[x_, y_] := Sin[x] + Cos[y]
v[x_, y_] := E^-x + y
w[x_, y_] := Tanh[x] + Sqrt[y]
RegionPlot[2 x^2 + y^2 < 1, {x, -1, 1}, {y, -1, 1}, Mesh -> None,
ColorFunction -> Function[{x, y}, RGBColor[u[x, y], v[x, y], w[x, y]]]]


Result: • Thanks, this is exactly what I was looking for. – Michael Ray Jun 13 '13 at 13:13

Let's use a polar formula for a conic curve,

cc[u_, eps_] := {1/(1 + eps Cos[u]) Cos[u], 1/(1 + eps Cos[u]) Sin[u]}


For -1 < eps < 1 we have an ellipse, for eps == 1 a parabola, and for eps > 1 a hyperbola.

We assume a simple function to describe dependence of the color on the angle:

ParametricPlot[ cc[u, 2/3], {u, 0, 2 Pi}, Axes -> False, PlotStyle -> Thick,
ColorFunction -> Function[{x, y, u}, Hue[u/(2 Pi)]],
ColorFunctionScaling -> False] ParametricPlot[ cc[u, 1], {u, 0, 2 Pi}, Axes -> False, PlotStyle -> Thick,
ColorFunction -> Function[{x, y, u}, Hue[u/(2 Pi)]],
ColorFunctionScaling -> False] and to plot a hyperbola we'd use Exclusions (to get rid of zero from the denominator) e.g.

ParametricPlot[ cc[u, 3/2], {u, 0, 2 Pi}, Axes -> False, PlotStyle -> Thick,
ColorFunction -> Function[{x, y, u}, Hue[u/(2 Pi)]],
ColorFunctionScaling -> False, Exclusions -> {Cos[u] == 2/3, Cos[u] == -2/3}] • I don't get to see the polar (Keplerian) form everyday, so +1 for that. :) – J. M. is in limbo Jun 12 '13 at 17:16