/// <summary> /// Parses the specified path data and converts it to <see cref="CompositionGeometricClip"/>. /// </summary> /// <param name="compositor"><see cref="Compositor"/></param> /// <param name="pathData">Path data (Win2d Path Mini Language) in string format.</param> /// <returns><see cref="CompositionGeometricClip"/></returns> public static CompositionGeometricClip CreateGeometricClip(this Compositor compositor, string pathData) { // Create the CanvasGeometry from the path data var geometry = CanvasPathGeometry.CreateGeometry(pathData); // Create the CompositionGeometricClip return compositor.CreateGeometricClip(geometry); }
/// <summary> /// Creates a <see cref="CompositionPathGeometry"/> based on the given path data. /// </summary> /// <param name="compositor"><see cref="Compositor"/></param> /// <param name="pathData">Path data (Win2d Path Mini Language) in string format.</param> /// <returns><see cref="CompositionPathGeometry"/></returns> public static CompositionPathGeometry CreatePathGeometry(this Compositor compositor, string pathData) { // Create CanvasGeometry var geometry = CanvasPathGeometry.CreateGeometry(pathData); // Create CompositionPathGeometry return compositor.CreatePathGeometry(new CompositionPath(geometry)); }
/// <summary> /// Creates a <see cref="CompositionSpriteShape"/> based on the specified path data. /// </summary> /// <param name="compositor"><see cref="Compositor"/></param> /// <param name="pathData">Path data (Win2d Path Mini Language) in string format.</param> /// <returns><see cref="CompositionSpriteShape"/></returns> public static CompositionSpriteShape CreateSpriteShape(this Compositor compositor, string pathData) { // Create CanvasGeometry var geometry = CanvasPathGeometry.CreateGeometry(pathData); // Create CompositionPathGeometry var pathGeometry = compositor.CreatePathGeometry(new CompositionPath(geometry)); // Create CompositionSpriteShape return(compositor.CreateSpriteShape(pathGeometry)); }
/// <summary> /// Fills a Squircle of the specified dimensions, using the given brush at specified offset. /// </summary> /// <param name="session">CanvasDrawingSession</param> /// <param name="x">Offset of the top left corner of the Squircle on the x-axis</param> /// <param name="y">Offset of the top left corner of the Squircle on the y-axis</param> /// <param name="w">Width of the Squircle</param> /// <param name="h">Height of the Squircle</param> /// <param name="radiusX">Corner Radius on the x axis</param> /// <param name="radiusY">Corner Radius on the y axis</param> /// <param name="offset">Offset of the Squircle from the origin.</param> /// <param name="brush">Brush to fill the Squircle.</param> public static void FillSquircle(this CanvasDrawingSession session, float x, float y, float w, float h, float radiusX, float radiusY, Vector2 offset, ICanvasBrush brush) { using var geometry = CanvasPathGeometry.CreateSquircle(session.Device, x, y, w, h, radiusX, radiusY); session.FillGeometry(geometry, offset, brush); }
/// <summary> /// Fills a Squircle of the specified dimensions, using the given color. /// </summary> /// <param name="session">CanvasDrawingSession</param> /// <param name="x">Offset of the top left corner of the Squircle on the x-axis</param> /// <param name="y">Offset of the top left corner of the Squircle on the y-axis</param> /// <param name="w">Width of the Squircle</param> /// <param name="h">Height of the Squircle</param> /// <param name="radiusX">Corner Radius on the x axis</param> /// <param name="radiusY">Corner Radius on the y axis</param> /// <param name="color">Color to fill the Squircle.</param> public static void FillSquircle(this CanvasDrawingSession session, float x, float y, float w, float h, float radiusX, float radiusY, Color color) { using var geometry = CanvasPathGeometry.CreateSquircle(session.Device, x, y, w, h, radiusX, radiusY); session.FillGeometry(geometry, color); }
/// <summary> /// Draws a Squircle of the specified dimensions, using a CanvasStroke to define the stroke width, the stroke color and stroke style. /// </summary> /// <param name="session">CanvasDrawingSession</param> /// <param name="x">Offset of the top left corner of the Squircle on the x-axis</param> /// <param name="y">Offset of the top left corner of the Squircle on the y-axis</param> /// <param name="w">Width of the Squircle</param> /// <param name="h">Height of the Squircle</param> /// <param name="radiusX">Corner Radius on the x axis</param> /// <param name="radiusY">Corner Radius on the y axis</param> /// <param name="offset">Offset of the Squircle from the origin.</param> /// <param name="stroke">CanvasStroke defining the stroke width, the stroke /// color and stroke style.</param> public static void DrawSquircle(this CanvasDrawingSession session, float x, float y, float w, float h, float radiusX, float radiusY, Vector2 offset, ICanvasStroke stroke) { using var geometry = CanvasPathGeometry.CreateSquircle(session.Device, x, y, w, h, radiusX, radiusY); session.DrawGeometry(geometry, offset, stroke); }