Convert geometry to path in wpf (with blend?)

my question is simple.

how can i convert this code:

<Path>
    <Path.Data>
        <EllipseGeometry Center="5,4" RadiusX="4" RadiusY="4"/>
    </Path.Data>
</Path>

into something like

<Path Data="M 0 5 L 3 10 10 0"/>

(note that the second creates a check mark, not an ellipse. It was just for illustration, and my goal is to find which sequence the ellipse gives)

edit: I also read the document on Bezier curves in xaml and fully realized that I can just create the correct code by calculating the exact points of the Bezier curve to get an ellipse, but I do not want to go into the hassle of doing this calculation myself, so I was wondering if Is there an easy way to do this (possibly in Blend)

+3
source share
1 answer

, . , - " "? , , Blend. , .

EllipseGeometry PathGeometry:

var geom = new EllipseGeometry(new Point(5, 4), 4, 4);
var pathGeometry = PathGeometry.CreateFromGeometry(geom);

PathGeometry, ToString, :

string pathText = pathGeometry.ToString();

:

"M9,4C9,6.20913899932317 7.20913899932317,8 5,8 2,7,9091300067683,8 1,6,20913899932317 1,4 1,1,79086100067683 2,79086100067683,0 5,0 7.20913899932317,0 9,1.79086100067683 9,4z"

, , , Xaml, , Xaml , :

<Path Data="M 0 5 L 3 10 10 0"/>

a PathGeometry. StreamGeometry, , . ( , , , StreamGeometry, PathGeometry. StreamGeometry .)

StreamGeometry :

var streamGeometry = StreamGeometry.Parse(pathText);

, , Path :

var p = new Path { Data = streamGeometry };

. (StreamGeometry - , , , , , PathGeometry, . , - , PathGeometry .)

+7

Source: https://habr.com/ru/post/1780170/


All Articles