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
    Sep 29, 2020 at 0:53
  • $\begingroup$ @kglr Exactly what I was looking for. $\endgroup$ Sep 29, 2020 at 1:18
  • $\begingroup$ @kglr Can the arrow also be made of blue color? $\endgroup$ Sep 29, 2020 at 1:20
  • 1
    $\begingroup$ @kglr Got the arrow part. $\endgroup$ 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 that you have read and understand our privacy policy and code of conduct.

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