Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
205 views
in Technique[技术] by (71.8m points)

c# - Drawing a double arrow line

I'm trying to render a double sided arrow using the Geometry class. I've been able to get an arrow as below image:

enter image description here

As you can see from the image, it seems that the line is off as well on the bottom right where it's highlighted in yellow:

enter image description here

I am trying to achieve drawing a double sided arrow line like the image below:

enter image description here

Here's what I am working with so far, if more details need to be added please let me know.

public class DoubleArrow : Shape
{
   public DoubleArrow() : base()
   {
      Stretch = Stretch.Fill;
   }

   protected override Geometry DefiningGeometry
   {
      get { return GetGeometry(); }
   }

   protected override Size MeasureOverride(Size constraint)
   {
      return constraint;
   }

   private Geometry GetGeometry()
   {                     
      return Geometry.Parse("M 0 4 L 16 4 L 10 0 M 16 4 L 10 8");
   }
}
question from:https://stackoverflow.com/questions/65926815/drawing-a-double-arrow-line

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You are drawing your path like a stroke:

Original SVG path

This will not allow you to use Fill and is the reason your point looks mismatched. If you instead draw your path like a polygon, you will be able to use Fill and your points will appear aligned.

New SVG path

Here's the path I would use, you can check it out using this online editor.

M 0  4
L 4  2
L 4  3.75
L 16 3.75
L 16 2
L 20 4
L 16 6
L 16 4.25
L 4  4.25
L 4  6
L 0  4

Edit

Just saw that you changed your target picture. Here's the path I would use for the new one:

M 4  2
L 0  4
L 4  6
M 0  4
L 20 4
M 16 2
L 20 4
L 16 6

Stroke SVG path


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...