20
$\begingroup$

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}]}] 

spLine

$\endgroup$

2 Answers 2

19
$\begingroup$

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}]} ] 

enter image description here

$\endgroup$
1
  • $\begingroup$ This was what I was looking for. tks $\endgroup$ Commented Jul 31, 2013 at 11:14
11
$\begingroup$
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 ] 

Mathematica graphics

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.