Package ej.drawing

## Class ShapePainter

- java.lang.Object
- - ej.drawing.ShapePainter

-     public class ShapePainter
      extends Object

  The `ShapePainter` class offers a set of static methods to render thick shapes (with or without anti-aliasing) and polygons.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static class` | `ShapePainter.Cap` | Defines the cap representation when drawing a line or a circle arc.

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ShapePainter()` |

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static void` | `drawPolygon​(GraphicsContext gc, int[] xys)` | Draws the closed polygon which is defined by the array of integer coordinates, using the current color.
    `static void` | `drawPolygon​(GraphicsContext gc, int[] xys, int offset, int length)` | Draws the closed polygon which is defined by the array of integer coordinates, using the current color.
    `static void` | `drawThickCircle​(GraphicsContext gc, int x, int y, int diameter, int thickness)` | Draws the outline of a circle covering the square specified by its diameter, using the `GraphicsContext` 's current color. The center of the circle is defined as the center of the square whose origin is at `(x,y)` (upper-left corner) and whose dimension is given by `diameter`. If `diameter` is negative, nothing is drawn.
    `static void` | `drawThickCircleArc​(GraphicsContext gc, int x, int y, int diameter, float startAngle, float arcAngle, int thickness)` | Draws the outline of a circular arc covering the specified square, using the `GraphicsContext` 's current color. The arc is drawn from `startAngle` up to `arcAngle` degrees.
    `static void` | `drawThickEllipse​(GraphicsContext gc, int x, int y, int width, int height, int thickness)` | Draws the outline of a ellipse covering the specified rectangle, using the `GraphicsContext`'s current color. The center of the ellipse is defined as the center of the rectangle whose origin is at `(x,y)` (upper-left corner) and whose dimension is given by `width` and `height`. If either `width` or `height` is negative or zero, nothing is drawn.
    `static void` | `drawThickFadedCircle​(GraphicsContext gc, int x, int y, int diameter, int thickness, int fade)` | Draws the faded outline of a circle covering the square specified by its diameter, using the `GraphicsContext` 's current color. The center of the circle is defined as the center of the square whose origin is at `(x,y)` (upper-left corner) and whose dimension is given by `diameter`. If `diameter` is negative or zero, nothing is drawn.
    `static void` | `drawThickFadedCircleArc​(GraphicsContext gc, int x, int y, int diameter, float startAngle, float arcAngle, int thickness, int fade, ShapePainter.Cap startCap, ShapePainter.Cap endCap)` | Draws the faded outline of a circular arc covering the specified square, using the current color and caps.
    `static void` | `drawThickFadedEllipse​(GraphicsContext gc, int x, int y, int width, int height, int thickness, int fade)` | Draws the outline of a ellipse covering the specified rectangle, using the `GraphicsContext`'s current color. The center of the ellipse is defined as the center of the rectangle whose origin is at `(x,y)` (upper-left corner) and whose dimension is given by `width` and `height`. If either `width` or `height` is negative or zero, nothing is drawn.
    `static void` | `drawThickFadedLine​(GraphicsContext gc, int startX, int startY, int endX, int endY, int thickness, int fade, ShapePainter.Cap startCap, ShapePainter.Cap endCap)` | Draws a faded line from `(x1,y1)` to `(x2,y2)` using the `GraphicsContext`'s current color and caps.
    `static void` | `drawThickFadedPoint​(GraphicsContext gc, int x, int y, int thickness, int fade)` | Draws a faded point at `(x,y)` using the `GraphicsContext`'s current color.
    `static void` | `drawThickLine​(GraphicsContext gc, int startX, int startY, int endX, int endY, int thickness)` | Draws a line from `(x1,y1)` to `(x2,y2)` using the `GraphicsContext`'s current color.
    `static void` | `fillPolygon​(GraphicsContext gc, int[] xys)` | Fills the closed polygon which is defined by the array of integer coordinates, using the current color.
    `static void` | `fillPolygon​(GraphicsContext gc, int[] xys, int offset, int length)` | Fills the closed polygon which is defined by the array of integer coordinates, using the current color.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ShapePainter

          public ShapePainter()

  - ### Method Detail

    - #### drawThickFadedPoint

          public static void drawThickFadedPoint​(GraphicsContext gc,
                                                 int x,
                                                 int y,
                                                 int thickness,
                                                 int fade)

      Draws a faded point at `(x,y)` using the `GraphicsContext`'s current color.

      The shape's bounding box is `(x - thickness / 2 - fade, y - thickness / 2 - fade) to (x + thickness / 2 + fade, y + thickness / 2 + fade)`.

      Parameters:
        `gc` - the graphics context where render the drawing.
        `x` - the x coordinate of the point
        `y` - the y coordinate of the point
        `thickness` - the thickness to apply.
        `fade` - the fade to apply.
      Throws:
        `IllegalArgumentException` - when given thickness is negative

    - #### drawThickLine

          public static void drawThickLine​(GraphicsContext gc,
                                           int startX,
                                           int startY,
                                           int endX,
                                           int endY,
                                           int thickness)

      Draws a line from `(x1,y1)` to `(x2,y2)` using the `GraphicsContext`'s current color.

      The rendering is aliased but the rendering time is often faster than `drawThickFadedLine(GraphicsContext, int, int, int, int, int, int, Cap, Cap)`.

      Equivalent to calling `drawThickFadedLine(GraphicsContext, int, int, int, int, int, int, Cap, Cap)` with a fade equals to 0 and `ShapePainter.Cap.NONE` for caps.

      The shape's bounding box is `(min(startX, endX) - thickness / 2, min(startY, endY) - thickness / 2) to (max(startX, endX) + thickness / 2, max(startY, endY) + thickness / 2)`.

      Parameters:
        `gc` - the graphics context where render the drawing.
        `startX` - the x coordinate of the start of the line.
        `startY` - the y coordinate of the start of the line.
        `endX` - the x coordinate of the end of the line.
        `endY` - the y coordinate of the end of the line.
        `thickness` - the thickness to apply.
      Throws:
        `IllegalArgumentException` - when given thickness is negative

    - #### drawThickFadedLine

          public static void drawThickFadedLine​(GraphicsContext gc,
                                                int startX,
                                                int startY,
                                                int endX,
                                                int endY,
                                                int thickness,
                                                int fade,
                                                ShapePainter.Cap startCap,
                                                ShapePainter.Cap endCap)

      Draws a faded line from `(x1,y1)` to `(x2,y2)` using the `GraphicsContext`'s current color and caps.

      The shape's bounding box is `(min(startX, endX) - thickness / 2 - fade, min(startY, endY) - thickness / 2 - fade) to (max(startX, endX) + thickness / 2 + fade, max(startY, endY) + thickness / 2 + fade)`.

      Parameters:
        `gc` - the graphics context where render the drawing.
        `startX` - the x coordinate of the start of the line
        `startY` - the y coordinate of the start of the line
        `endX` - the x coordinate of the end of the line
        `endY` - the y coordinate of the end of the line
        `thickness` - the thickness to apply.
        `fade` - the fade to apply.
        `startCap` - the cap to draw on (x1,y1).
        `endCap` - the cap to draw on (x2,y2).
      Throws:
        `IllegalArgumentException` - when given thickness or fade is negative

    - #### drawThickCircleArc

          public static void drawThickCircleArc​(GraphicsContext gc,
                                                int x,
                                                int y,
                                                int diameter,
                                                float startAngle,
                                                float arcAngle,
                                                int thickness)

      Draws the outline of a circular arc covering the specified square, using the `GraphicsContext` 's current color.
      The arc is drawn from `startAngle` up to `arcAngle` degrees. The center of the arc is defined as the center of the square whose origin is at `(x,y)` (upper-left corner) and whose dimension is given by `diameter`.
      Angles are interpreted such that 0 degrees is at the 3 o'clock position. A positive value indicates a counter-clockwise rotation while a negative value indicates a clockwise rotation.
      If `diameter` is negative, nothing is drawn.

      The rendering is aliased but the rendering time is often faster than `drawThickFadedCircleArc(GraphicsContext, int, int, int, float, float, int, int, Cap, Cap)`.

      Equivalent to calling `drawThickFadedCircleArc(GraphicsContext, int, int, int, float, float, int, int, Cap, Cap)` with a fade equals to 0 and `ShapePainter.Cap.NONE` for caps.

      The shape's bounding box is (when arcAngle is 360°): `(x - thickness / 2, y - thickness / 2) to (x + diameter + thickness / 2, y + diameter + thickness / 2)`.

      Parameters:
        `gc` - the graphics context where render the drawing.
        `x` - the x coordinate of the upper-left corner of the square where the arc is drawn.
        `y` - the y coordinate of the upper-left corner of the square where the arc is drawn.
        `diameter` - the diameter of the arc to draw.
        `startAngle` - the beginning angle of the arc to draw.
        `arcAngle` - the angular extent of the arc from `startAngle`.
        `thickness` - the thickness to apply.
      Throws:
        `IllegalArgumentException` - when given thickness is negative

    - #### drawThickFadedCircleArc

          public static void drawThickFadedCircleArc​(GraphicsContext gc,
                                                     int x,
                                                     int y,
                                                     int diameter,
                                                     float startAngle,
                                                     float arcAngle,
                                                     int thickness,
                                                     int fade,
                                                     ShapePainter.Cap startCap,
                                                     ShapePainter.Cap endCap)

      Draws the faded outline of a circular arc covering the specified square, using the current color and caps.
      The arc is drawn from `startAngle` up to `arcAngle` degrees. The center of the arc is defined as the center of the square whose origin is at `(x,y)` (upper-left corner) and whose dimension is given by `diameter`.
      Angles are interpreted such that 0 degrees is at the 3 o'clock position. A positive value indicates a counter-clockwise rotation while a negative value indicates a clockwise rotation.
      If `diameter` is negative or zero, nothing is drawn.
      The angles are given relative to the square. For instance an angle of 45 degrees is always defined by the line from the center of the square to the upper right corner of the square. Thus for a non squared square angles are skewed along either height or width.

      The shape's bounding box is (when arcAngle is 360°): `(x - thickness / 2 - fade, y - thickness / 2 - fade) to (x + diameter + thickness / 2 + fade, y + diameter + thickness / 2 + fade)`.

      Parameters:
        `gc` - the graphics context where render the drawing.
        `x` - the x coordinate of the upper-left corner of the square where the arc is drawn
        `y` - the y coordinate of the upper-left corner of the square where the arc is drawn
        `diameter` - the diameter of the arc to draw
        `startAngle` - the beginning angle of the arc to draw
        `arcAngle` - the angular extent of the arc from `startAngle`
        `thickness` - the thickness to apply.
        `fade` - the fade to apply.
        `startCap` - the cap to draw at startAngle.
        `endCap` - the cap to draw at startAngle + arcAngle.
      Throws:
        `IllegalArgumentException` - when given thickness or fade is negative

    - #### drawThickCircle

          public static void drawThickCircle​(GraphicsContext gc,
                                             int x,
                                             int y,
                                             int diameter,
                                             int thickness)

      Draws the outline of a circle covering the square specified by its diameter, using the `GraphicsContext` 's current color.
      The center of the circle is defined as the center of the square whose origin is at `(x,y)` (upper-left corner) and whose dimension is given by `diameter`.
      If `diameter` is negative, nothing is drawn.

      The rendering is aliased but the rendering time is often faster than `drawThickFadedCircle(GraphicsContext, int, int, int, int, int)`.

      Equivalent to calling `drawThickFadedCircle(GraphicsContext, int, int, int, int, int)` with a fade equals to 0.

      The shape's bounding box is `(x - thickness / 2, y - thickness / 2) to (x + diameter + thickness / 2, y + diameter + thickness / 2)`.

      Parameters:
        `gc` - the graphics context where render the drawing.
        `x` - the x coordinate of the upper-left corner of the square where the circle is drawn.
        `y` - the y coordinate of the upper-left corner of the square where the circle is drawn.
        `diameter` - the diameter of the circle to draw.
        `thickness` - the thickness to apply.
      Throws:
        `IllegalArgumentException` - when given thickness is negative

    - #### drawThickFadedCircle

          public static void drawThickFadedCircle​(GraphicsContext gc,
                                                  int x,
                                                  int y,
                                                  int diameter,
                                                  int thickness,
                                                  int fade)

      Draws the faded outline of a circle covering the square specified by its diameter, using the `GraphicsContext` 's current color.
      The center of the circle is defined as the center of the square whose origin is at `(x,y)` (upper-left corner) and whose dimension is given by `diameter`.
      If `diameter` is negative or zero, nothing is drawn.

      The shape's bounding box is `(x - thickness / 2 - fade, y - thickness / 2 - fade) to (x + diameter + thickness / 2 + fade, y + diameter + thickness / 2 + fade)`.

      Parameters:
        `gc` - the graphics context where render the drawing.
        `x` - the x coordinate of the upper-left corner of the square where the circle is drawn
        `y` - the y coordinate of the upper-left corner of the square where the circle is drawn
        `diameter` - the diameter of the circle to draw
        `thickness` - the thickness to apply.
        `fade` - the fade to apply.
      Throws:
        `IllegalArgumentException` - when given thickness or fade is negative

    - #### drawThickEllipse

          public static void drawThickEllipse​(GraphicsContext gc,
                                              int x,
                                              int y,
                                              int width,
                                              int height,
                                              int thickness)

      Draws the outline of a ellipse covering the specified rectangle, using the `GraphicsContext`'s current color.
      The center of the ellipse is defined as the center of the rectangle whose origin is at `(x,y)` (upper-left corner) and whose dimension is given by `width` and `height`.
      If either `width` or `height` is negative or zero, nothing is drawn.

      The rendering is aliased but the rendering time is often faster than `drawThickFadedEllipse(GraphicsContext, int, int, int, int, int, int)`.

      Equivalent to calling `drawThickFadedEllipse(GraphicsContext, int, int, int, int, int, int)` with a fade equals to 0.

      The shape's bounding box is `(x - thickness / 2, y - thickness / 2) to (x + width + thickness / 2, y + height + thickness / 2)`.

      Parameters:
        `gc` - the graphics context where render the drawing.
        `x` - the x coordinate of the upper-left corner of the rectangle where the ellipse is drawn
        `y` - the y coordinate of the upper-left corner of the rectangle where the ellipse is drawn
        `width` - the width of the ellipse to draw
        `height` - the height of the ellipse to draw
        `thickness` - the thickness to apply.
      Throws:
        `IllegalArgumentException` - when given thickness is negative

    - #### drawThickFadedEllipse

          public static void drawThickFadedEllipse​(GraphicsContext gc,
                                                   int x,
                                                   int y,
                                                   int width,
                                                   int height,
                                                   int thickness,
                                                   int fade)

      Draws the outline of a ellipse covering the specified rectangle, using the `GraphicsContext`'s current color.
      The center of the ellipse is defined as the center of the rectangle whose origin is at `(x,y)` (upper-left corner) and whose dimension is given by `width` and `height`.
      If either `width` or `height` is negative or zero, nothing is drawn.

      The shape's bounding box is `(x - thickness / 2 - fade, y - thickness / 2 - fade) to (x + width + thickness / 2 + fade, y + height + thickness / 2 + fade)`.

      Parameters:
        `gc` - the graphics context where render the drawing.
        `x` - the x coordinate of the upper-left corner of the rectangle where the ellipse is drawn
        `y` - the y coordinate of the upper-left corner of the rectangle where the ellipse is drawn
        `width` - the width of the ellipse to draw
        `height` - the height of the ellipse to draw
        `thickness` - the thickness to apply.
        `fade` - the fade to apply.
      Throws:
        `IllegalArgumentException` - when given thickness or fade is negative

    - #### drawPolygon

          public static void drawPolygon​(GraphicsContext gc,
                                         int[] xys)

      Draws the closed polygon which is defined by the array of integer coordinates, using the current color. Lines are drawn between each consecutive pair, and between the first pair and last pair in the array. The effect is identical to
      `draw(xys,0,xys.length);`
      Parameters:
        `gc` - the graphics context where render the drawing.
        `xys` - the array of coordinates : x1,y1,......xn,yn.
      Throws:
        `IllegalArgumentException` - if the given array length is odd.

    - #### drawPolygon

          public static void drawPolygon​(GraphicsContext gc,
                                         int[] xys,
                                         int offset,
                                         int length)

      Draws the closed polygon which is defined by the array of integer coordinates, using the current color. Lines are drawn between each consecutive pair, and between the first pair and last pair in the array.
      Parameters:
        `gc` - the graphics context where render the drawing.
        `xys` - the array of coordinates : x1,y1,......xn,yn.
        `offset` - the `x1` index in `xys`.
        `length` - the number of coordinates, must be even.
      Throws:
        `IllegalArgumentException` - if the given array length is odd.
        `ArrayIndexOutOfBoundsException` - the wanted data is outside the array bounds.

    - #### fillPolygon

          public static void fillPolygon​(GraphicsContext gc,
                                         int[] xys)

      Fills the closed polygon which is defined by the array of integer coordinates, using the current color. Lines are drawn between each consecutive pair, and between the first pair and last pair in the array. The lines connecting each pair of points are included in the filled polygon. The effect is identical to
      `fill(xys,0,xys.length);`
      Parameters:
        `gc` - the graphics context where render the drawing.
        `xys` - the array of coordinates : x1,y1,......xn,yn.
      Throws:
        `IllegalArgumentException` - if the given array length is odd.

    - #### fillPolygon

          public static void fillPolygon​(GraphicsContext gc,
                                         int[] xys,
                                         int offset,
                                         int length)

      Fills the closed polygon which is defined by the array of integer coordinates, using the current color. Lines are drawn between each consecutive pair, and between the first pair and last pair in the array. The lines connecting each pair of points are included in the filled polygon.
      Parameters:
        `gc` - the graphics context where render the drawing.
        `xys` - the array of coordinates : x1,y1,......xn,yn.
        `offset` - the `x1` index in `xys`.
        `length` - the number of coordinates, must be even.
      Throws:
        `ArrayIndexOutOfBoundsException` - if `offset` and `length` do not specify a valid range within `xys`.
        `IllegalArgumentException` - if the `xys` length is odd.