Package ej.microvg

Class Path


  • public class Path
    extends Object
    Represents a geometric paths consisting of straight line segments, quadratic curves, and cubic curves.
    • Constructor Summary

      Constructors 
      Constructor Description
      Path()
      Creates an empty path.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes the current contour.
      void cubicTo​(float x1, float y1, float x2, float y2, float x3, float y3)
      Adds a cubic bezier from the last point, approaching control points (x1,y1) and (x2,y2), and ending at (x3,y3).
      void cubicToRelative​(float dx1, float dy1, float dx2, float dy2, float dx3, float dy3)
      Same as cubicTo(float, float, float, float, float, float), but the coordinates are considered relative to the current point on this contour.
      float getBottomBound()
      Gets the bottom bound of this path.
      float getLeftBound()
      Gets the left bound of this path.
      float getRightBound()
      Gets the right bound of this path.
      float getTopBound()
      Gets the top bound of this path.
      void lineTo​(float x, float y)
      Adds a line from the last point to the specified point (x,y).
      void lineToRelative​(float dx, float dy)
      Same as lineTo(float, float), but the coordinates are considered relative to the last point on this contour.
      void moveTo​(float x, float y)
      Sets the beginning of the next contour to the point (x,y).
      void moveToRelative​(float dx, float dy)
      Sets the beginning of the next contour relative to the last point on the previous contour.
      void quadTo​(float x1, float y1, float x2, float y2)
      Adds a quadratic bezier from the last point, approaching control point (x1,y1), and ending at (x2,y2).
      void quadToRelative​(float dx1, float dy1, float dx2, float dy2)
      Same as quadTo(float, float, float, float), but the coordinates are considered relative to the last point on this contour.
      void reset()
      Resets the path to an empty one.
      void setOrigin​(float dx, float dy)
      Sets the offset that will be applied to all the subsequent absolute points of the contour.
    • Constructor Detail

      • Path

        public Path()
        Creates an empty path.

        The origin is set to (0,0).

    • Method Detail

      • reset

        public void reset()
        Resets the path to an empty one.

        The origin is also reset to (0,0).

      • moveTo

        public void moveTo​(float x,
                           float y)
        Sets the beginning of the next contour to the point (x,y).
        Parameters:
        x - the x-coordinate of the start of a new contour
        y - the y-coordinate of the start of a new contour
      • moveToRelative

        public void moveToRelative​(float dx,
                                   float dy)
        Sets the beginning of the next contour relative to the last point on the previous contour. If there is no previous contour, this is treated the same as moveTo(float, float).
        Parameters:
        dx - the amount to add to the x-coordinate of the end of the previous contour, to specify the start of a new contour
        dy - the amount to add to the y-coordinate of the end of the previous contour, to specify the start of a new contour
      • lineTo

        public void lineTo​(float x,
                           float y)
        Adds a line from the last point to the specified point (x,y). If no moveTo(float, float) call has been made for this contour, the first point is automatically set to (0,0).
        Parameters:
        x - the x-coordinate of the end of a line
        y - the y-coordinate of the end of a line
      • lineToRelative

        public void lineToRelative​(float dx,
                                   float dy)
        Same as lineTo(float, float), but the coordinates are considered relative to the last point on this contour. If there is no previous point, then a moveTo(0,0) is inserted automatically.
        Parameters:
        dx - the amount to add to the x-coordinate of the previous point on this contour, to specify a line
        dy - the amount to add to the y-coordinate of the previous point on this contour, to specify a line
      • quadTo

        public void quadTo​(float x1,
                           float y1,
                           float x2,
                           float y2)
        Adds a quadratic bezier from the last point, approaching control point (x1,y1), and ending at (x2,y2). If no moveTo(float, float) call has been made for this contour, the first point is automatically set to (0,0).
        Parameters:
        x1 - the x-coordinate of the control point on a quadratic curve
        y1 - the y-coordinate of the control point on a quadratic curve
        x2 - the x-coordinate of the end point on a quadratic curve
        y2 - the y-coordinate of the end point on a quadratic curve
      • quadToRelative

        public void quadToRelative​(float dx1,
                                   float dy1,
                                   float dx2,
                                   float dy2)
        Same as quadTo(float, float, float, float), but the coordinates are considered relative to the last point on this contour. If there is no previous point, then a moveTo(0,0) is inserted automatically.
        Parameters:
        dx1 - the amount to add to the x-coordinate of the last point on this contour, for the control point of a quadratic curve
        dy1 - the amount to add to the y-coordinate of the last point on this contour, for the control point of a quadratic curve
        dx2 - the amount to add to the x-coordinate of the last point on this contour, for the end point of a quadratic curve
        dy2 - the amount to add to the y-coordinate of the last point on this contour, for the end point of a quadratic curve
      • cubicTo

        public void cubicTo​(float x1,
                            float y1,
                            float x2,
                            float y2,
                            float x3,
                            float y3)
        Adds a cubic bezier from the last point, approaching control points (x1,y1) and (x2,y2), and ending at (x3,y3). If no moveTo(float, float) call has been made for this contour, the first point is automatically set to (0,0).
        Parameters:
        x1 - the x-coordinate of the 1st control point on a cubic curve
        y1 - the y-coordinate of the 1st control point on a cubic curve
        x2 - the x-coordinate of the 2nd control point on a cubic curve
        y2 - the y-coordinate of the 2nd control point on a cubic curve
        x3 - the x-coordinate of the end point on a cubic curve
        y3 - the y-coordinate of the end point on a cubic curve
      • cubicToRelative

        public void cubicToRelative​(float dx1,
                                    float dy1,
                                    float dx2,
                                    float dy2,
                                    float dx3,
                                    float dy3)
        Same as cubicTo(float, float, float, float, float, float), but the coordinates are considered relative to the current point on this contour. If there is no previous point, then a moveTo(0,0) is inserted automatically.
        Parameters:
        dx1 - the x-coordinate of the 1st control point on a cubic curve
        dy1 - the y-coordinate of the 1st control point on a cubic curve
        dx2 - the x-coordinate of the 2nd control point on a cubic curve
        dy2 - the y-coordinate of the 2nd control point on a cubic curve
        dx3 - the x-coordinate of the end point on a cubic curve
        dy3 - the y-coordinate of the end point on a cubic curve
      • close

        public void close()
        Closes the current contour. If the current point is not equal to the first point of the contour, a line segment is automatically added.
      • setOrigin

        public void setOrigin​(float dx,
                              float dy)
        Sets the offset that will be applied to all the subsequent absolute points of the contour.
        Parameters:
        dx - the amount in the x direction to offset the subsequent points
        dy - the amount in the y direction to offset the subsequent points
      • getLeftBound

        public float getLeftBound()
        Gets the left bound of this path.

        If this path does not contain any point, all bounds are equal to 0.

        Returns:
        the left bound of this path
      • getRightBound

        public float getRightBound()
        Gets the right bound of this path.

        If this path does not contain any point, all bounds are equal to 0.

        Returns:
        the right bound of this path
      • getTopBound

        public float getTopBound()
        Gets the top bound of this path.

        If this path does not contain any point, all bounds are equal to 0.

        Returns:
        the top bound of this path
      • getBottomBound

        public float getBottomBound()
        Gets the bottom bound of this path.

        If this path does not contain any point, all bounds are equal to 0.

        Returns:
        the bottom bound of this path