I need to define a color gradient on a 3D curve, but I'm having some problems with this.
Suppose we have a 3D curve defined as a parametric function of some real variable phi
:
curve[phi_] := {...};
where phi
runs from phi1
to phi2
. Now, I defined the start, middle and end colors like this :
Color1 := RGBColor[0.99, 0.2, 0.2, 0.2];
Color2 := RGBColor[0.2, 0.99, 0.2, 0.8];
Color3 := RGBColor[0.2, 0.2, 0.99, 0.2];
CurveColor[phi_] = Blend[{Color1, Color2, Color3}, phi];
The last definition doesn't work. I need the function CurveColor[phi]
to output four real positive numbers smaller than 1, like this :
CurveColor[phi1] := {0.99, 0.2, 0.2, 0.2}
CurveColor[phi2] := {0.2, 0.2, 0.99, 0.2}
The colors should blend smoothly between Color1
to Color2
to Color3
, and be uniformly distributed along the interval phi1
to phi2
).
So how should I define that color function ? I don't need that function to be used in a plot3D. I only need the color data as a list of numbers.
Please, notice that I'm working with Mathematica 7.
Answer
Since you only want the numbers, you can get them by using Apply
:
CurveColor[phi_] = List@@Blend[{Color1, Color2, Color3},
Rescale[phi, {phimin, phimax}]]
which will ensure that you always use the same blending functionality that Blend
uses. Note, the use of Rescale
.
Comments
Post a Comment