com.aspose.html.dom.canvas

Class Path2D

  • All Implemented Interfaces:
    ICanvasPathMethods, com.aspose.ms.System.IDisposable


    @DOMObjectAttribute
     @DOMNameAttribute(name="Path2D")
    public class Path2D
    extends DOMObject
    implements ICanvasPathMethods, com.aspose.ms.System.IDisposable

    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.

    • Constructor Summary

      Constructors 
      Constructor and Description
      Path2D()
      returns a newly instantiated Path2D object
      Path2D(Path2D path)
      returns a newly instantiated Path2D object with another path as an argument (creates a copy)
      Path2D(java.lang.String d)
      returns a newly instantiated Path2D object with a string consisting of SVG path data.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void addPath(Path2D path, SVGMatrix transformation)
      Adds to the path the path given by the argument.
      void arc(double x, double y, double radius, double startAngle, double endAngle)
      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).
      void arc(double x, double y, double radius, double startAngle, double endAngle, boolean counterclockwise)
      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).
      void arcTo(double x1, double y1, double x2, double y2, double radius)
      Adds an arc to the path with the given control points and radius, connected to the previous point by a straight line.
      void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y)
      Adds a cubic Bézier curve to the path.
      void closePath()
      Causes the point of the pen to move back to the start of the current sub-path.
      void dispose()
      Disposes object.
      void ellipse(double x, double y, double radiusX, double radiusY, double rotation, double startAngle, double endAngle)
      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).
      void ellipse(double x, double y, double radiusX, double radiusY, double rotation, double startAngle, double endAngle, boolean anticlockwise)
      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).
      com.aspose.ms.System.Drawing.Drawing2D.GraphicsPath getPath() 
      void lineTo(double x, double y)
      Connects the last point in the subpath to the x, y coordinates with a straight line.
      void moveTo(double x, double y)
      Moves the starting point of a new sub-path to the (x, y) coordinates.
      void quadraticCurveTo(double cpx, double cpy, double x, double y)
      Adds a quadratic Bézier curve to the current path.
      void rect(double x, double y, double w, double h)
      Creates a path for a rectangle at position (x, y) with a size that is determined by width and height.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Path2D

        public Path2D()

        returns a newly instantiated Path2D object

      • Path2D

        public Path2D(Path2D path)

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

        Parameters:
        path - When invoked with another Path2D object, a copy of the path argument is created
      • Path2D

        public Path2D(java.lang.String d)

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

        Parameters:
        d - The string consisting of SVG path data
    • Method Detail

      • getPath

        public com.aspose.ms.System.Drawing.Drawing2D.GraphicsPath getPath()
      • addPath

        @DOMNameAttribute(name="addPath")
        public void addPath(Path2D path,
                                                              @DOMParameterAttribute(name="transformation",optional=true)
                                                              SVGMatrix transformation)

        Adds to the path the path given by the argument.

        Parameters:
        path - A Path2D path to add.
        transformation - An SVGMatrix to be used as the transformation matrix for the path that is added.
      • closePath

        public void 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.

        Specified by:
        closePath in interface ICanvasPathMethods
      • moveTo

        public void moveTo(double x,
                           double y)

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

        Specified by:
        moveTo in interface ICanvasPathMethods
        Parameters:
        x - The x axis of the point
        y - The y axis of the point
      • lineTo

        public void lineTo(double x,
                           double y)

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

        Specified by:
        lineTo in interface ICanvasPathMethods
        Parameters:
        x - The x axis of the coordinate for the end of the line.
        y - The y axis of the coordinate for the end of the line.
      • quadraticCurveTo

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

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

        Specified by:
        quadraticCurveTo in interface ICanvasPathMethods
        Parameters:
        cpx - The x axis of the coordinate for the control point.
        cpy - The y axis of the coordinate for the control point.
        x - The x axis of the coordinate for the end point.
        y - The y axis of the coordinate for the end point.
      • bezierCurveTo

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

        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.

        Specified by:
        bezierCurveTo in interface ICanvasPathMethods
        Parameters:
        cp1x - The x axis of the coordinate for the first control point.
        cp1y - The y axis of the coordinate for the first control point.
        cp2x - The x axis of the coordinate for the second control point.
        cp2y - The y axis of the coordinate for the second control point.
        x - The x axis of the coordinate for the end point.
        y - The y axis of the coordinate for the end point.
      • arcTo

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

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

        Specified by:
        arcTo in interface ICanvasPathMethods
        Parameters:
        x1 - x-axis coordinates for the first control point.
        y1 - y-axis coordinates for the first control point.
        x2 - x-axis coordinates for the second control point.
        y2 - y-axis coordinates for the second control point.
        radius - The arc's radius.
      • rect

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

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

        Specified by:
        rect in interface ICanvasPathMethods
        Parameters:
        x - The x axis of the coordinate for the rectangle starting point.
        y - The y axis of the coordinate for the rectangle starting point.
        w - The rectangle's width.
        h - The rectangle's height.
      • arc

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

        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).

        Specified by:
        arc in interface ICanvasPathMethods
        Parameters:
        x - The x coordinate of the arc's center.
        y - The y coordinate of the arc's center.
        radius - The arc's radius.
        startAngle - The angle at which the arc starts, measured clockwise from the positive x axis and expressed in radians.
        endAngle - The angle at which the arc ends, measured clockwise from the positive x axis and expressed in radians.
      • arc

        public void arc(double x,
                        double y,
                        double radius,
                        double startAngle,
                        double endAngle,
                        @DOMParameterAttribute(name="counterclockwise",optional=true)
                        boolean counterclockwise)

        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).

        Specified by:
        arc in interface ICanvasPathMethods
        Parameters:
        x - The x coordinate of the arc's center.
        y - The y coordinate of the arc's center.
        radius - The arc's radius.
        startAngle - The angle at which the arc starts, measured clockwise from the positive x axis and expressed in radians.
        endAngle - The angle at which the arc ends, measured clockwise from the positive x axis and expressed in radians.
        counterclockwise - Causes the arc to be drawn counter-clockwise between the two angles. By default it is drawn clockwise.
      • ellipse

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

        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).

        Specified by:
        ellipse in interface ICanvasPathMethods
        Parameters:
        x - The x axis of the coordinate for the ellipse's center.
        y - The y axis of the coordinate for the ellipse's center.
        radiusX - The ellipse's major-axis radius.
        radiusY - The ellipse's minor-axis radius.
        rotation - The rotation for this ellipse, expressed in radians.
        startAngle - The starting point, measured from the x axis, from which it will be drawn, expressed in radians.
        endAngle - The end ellipse's angle to which it will be drawn, expressed in radians.
      • ellipse

        public void ellipse(double x,
                            double y,
                            double radiusX,
                            double radiusY,
                            double rotation,
                            double startAngle,
                            double endAngle,
                            boolean anticlockwise)

        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).

        Specified by:
        ellipse in interface ICanvasPathMethods
        Parameters:
        x - The x axis of the coordinate for the ellipse's center.
        y - The y axis of the coordinate for the ellipse's center.
        radiusX - The ellipse's major-axis radius.
        radiusY - The ellipse's minor-axis radius.
        rotation - The rotation for this ellipse, expressed in radians.
        startAngle - The starting point, measured from the x axis, from which it will be drawn, expressed in radians.
        endAngle - The end ellipse's angle to which it will be drawn, expressed in radians.
        anticlockwise - An optional boolean which, if true, draws the ellipse anticlockwise (counter-clockwise), otherwise in a clockwise direction.
      • dispose

        public void dispose()

        Disposes object.

        Specified by:
        dispose in interface com.aspose.ms.System.IDisposable