7
$\begingroup$

How to draw an arrow such that this arrow gradually dims away?

Say the arrow head has Opacity[1], but the arrow end has Opacity[0]?

Thank you in advance! Here is the minimal code:

Graphics[{
  Black, Opacity[1], Arrowheads[Large], Arrow[{{2.5, 2.5}, {5, 5}}]
  }]

Here is an example of the enter image description herearrow: I failed to manage to gradually dims the arrow away to the arrow end.

$\endgroup$

1 Answer 1

9
$\begingroup$
Graphics @ 
 {Arrowheads[{{.1, 1, {Graphics[{Opacity[.1, Black], 
    Polygon[{{-1, 1/2}, {0, 0}, {-1, -1/2}}]}], 1}}}], 
  AbsoluteThickness[5], 
  Arrow[Line[{{2.5, 2.5}, {5, 5}}, 
    VertexColors -> {Opacity[1, Black], Opacity[.1, Black]}]]}

enter image description here

Graphics @ 
 {Green, Rectangle[{3.9, 3.9}], 
  Arrowheads[{{.1, 1, {Graphics[{Opacity[.1, Black], 
        Polygon[{{-1, 1/2}, {0, 0}, {-1, -1/2}}]}], 1}}}], 
  AbsoluteThickness[10], 
  Arrow[Line[{{2.5, 2.5}, {5, 5}}, 
     VertexColors -> {Opacity[1, Black], Opacity[.1, Black]}]]}

enter image description here

Replace Opacity[1, Black] with Opacity[1, Purple] and Opacity[.1, Black] with Opacity[.3, Orange] to get

enter image description here

Alternatively, without Opacity:

Graphics @ 
 {Green, Rectangle[{3.9, 3.9}], 
  Arrowheads[{{.1, 1, {Graphics[{GrayLevel[.9], 
        Polygon[{{-1, 1/2}, {0, 0}, {-1, -1/2}}]}], 1}}}], 
  AbsoluteThickness[10], 
  Arrow[Line[{{2.5, 2.5}, {5, 5}},
     VertexColors -> {GrayLevel[0], GrayLevel[.9]}]]}

enter image description here

Replace GrayLevel[0] with Purple and GrayLevel[.9] with Lighter[Orange, .8] to get:

enter image description here

$\endgroup$
3
  • $\begingroup$ It seems a very smart way +1 thanks!!! $\endgroup$
    – wonderich
    Jun 17, 2021 at 2:39
  • 1
    $\begingroup$ I will accept the answer in a few days if no better solutions show up. :) I like this $\endgroup$
    – wonderich
    Jun 17, 2021 at 2:47
  • 1
    $\begingroup$ If using Polygon, LinearGradientFilling is an option. $\endgroup$ Jun 17, 2021 at 5:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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