3
$\begingroup$

I would like to color gradient (Red to Blue) the following curve:

gr = Graphics[{Arrow[BezierCurve[{{0, 3}, {.8, 2}, {1.8, 1.7}}]]}]

Any help will be appreciated.

$\endgroup$
4
  • 1
    $\begingroup$ Graphics[{Antialiasing -> True, Arrow[Line[ BezierFunction[{{0, 3}, {.8, 2}, {1.8, 1.7}}] /@ Subdivide[50], VertexColors -> (Blend[{Red, Blue}, #] & /@ Subdivide[50])]]}]? $\endgroup$
    – kglr
    Commented Sep 29, 2020 at 0:53
  • $\begingroup$ @kglr Exactly what I was looking for. $\endgroup$ Commented Sep 29, 2020 at 1:18
  • $\begingroup$ @kglr Can the arrow also be made of blue color? $\endgroup$ Commented Sep 29, 2020 at 1:20
  • 1
    $\begingroup$ @kglr Got the arrow part. $\endgroup$ Commented Sep 29, 2020 at 1:22

1 Answer 1

5
$\begingroup$
Graphics[{Antialiasing -> True, Blue, AbsoluteThickness[2], 
  Arrowheads[.05], 
  Arrow[Line[BezierFunction[{{0, 3}, {.8, 2}, {1.8, 1.7}}] /@ Subdivide[100], 
    VertexColors -> (Blend[{Red, Blue}, #] & /@ Subdivide[100])]]}]

enter image description here

To get a smoother look Rasterize using a large ImageSize and resize using Magnify:

Magnify[Rasterize[
  Graphics[{Antialiasing -> True, Blue, AbsoluteThickness[20], 
    Arrowheads[.05], 
    Arrow[Line[BezierFunction[{{0, 3}, {.8, 2}, {1.8, 1.7}}] /@ Subdivide[100],
       VertexColors -> (Blend[{Red, Blue}, #] & /@ Subdivide[100])]]}], 
  ImageSize -> 5000], .1]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.