Click or drag to resize
CanvasGeometry Class
Geometry objects provide a means of drawing and manipulating geometric shapes.
Inheritance Hierarchy
SystemObject
  Microsoft.Graphics.Canvas.GeometryCanvasGeometry

Namespace:  Microsoft.Graphics.Canvas.Geometry
Assembly:  Microsoft.Graphics.Canvas (in Microsoft.Graphics.Canvas.dll) Version: 0.0.0.0
Syntax
C#
public sealed class CanvasGeometry : IDisposable, 
	IGeometrySource2D

The CanvasGeometry type exposes the following members.

Properties
  NameDescription
Public propertyStatic memberDefaultFlatteningTolerance
A suitable flattening tolerance for most situations.
Public propertyDevice
Gets the device associated with this CanvasGeometry.
Top
Methods
  NameDescription
Public methodCombineWith(CanvasGeometry, Matrix3x2, CanvasGeometryCombine)
Returns the combination of this geometry and the specified geometry according to the specified combine operation, such as union, intersection, etc.
Public methodCombineWith(CanvasGeometry, Matrix3x2, CanvasGeometryCombine, Single)
Returns the combination of this geometry and the specified geometry according to the specified combine operation, such as union, intersection, etc.
Public methodCompareWith(CanvasGeometry)
Returns a value describing the intersection between this geometry and the specified geometry.
Public methodCompareWith(CanvasGeometry, Matrix3x2, Single)
Returns a value describing the intersection between this geometry and the specified geometry.
Public methodComputeArea
Returns the area of this geometry.
Public methodComputeArea(Matrix3x2, Single)
Returns the area of this geometry.
Public methodComputeBounds
Returns the bounds of the geometry.
Public methodComputeBounds(Matrix3x2)
Returns the bounds of the geometry.
Public methodStatic memberComputeFlatteningTolerance(Single, Single)
Computes the correct flattening tolerance given the specified DPI, and maximum zoom level.
Public methodStatic memberComputeFlatteningTolerance(Single, Single, Matrix3x2)
Computes the correct flattening tolerance given the specified DPI, maximum zoom level, and geometry transform.
Public methodComputePathLength
Returns the length of the geometry as though the entire path were unrolled into a single straight line.
Public methodComputePathLength(Matrix3x2, Single)
Returns the length of the geometry as though the entire path were unrolled into a single straight line.
Public methodComputePointOnPath(Single)
Returns the point at the specified distance along the segments of the geometry.
Public methodComputePointOnPath(Single, Vector2)
Returns the point and tangent vector at the specified distance along the segments of the geometry.
Public methodComputePointOnPath(Single, Matrix3x2, Single, Vector2)
Returns the point and tangent vector at the specified distance along the segments of the geometry.
Public methodComputeStrokeBounds(Single)
Returns the bounds of a stroked area of this geometry, with the specified stroke width.
Public methodComputeStrokeBounds(Single, CanvasStrokeStyle)
Returns the bounds of a stroked area of this geometry, with the specified stroke width and stroke style.
Public methodComputeStrokeBounds(Single, CanvasStrokeStyle, Matrix3x2, Single)
Returns the bounds of a stroked area of this geometry, with the specified stroke width and stroke style.
Public methodStatic memberCreateCircle(ICanvasResourceCreator, Vector2, Single)
Creates a new circle geometry object with the specified extents.
Public methodStatic memberCreateCircle(ICanvasResourceCreator, Single, Single, Single)
Creates a new circle geometry object with the specified extents.
Public methodStatic memberCreateEllipse(ICanvasResourceCreator, Vector2, Single, Single)
Creates a new ellipse geometry object with the specified extents.
Public methodStatic memberCreateEllipse(ICanvasResourceCreator, Single, Single, Single, Single)
Creates a new ellipse geometry object with the specified extents.
Public methodStatic memberCreateGlyphRun
Creates a geometry based on a glyph run.
Public methodStatic memberCreateGroup(ICanvasResourceCreator, CanvasGeometry)
Returns a geometry containing the specified geometries, grouped together.
Public methodStatic memberCreateGroup(ICanvasResourceCreator, CanvasGeometry, CanvasFilledRegionDetermination)
Returns a geometry containing the specified geometries, grouped together.
Public methodStatic memberCreateInk(ICanvasResourceCreator, IEnumerableInkStroke)
Creates a geometry from a collection of ink strokes.
Public methodStatic memberCreateInk(ICanvasResourceCreator, IEnumerableInkStroke, Matrix3x2, Single)
Creates a geometry from a collection of ink strokes.
Public methodStatic memberCreatePath
Creates a new path geometry, populated with data from the specified path builder.
Public methodStatic memberCreatePolygon
Creates a new polygon geometry (triangle, quadrilateral, etc.), connecting the specified points.
Public methodStatic memberCreateRectangle(ICanvasResourceCreator, Rect)
Creates a new rectangle geometry object with the specified extents.
Public methodStatic memberCreateRectangle(ICanvasResourceCreator, Single, Single, Single, Single)
Creates a rectangular geometry primitive with the specified extents.
Public methodStatic memberCreateRoundedRectangle(ICanvasResourceCreator, Rect, Single, Single)
Creates a new rounded rectangle geometry object with the specified extents.
Public methodStatic memberCreateRoundedRectangle(ICanvasResourceCreator, Single, Single, Single, Single, Single, Single)
Creates a new rounded rectangle geometry object with the specified extents.
Public methodStatic memberCreateText
Creates a geometry based on a text layout.
Public methodDispose
Releases all resources used by the CanvasGeometry.
Public methodFillContainsPoint(Vector2)
Returns whether the area filled by the geometry contains the specified point.
Public methodFillContainsPoint(Vector2, Matrix3x2, Single)
Returns whether the area filled by the geometry contains the specified point.
Public methodOutline
Returns a geometry with equivalent fill, but no self-intersections, and figures are all oriented counterclockwise.
Public methodOutline(Matrix3x2, Single)
Returns a geometry with equivalent fill, but no self-intersections, and figures are all oriented counterclockwise.
Public methodSendPathTo
Sends all of this geometry's path data to an application-implemented interface.
Public methodSimplify(CanvasGeometrySimplification)
Returns a version of the geometry that contains only lines, and, optionally, cubic Bezier curves.
Public methodSimplify(CanvasGeometrySimplification, Matrix3x2, Single)
Returns a version of the geometry that contains only lines, and, optionally, cubic Bezier curves.
Public methodStroke(Single)
Returns a geometry equivalent to a stroked area of this geometry, with the specified stroke width and a default stroke style.
Public methodStroke(Single, CanvasStrokeStyle)
Returns a geometry equivalent to a stroked area of this geometry, with the specified stroke width and a default stroke style.
Public methodStroke(Single, CanvasStrokeStyle, Matrix3x2, Single)
Returns a geometry equivalent to a stroked area of this geometry, with the specified stroke width and a default stroke style.
Public methodStrokeContainsPoint(Vector2, Single)
Returns whether the stroked area of this geometry, with the specified stroke width and default stroke style, would contain the specified point.
Public methodStrokeContainsPoint(Vector2, Single, CanvasStrokeStyle)
Returns whether the stroked area of this geometry, with the specified stroke width and stroke style, would contain the specified point.
Public methodStrokeContainsPoint(Vector2, Single, CanvasStrokeStyle, Matrix3x2, Single)
Returns whether the stroked area of this geometry, with the specified stroke width and stroke style, would contain the specified point.
Public methodTessellate
Returns an array of clockwise-wound triangles that cover the geometry.
Public methodTessellate(Matrix3x2, Single)
Returns an array of clockwise-wound triangles that cover the geometry after it has been transformed using the specified matrix and flattened using the specified tolerance.
Public methodTransform
Returns a transformed version of this geometry.
Top
Remarks

