How can I color a BezierCurve
from Red
into Green
just as Line
does?
pts={{0,0}, {1,1}, {2,0}};
Graphics[{Thick, BezierCurve[pts], Line[{{0,0}, {2,0}}, VertexColors->{Red, Green}]}]
A simple line strip should be sufficient for most purposes and there you can use VertexColors
as usual:
pts = {{0, 0}, {1, 1}, {2, 0}};
Graphics[{Thick,
Line[BezierFunction[pts] /@ #,
VertexColors -> (Blend[{Red, Green}, #] & /@ #)] &[Range[0, 1, .01]],
Line[{{0, 0}, {2, 0}}, VertexColors -> {Red, Green}]}
]
pts = {{0, 0}, {1, 1}, {2, 0}};
f = BezierFunction[pts];
Show[
ParametricPlot[f[t], {t, 0, 2}, ColorFunction -> Function[{x}, RGBColor[1 - x, x, 0]]],
Graphics[{Thick,Line[{{0, 0}, {2, 0}}, VertexColors -> {Red, Green}]}], Axes -> None
]