Class Path2D

Class Path2D

Namespace: Aspose.Html.Dom.Canvas
Assembly: Aspose.HTML.dll (25.2.0)

The Path2D interface of the Canvas 2D API is used to declare paths that are then later used on CanvasRenderingContext2D objects. The path methods of the CanvasRenderingContext2D interface are present on this interface as well and are allowing you to create paths that you can retain and replay as required on a canvas.

[DOMObject]
[DOMName("Path2D")]
[ComVisible(true)]
public class Path2D : DOMObject, INotifyPropertyChanged, ICanvasPathMethods, IDisposable

Inheritance

objectDOMObjectPath2D

Implements

INotifyPropertyChanged, ICanvasPathMethods, IDisposable

Inherited Members

DOMObject.GetPlatformType(), object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Constructors

Path2D()

returns a newly instantiated Path2D object

[DOMConstructor]
public Path2D()

Path2D(Path2D)

returns a newly instantiated Path2D object with another path as an argument (creates a copy)

[DOMConstructor]
public Path2D(Path2D path)

Parameters

path Path2D

When invoked with another Path2D object, a copy of the path argument is created

Path2D(string)

returns a newly instantiated Path2D object with a string consisting of SVG path data.

[DOMConstructor]
public Path2D(string d)

Parameters

d string

The string consisting of SVG path data

Methods

AddPath(Path2D)

Adds to the path the path given by the argument.

[DOMName("addPath")]
public void AddPath(Path2D path)

Parameters

path Path2D

A Path2D path to add.

AddPath(Path2D, SVGMatrix)

Adds to the path the path given by the argument.

[DOMName("addPath")]
public void AddPath(Path2D path, SVGMatrix transformation)

Parameters

path Path2D

A Path2D path to add.

transformation SVGMatrix

An SVGMatrix to be used as the transformation matrix for the path that is added.

Arc(double, double, double, double, double)

Adds an arc to the path which is centered at (x, y) position with radius r starting at startAngle and ending at endAngle going in the given direction by anticlockwise (defaulting to clockwise).

public void Arc(double x, double y, double radius, double startAngle, double endAngle)

Parameters

x double

The x coordinate of the arc’s center.

y double

The y coordinate of the arc’s center.

radius double

The arc’s radius.

startAngle double

The angle at which the arc starts, measured clockwise from the positive x axis and expressed in radians.

endAngle double

The angle at which the arc ends, measured clockwise from the positive x axis and expressed in radians.

Arc(double, double, double, double, double, bool)

Adds an arc to the path which is centered at (x, y) position with radius r starting at startAngle and ending at endAngle going in the given direction by anticlockwise (defaulting to clockwise).

public void Arc(double x, double y, double radius, double startAngle, double endAngle, bool counterclockwise)

Parameters

x double

The x coordinate of the arc’s center.

y double

The y coordinate of the arc’s center.

radius double

The arc’s radius.

startAngle double

The angle at which the arc starts, measured clockwise from the positive x axis and expressed in radians.

endAngle double

The angle at which the arc ends, measured clockwise from the positive x axis and expressed in radians.

counterclockwise bool

Causes the arc to be drawn counter-clockwise between the two angles. By default it is drawn clockwise.

ArcTo(double, double, double, double, double)

Adds an arc to the path with the given control points and radius, connected to the previous point by a straight line.

public void ArcTo(double x1, double y1, double x2, double y2, double radius)

Parameters

x1 double

x-axis coordinates for the first control point.

y1 double

y-axis coordinates for the first control point.

x2 double

x-axis coordinates for the second control point.

y2 double

y-axis coordinates for the second control point.

radius double

The arc’s radius.

BezierCurveTo(double, double, double, double, double, double)

Adds a cubic Bézier curve to the path. It requires three points. The first two points are control points and the third one is the end point. The starting point is the last point in the current path, which can be changed using moveTo() before creating the Bézier curve.

public void BezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y)

Parameters

cp1x double

The x axis of the coordinate for the first control point.

cp1y double

The y axis of the coordinate for the first control point.

cp2x double

The x axis of the coordinate for the second control point.

cp2y double

The y axis of the coordinate for the second control point.

x double

The x axis of the coordinate for the end point.

y double

The y axis of the coordinate for the end point.

ClosePath()

Causes the point of the pen to move back to the start of the current sub-path. It tries to draw a straight line from the current point to the start. If the shape has already been closed or has only one point, this function does nothing.

public void ClosePath()

Dispose()

Disposes object.

public void Dispose()

Ellipse(double, double, double, double, double, double, double)

Adds an ellipse to the path which is centered at (x, y) position with the radii radiusX and radiusY starting at startAngle and ending at endAngle going in the given direction by anticlockwise (defaulting to clockwise).

public void Ellipse(double x, double y, double radiusX, double radiusY, double rotation, double startAngle, double endAngle)

Parameters

x double

The x axis of the coordinate for the ellipse’s center.

y double

The y axis of the coordinate for the ellipse’s center.

radiusX double

The ellipse’s major-axis radius.

radiusY double

The ellipse’s minor-axis radius.

rotation double

The rotation for this ellipse, expressed in radians.

startAngle double

The starting point, measured from the x axis, from which it will be drawn, expressed in radians.

endAngle double

The end ellipse’s angle to which it will be drawn, expressed in radians.

Ellipse(double, double, double, double, double, double, double, bool)

Adds an ellipse to the path which is centered at (x, y) position with the radii radiusX and radiusY starting at startAngle and ending at endAngle going in the given direction by anticlockwise (defaulting to clockwise).

public void Ellipse(double x, double y, double radiusX, double radiusY, double rotation, double startAngle, double endAngle, bool anticlockwise)

Parameters

x double

The x axis of the coordinate for the ellipse’s center.

y double

The y axis of the coordinate for the ellipse’s center.

radiusX double

The ellipse’s major-axis radius.

radiusY double

The ellipse’s minor-axis radius.

rotation double

The rotation for this ellipse, expressed in radians.

startAngle double

The starting point, measured from the x axis, from which it will be drawn, expressed in radians.

endAngle double

The end ellipse’s angle to which it will be drawn, expressed in radians.

anticlockwise bool

An optional boolean which, if true, draws the ellipse anticlockwise (counter-clockwise), otherwise in a clockwise direction.

LineTo(double, double)

Connects the last point in the subpath to the x, y coordinates with a straight line.

public void LineTo(double x, double y)

Parameters

x double

The x axis of the coordinate for the end of the line.

y double

The y axis of the coordinate for the end of the line.

MoveTo(double, double)

Moves the starting point of a new sub-path to the (x, y) coordinates.

public void MoveTo(double x, double y)

Parameters

x double

The x axis of the point

y double

The y axis of the point

QuadraticCurveTo(double, double, double, double)

Adds a quadratic Bézier curve to the current path.

public void QuadraticCurveTo(double cpx, double cpy, double x, double y)

Parameters

cpx double

The x axis of the coordinate for the control point.

cpy double

The y axis of the coordinate for the control point.

x double

The x axis of the coordinate for the end point.

y double

The y axis of the coordinate for the end point.

Rect(double, double, double, double)

Creates a path for a rectangle at position (x, y) with a size that is determined by width and height.

public void Rect(double x, double y, double w, double h)

Parameters

x double

The x axis of the coordinate for the rectangle starting point.

y double

The y axis of the coordinate for the rectangle starting point.

w double

The rectangle’s width.

h double

The rectangle’s height.