A geometry is an arbitrary 2-D area, and a means of representing geometric shapes. It may consist of lines, polygons with multiple segments, bezier curves, or any number of open or closed figures comprised of these. There aren't any limits on how complex a geometry can be. It can be zero-sized, consist of one point, or be arbitrarily complex.

A geometry object can be drawn using CanvasDrawingSession's DrawGeometry Overload or FillGeometry Overload.

Geometry objects can be manipulated using methods like CombineWith Overload or Stroke Overload.

Some primitives that can be created using static CanvasGeometry methods, such as Rectangle, may also be drawn straightforwardly through CanvasDrawingSession's methods. In fact, for simple cases, CanvasDrawingSession's methods are recommended.

Complex geometries, sometimes those created through CanvasGeometry.CreatePath, can be costly to draw. It may be worth paying a one-time, up-front performance cost for a less expensive draw-time cost. To do this, consider using CanvasCachedGeometry.

When using Direct2D interop, this Win2D class corresponds to the Direct2D interface ID2D1Geometry. Depending on how the CanvasGeometry was created, its underlying Direct2D resource will also implement one of the derived interfaces ID2D1PathGeometry, ID2D1RectangleGeometry, ID2D1RoundedRectangleGeometry, ID2D1EllipseGeometry, ID2D1TransformedGeometry, or ID2D1GeometryGroup.

See Also