1
votes

In my Metro app with c# and XAML, I have some basic points on which I want to draw. I can draw from start(x,y) point to destination point(x1, y1). But the line drawn is straight, but my requirement is to draw the curved line. Like bented at some angle, but i fails to achieve this.

Can someone help me to draw a curved line?

1
How about Bezier curves?Andrei Schneider
Thanks for reply, I can't use Bezier curves as it then needs to form a path with specific points but I am having hundreds of different drawing characters which don't have each point on the line.....so i want to make it simple so that I can create a line with just start and end points and with a angle.Mandeep Kaur

1 Answers

0
votes

Not exactly the two points and an angle you mention in comments, but the ArcSegment is quite close.

It draws a section of a circle/ellipse between two given points, where the curve is affected by radius, rotation, and direction values you can supply.

This isn't the full XAML (and you can also do this in code), but the essence:

<PathFigure StartPoint="200,200">
    <PathFigure.Segments>
        <PathSegmentCollection>
            <ArcSegment SweepDirection="Clockwise" Size="100,50" Point="400,200" />
        </PathSegmentCollection>
    </PathFigure.Segments>
</PathFigure>

Much easier to understand visually, so scroll down to the diagrams in the ArcSegment documentation for examples.

If you're curious about the details of ArcSegment, there's an interesting post by Charles Petzold: