Module javafx.graphics
Package javafx.scene.canvas

# Class GraphicsContext

java.lang.Object
javafx.scene.canvas.GraphicsContext

public final class GraphicsContext extends Object
This class is used to issue draw calls to a `Canvas` using a buffer.

Each call pushes the necessary parameters onto the buffer where they will be later rendered onto the image of the `Canvas` node by the rendering thread at the end of a pulse.

A `Canvas` only contains one `GraphicsContext`, and only one buffer. If it is not attached to any scene, then it can be modified by any thread, as long as it is only used from one thread at a time. Once a `Canvas` node is attached to a scene, it must be modified on the JavaFX Application Thread.

Calling any method on the `GraphicsContext` is considered modifying its corresponding `Canvas` and is subject to the same threading rules.

A `GraphicsContext` also manages a stack of state objects that can be saved or restored at anytime.

The `GraphicsContext` maintains the following rendering attributes which affect various subsets of the rendering methods:

List of Rendering Attributes
Attribute | Save/Restore? | Default value | Description
--- | --- | --- | ---
Common Rendering Attributes
`Clip` | Yes | No clipping | An anti-aliased intersection of various clip paths to which rendering is restricted.
`Global Alpha` | Yes | `1.0` | An opacity value that controls the visibility or fading of each rendering operation.
`Global Blend Mode` | Yes | `SRC_OVER` | A `BlendMode` enum value that controls how pixels from each rendering operation are composited into the existing image.
`Transform` | Yes | `Identity` | A 3x2 2D affine transformation matrix that controls how coordinates are mapped onto the logical pixels of the canvas image.
`Effect` | Yes | `null` | An `Effect` applied individually to each rendering operation.
Fill Attributes
`Fill Paint` | Yes | `BLACK` | The `Paint` to be applied to the interior of shapes in a fill operation.
Stroke Attributes
`Stroke Paint` | Yes | `BLACK` | The `Paint` to be applied to the boundary of shapes in a stroke operation.
`Line Width` | Yes | `1.0` | The width of the stroke applied to the boundary of shapes in a stroke operation.
`Line Cap` | Yes | `SQUARE` | The style of the end caps applied to the beginnings and ends of each dash and/or subpath in a stroke operation.
`Line Join` | Yes | `MITER` | The style of the joins applied between individual segments in the boundary paths of shapes in a stroke operation.
`Miter Limit` | Yes | `10.0` | The ratio limit of how far a `MITER` line join may extend in the direction of a sharp corner between segments in the boundary path of a shape, relative to the line width, before it is truncated to a `BEVEL` join in a stroke operation.
`Dashes` | Yes | `null` | The array of dash lengths to be applied to the segments in the boundary of shapes in a stroke operation.
`Dash Offset` | Yes | `0.0` | The distance offset into the array of dash lengths at which to start the dashing of the segments in the boundary of shapes in a stroke operation.
Text Attributes
`Font` | Yes | `Default Font` | The font used for all fill and stroke text operations.
`Text Align` | Yes | `LEFT` | The horizontal alignment of text with respect to the `X` coordinate specified in the text operation.
`Text Baseline` | Yes | `BASELINE` | The vertical position of the text relative to the `Y` coordinate specified in the text operation.
`Font Smoothing` | Yes | `GRAY` | The type of smoothing (antialiasing) applied to the glyphs in the font for all fill text operations.
Path Attributes
`Current Path` | No | Empty path | The path constructed using various path construction methods to be used in various path filling, stroking, or clipping operations.
`Fill Rule` | Yes | `NON_ZERO` | The method used to determine the interior of paths for a path fill or clip operation.
Image Attributes
`Image Smoothing` | Yes | `true` | A boolean state which enables or disables image smoothing for `drawImage(all forms)`.

The various rendering methods on the `GraphicsContext` use the following sets of rendering attributes:

Rendering Attributes Table
Method | Common Rendering Attributes | Fill Attributes | Stroke Attributes | Text Attributes | Path Attributes | Image Attributes
--- | --- | --- | --- | --- | --- | ---
Basic Shape Rendering
`fillRect()`, `fillRoundRect()`, `fillOval()`, `fillArc()` | Yes | Yes | No | No | No | No
`strokeLine()`, `strokeRect()`, `strokeRoundRect()`, `strokeOval()`, `strokeArc()` | Yes | No | Yes | No | No | No
`clearRect()` | Yes [1] | No | No | No | No | No
`fillPolygon()` | Yes | Yes | No | No | Yes [2] | No
`strokePolygon()`, `strokePolyline()` | Yes | No | Yes | No | No | No
[1] Only the Transform, Clip, and Effect apply to clearRect() [2] Only the Fill Rule applies to fillPolygon(), the current path is left unchanged
Text Rendering
`fillText()`, `fillText(with maxWidth)` | Yes | Yes | No | Yes [3] | No | No
`strokeText()`, `strokeText(with maxWidth)` | Yes | No | Yes | Yes [3] | No | No
[3] The Font Smoothing attribute only applies to filled text
Path Rendering
`beginPath()`, `moveTo()`, `lineTo()`, `quadraticCurveTo()`, `bezierCurveTo()`, `arc()`, `arcTo()`, `appendSVGPath()`, `closePath()`, `rect()` | Yes [4] | No | No | No | No | No
`fill()` | Yes [4] | Yes | No | No | Yes | No
`stroke()` | Yes [4] | No | Yes | No | Yes [5] | No
`clip()` | No | No | No | No | Yes | No
[4] Transform applied only during path construction [5] Fill Rule only used for fill() and clip()
Image Rendering
`drawImage(all forms)` | Yes | No | No | No | No | Yes
Miscellaneous
`applyEffect()`, `PixelWriter methods` | No | No | No | No | No | No

Example:

     import javafx.scene.*;
     import javafx.scene.paint.*;
     import javafx.scene.canvas.*;

     Group root = new Group();
     Scene s = new Scene(root, 300, 300, Color.BLACK);

     final Canvas canvas = new Canvas(250,250);
     GraphicsContext gc = canvas.getGraphicsContext2D();

     gc.setFill(Color.BLUE);
     gc.fillRect(75,75,100,100);

     root.getChildren().add(canvas);

Since:
  JavaFX 2.2
See Also:
  - `Canvas`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `appendSVGPath(String svgpath)`
  Appends an SVG Path string to the current path.
  `void`
  `applyEffect(Effect e)`
  Applies the given effect to the entire bounds of the canvas and stores the result back into the same canvas.
  `void`
  `arc(double centerX, double centerY, double radiusX, double radiusY, double startAngle, double length)`
  Adds path elements to the current path to make an arc that uses Euclidean degrees.
  `void`
  `arcTo(double x1, double y1, double x2, double y2, double radius)`
  Adds segments to the current path to make an arc.
  `void`
  `beginPath()`
  Resets the current path to empty.
  `void`
  `bezierCurveTo(double xc1, double yc1, double xc2, double yc2, double x1, double y1)`
  Adds segments to the current path to make a cubic Bezier curve.
  `void`
  `clearRect(double x, double y, double w, double h)`
  Clears a portion of the canvas with a transparent color value.
  `void`
  `clip()`
  Intersects the current clip with the current path and applies it to subsequent rendering operation as an anti-aliased mask.
  `void`
  `closePath()`
  Closes the path.
  `void`
  `drawImage(Image img, double x, double y)`
  Draws an image at the given x, y position using the width and height of the given image.
  `void`
  `drawImage(Image img, double x, double y, double w, double h)`
  Draws an image into the given destination rectangle of the canvas.
  `void`
  `drawImage(Image img, double sx, double sy, double sw, double sh, double dx, double dy, double dw, double dh)`
  Draws the specified source rectangle of the given image to the given destination rectangle of the Canvas.
  `void`
  `fill()`
  Fills the path with the current fill paint.
  `void`
  `fillArc(double x, double y, double w, double h, double startAngle, double arcExtent, ArcType closure)`
  Fills an arc using the current fill paint.
  `void`
  `fillOval(double x, double y, double w, double h)`
  Fills an oval using the current fill paint.
  `void`
  `fillPolygon(double[] xPoints, double[] yPoints, int nPoints)`
  Fills a polygon with the given points using the currently set fill paint.
  `void`
  `fillRect(double x, double y, double w, double h)`
  Fills a rectangle using the current fill paint.
  `void`
  `fillRoundRect(double x, double y, double w, double h, double arcWidth, double arcHeight)`
  Fills a rounded rectangle using the current fill paint.
  `void`
  `fillText(String text, double x, double y)`
  Fills the given string of text at position x, y with the current fill paint attribute.
  `void`
  `fillText(String text, double x, double y, double maxWidth)`
  Fills text and includes a maximum width of the string.
  `Canvas`
  `getCanvas()`
  Gets the `Canvas` that the `GraphicsContext` is issuing draw commands to.
  `Effect`
  `getEffect(Effect e)`
  Gets a copy of the effect to be applied after the next draw call.
  `Paint`
  `getFill()`
  Gets the current fill paint attribute.
  `FillRule`
  `getFillRule()`
  Get the filling rule attribute for determining the interior of paths in fill and clip operations.
  `Font`
  `getFont()`
  Gets the current Font.
  `FontSmoothingType`
  `getFontSmoothingType()`
  Gets the current Font Smoothing Type.
  `double`
  `getGlobalAlpha()`
  Gets the current global alpha.
  `BlendMode`
  `getGlobalBlendMode()`
  Gets the global blend mode.
  `StrokeLineCap`
  `getLineCap()`
  Gets the current stroke line cap.
  `double[]`
  `getLineDashes()`
  Gets a copy of the current line dash array.
  `double`
  `getLineDashOffset()`
  Gets the current line dash offset.
  `StrokeLineJoin`
  `getLineJoin()`
  Gets the current stroke line join.
  `double`
  `getLineWidth()`
  Gets the current line width.
  `double`
  `getMiterLimit()`
  Gets the current miter limit.
  `PixelWriter`
  `getPixelWriter()`
  Returns a `PixelWriter` object that can be used to modify the pixels of the `Canvas` associated with this `GraphicsContext`.
  `Paint`
  `getStroke()`
  Gets the current stroke.
  `TextAlignment`
  `getTextAlign()`
  Gets the current `TextAlignment`.
  `VPos`
  `getTextBaseline()`
  Gets the current Text Baseline.
  `Affine`
  `getTransform()`
  Returns a copy of the current transform.
  `Affine`
  `getTransform(Affine xform)`
  Copies the current transform into the supplied object, creating a new `Affine` object if it is null, and returns the object containing the copy.
  `boolean`
  `isImageSmoothing()`
  Gets the current image smoothing state.
  `boolean`
  `isPointInPath(double x, double y)`
  Returns true if the the given x,y point is inside the path.
  `void`
  `lineTo(double x1, double y1)`
  Adds segments to the current path to make a line to the given x,y coordinate.
  `void`
  `moveTo(double x0, double y0)`
  Issues a move command for the current path to the given x,y coordinate.
  `void`
  `quadraticCurveTo(double xc, double yc, double x1, double y1)`
  Adds segments to the current path to make a quadratic Bezier curve.
  `void`
  `rect(double x, double y, double w, double h)`
  Adds path elements to the current path to make a rectangle.
  `void`
  `restore()`
  Pops the state off of the stack, setting the following attributes to their value at the time when that state was pushed onto the stack.
  `void`
  `rotate(double degrees)`
  Rotates the current transform in degrees.
  `void`
  `save()`
  Saves the following attributes onto a stack.
  `void`
  `scale(double x, double y)`
  Scales the current transform by x, y.
  `void`
  `setEffect(Effect e)`
  Sets the effect to be applied after the next draw call, or null to disable effects.
  `void`
  `setFill(Paint p)`
  Sets the current fill paint attribute.
  `void`
  `setFillRule(FillRule fillRule)`
  Set the filling rule attribute for determining the interior of paths in fill or clip operations.
  `void`
  `setFont(Font f)`
  Sets the current Font.
  `void`
  `setFontSmoothingType(FontSmoothingType fontsmoothing)`
  Sets the current Font Smoothing Type.
  `void`
  `setGlobalAlpha(double alpha)`
  Sets the global alpha of the current state.
  `void`
  `setGlobalBlendMode(BlendMode op)`
  Sets the global blend mode.
  `void`
  `setImageSmoothing(boolean imageSmoothing)`
  Sets the image smoothing state.
  `void`
  `setLineCap(StrokeLineCap cap)`
  Sets the current stroke line cap.
  `void`
  `setLineDashes(double... dashes)`
  Sets the current stroke line dash pattern to a normalized copy of the argument.
  `void`
  `setLineDashOffset(double dashOffset)`
  Sets the line dash offset.
  `void`
  `setLineJoin(StrokeLineJoin join)`
  Sets the current stroke line join.
  `void`
  `setLineWidth(double lw)`
  Sets the current line width.
  `void`
  `setMiterLimit(double ml)`
  Sets the current miter limit.
  `void`
  `setStroke(Paint p)`
  Sets the current stroke paint attribute.
  `void`
  `setTextAlign(TextAlignment align)`
  Defines horizontal text alignment, relative to the text `x` origin.
  `void`
  `setTextBaseline(VPos baseline)`
  Sets the current Text Baseline.
  `void`
  `setTransform(double mxx, double myx, double mxy, double myy, double mxt, double myt)`
  Sets the current transform.
  `void`
  `setTransform(Affine xform)`
  Sets the current transform.
  `void`
  `stroke()`
  Strokes the path with the current stroke paint.
  `void`
  `strokeArc(double x, double y, double w, double h, double startAngle, double arcExtent, ArcType closure)`
  Strokes an Arc using the current stroke paint.
  `void`
  `strokeLine(double x1, double y1, double x2, double y2)`
  Strokes a line using the current stroke paint.
  `void`
  `strokeOval(double x, double y, double w, double h)`
  Strokes an oval using the current stroke paint.
  `void`
  `strokePolygon(double[] xPoints, double[] yPoints, int nPoints)`
  Strokes a polygon with the given points using the currently set stroke paint.
  `void`
  `strokePolyline(double[] xPoints, double[] yPoints, int nPoints)`
  Strokes a polyline with the given points using the currently set stroke paint attribute.
  `void`
  `strokeRect(double x, double y, double w, double h)`
  Strokes a rectangle using the current stroke paint.
  `void`
  `strokeRoundRect(double x, double y, double w, double h, double arcWidth, double arcHeight)`
  Strokes a rounded rectangle using the current stroke paint.
  `void`
  `strokeText(String text, double x, double y)`
  Draws the given string of text at position x, y with the current stroke paint attribute.
  `void`
  `strokeText(String text, double x, double y, double maxWidth)`
  Draws text with stroke paint and includes a maximum width of the string.
  `void`
  `transform(double mxx, double myx, double mxy, double myy, double mxt, double myt)`
  Concatenates the input with the current transform.
  `void`
  `transform(Affine xform)`
  Concatenates the input with the current transform.
  `void`
  `translate(double x, double y)`
  Translates the current transform by x, y.

  ### Methods declared in class java.lang.Object

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

- ## Method Details

  - ### getCanvas

    public Canvas getCanvas()
    Gets the `Canvas` that the `GraphicsContext` is issuing draw commands to. There is only ever one `Canvas` for a `GraphicsContext`.
    Returns:
      Canvas the canvas that this `GraphicsContext` is issuing draw commands to.

  - ### save

    public void save()
    Saves the following attributes onto a stack.
    - Global Alpha
    - Global Blend Operation
    - Transform
    - Fill Paint
    - Stroke Paint
    - Line Width
    - Line Cap
    - Line Join
    - Miter Limit
    - Clip
    - Font
    - Text Align
    - Text Baseline
    - Effect
    - Fill Rule
    This method does NOT alter the current state in any way. Also, note that the current path is not saved.

  - ### restore

    public void restore()
    Pops the state off of the stack, setting the following attributes to their value at the time when that state was pushed onto the stack. If the stack is empty then nothing is changed.
    - Global Alpha
    - Global Blend Operation
    - Transform
    - Fill Paint
    - Stroke Paint
    - Line Width
    - Line Cap
    - Line Join
    - Miter Limit
    - Clip
    - Font
    - Text Align
    - Text Baseline
    - Effect
    - Fill Rule
    Note that the current path is not restored.

  - ### translate

    public void translate(double x, double y)
    Translates the current transform by x, y.
    Parameters:
      `x` - value to translate along the x axis.
      `y` - value to translate along the y axis.

  - ### scale

    public void scale(double x, double y)
    Scales the current transform by x, y.
    Parameters:
      `x` - value to scale in the x axis.
      `y` - value to scale in the y axis.

  - ### rotate

    public void rotate(double degrees)
    Rotates the current transform in degrees.
    Parameters:
      `degrees` - value in degrees to rotate the current transform.

  - ### transform

    public void transform(double mxx, double myx, double mxy, double myy, double mxt, double myt)
    Concatenates the input with the current transform.
    Parameters:
      `mxx` - - the X coordinate scaling element of the 3x4 matrix
      `myx` - - the Y coordinate shearing element of the 3x4 matrix
      `mxy` - - the X coordinate shearing element of the 3x4 matrix
      `myy` - - the Y coordinate scaling element of the 3x4 matrix
      `mxt` - - the X coordinate translation element of the 3x4 matrix
      `myt` - - the Y coordinate translation element of the 3x4 matrix

  - ### transform

    public void transform(Affine xform)
    Concatenates the input with the current transform. Only 2D transforms are supported. The only values used are the X and Y scaling, translation, and shearing components of a transform. A `null` value is treated as identity.
    Parameters:
      `xform` - The affine to be concatenated with the current transform or null.

  - ### setTransform

    public void setTransform(double mxx, double myx, double mxy, double myy, double mxt, double myt)
    Sets the current transform.
    Parameters:
      `mxx` - - the X coordinate scaling element of the 3x4 matrix
      `myx` - - the Y coordinate shearing element of the 3x4 matrix
      `mxy` - - the X coordinate shearing element of the 3x4 matrix
      `myy` - - the Y coordinate scaling element of the 3x4 matrix
      `mxt` - - the X coordinate translation element of the 3x4 matrix
      `myt` - - the Y coordinate translation element of the 3x4 matrix

  - ### setTransform

    public void setTransform(Affine xform)
    Sets the current transform. Only 2D transforms are supported. The only values used are the X and Y scaling, translation, and shearing components of a transform.
    Parameters:
      `xform` - The affine to be copied and used as the current transform.

  - ### getTransform

    public Affine getTransform(Affine xform)
    Copies the current transform into the supplied object, creating a new `Affine` object if it is null, and returns the object containing the copy.
    Parameters:
      `xform` - A transform object that will be used to hold the result. If xform is non null, then this method will copy the current transform into that object. If xform is null a new transform object will be constructed. In either case, the return value is a copy of the current transform.
    Returns:
      A copy of the current transform.

  - ### getTransform

    public Affine getTransform()
    Returns a copy of the current transform.
    Returns:
      a copy of the transform of the current state.

  - ### setGlobalAlpha

    public void setGlobalAlpha(double alpha)
    Sets the global alpha of the current state. The default value is `1.0`. Any valid double can be set, but only values in the range `[0.0, 1.0]` are valid and the nearest value in that range will be used for rendering. The global alpha is a common attribute used for nearly all rendering methods as specified in the Rendering Attributes Table.
    Parameters:
      `alpha` - the new alpha value, clamped to `[0.0, 1.0]` during actual use.

  - ### getGlobalAlpha

    public double getGlobalAlpha()
    Gets the current global alpha. The default value is `1.0`. The global alpha is a common attribute used for nearly all rendering methods as specified in the Rendering Attributes Table.
    Returns:
      the current global alpha.

  - ### setGlobalBlendMode

    public void setGlobalBlendMode(BlendMode op)
    Sets the global blend mode. The default value is `SRC_OVER`. A `null` value will be ignored and the current value will remain unchanged. The blend mode is a common attribute used for nearly all rendering methods as specified in the Rendering Attributes Table.
    Parameters:
      `op` - the `BlendMode` that will be set or null.

  - ### getGlobalBlendMode

    public BlendMode getGlobalBlendMode()
    Gets the global blend mode. The default value is `SRC_OVER`. The blend mode is a common attribute used for nearly all rendering methods as specified in the Rendering Attributes Table.
    Returns:
      the global `BlendMode` of the current state.

  - ### setFill

    public void setFill(Paint p)
    Sets the current fill paint attribute. The default value is `BLACK`. The fill paint is a fill attribute used for any of the fill methods as specified in the Rendering Attributes Table. A `null` value will be ignored and the current value will remain unchanged.
    Parameters:
      `p` - The `Paint` to be used as the fill `Paint` or null.

  - ### getFill

    public Paint getFill()
    Gets the current fill paint attribute. The default value is `BLACK`. The fill paint is a fill attribute used for any of the fill methods as specified in the Rendering Attributes Table.
    Returns:
      p The `Paint` to be used as the fill `Paint`.

  - ### setStroke

    public void setStroke(Paint p)
    Sets the current stroke paint attribute. The default value is `BLACK`. The stroke paint is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table. A `null` value will be ignored and the current value will remain unchanged.
    Parameters:
      `p` - The Paint to be used as the stroke Paint or null.

  - ### getStroke

    public Paint getStroke()
    Gets the current stroke. The default value is `BLACK`. The stroke paint is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table.
    Returns:
      the `Paint` to be used as the stroke `Paint`.

  - ### setLineWidth

    public void setLineWidth(double lw)
    Sets the current line width. The default value is `1.0`. The line width is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table. An infinite or non-positive value outside of the range `(0, +inf)` will be ignored and the current value will remain unchanged.
    Parameters:
      `lw` - value in the range {0-positive infinity}, with any other value being ignored and leaving the value unchanged.

  - ### getLineWidth

    public double getLineWidth()
    Gets the current line width. The default value is `1.0`. The line width is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table.
    Returns:
      value between 0 and infinity.

  - ### setLineCap

    public void setLineCap(StrokeLineCap cap)
    Sets the current stroke line cap. The default value is `SQUARE`. The line cap is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table. A `null` value will be ignored and the current value will remain unchanged.
    Parameters:
      `cap` - `StrokeLineCap` with a value of Butt, Round, or Square or null.

  - ### getLineCap

    public StrokeLineCap getLineCap()
    Gets the current stroke line cap. The default value is `SQUARE`. The line cap is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table.
    Returns:
      `StrokeLineCap` with a value of Butt, Round, or Square.

  - ### setLineJoin

    public void setLineJoin(StrokeLineJoin join)
    Sets the current stroke line join. The default value is `StrokeLineJoin.MITER`. The line join is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table. A `null` value will be ignored and the current value will remain unchanged.
    Parameters:
      `join` - `StrokeLineJoin` with a value of Miter, Bevel, or Round or null.

  - ### getLineJoin

    public StrokeLineJoin getLineJoin()
    Gets the current stroke line join. The default value is `StrokeLineJoin.MITER`. The line join is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table.
    Returns:
      `StrokeLineJoin` with a value of Miter, Bevel, or Round.

  - ### setMiterLimit

    public void setMiterLimit(double ml)
    Sets the current miter limit. The default value is `10.0`. The miter limit is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table. An infinite or non-positive value outside of the range `(0, +inf)` will be ignored and the current value will remain unchanged.
    Parameters:
      `ml` - miter limit value between 0 and positive infinity with any other value being ignored and leaving the value unchanged.

  - ### getMiterLimit

    public double getMiterLimit()
    Gets the current miter limit. The default value is `10.0`. The miter limit is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table.
    Returns:
      the miter limit value in the range `0.0-positive infinity`

  - ### setLineDashes

    public void setLineDashes(double... dashes)
    Sets the current stroke line dash pattern to a normalized copy of the argument. The default value is `null`. The line dash array is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table. If the array is `null` or empty or contains all `0` elements then dashing will be disabled and the current dash array will be set to `null`. If any of the elements of the array are a negative, infinite, or NaN value outside the range `[0, +inf)` then the entire array will be ignored and the current dash array will remain unchanged. If the array is an odd length then it will be treated as if it were two copies of the array appended to each other.
    Parameters:
      `dashes` - the array of finite non-negative dash lengths
    Since:
      JavaFX 8u40

  - ### getLineDashes

    public double[] getLineDashes()
    Gets a copy of the current line dash array. The default value is `null`. The array may be normalized by the validation tests in the `setLineDashes(double...)` method. The line dash array is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table.
    Returns:
      a copy of the current line dash array.
    Since:
      JavaFX 8u40

  - ### setLineDashOffset

    public void setLineDashOffset(double dashOffset)
    Sets the line dash offset. The default value is `0.0`. The line dash offset is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table. An infinite or NaN value outside of the range `(-inf, +inf)` will be ignored and the current value will remain unchanged.
    Parameters:
      `dashOffset` - the line dash offset in the range `(-inf, +inf)`
    Since:
      JavaFX 8u40

  - ### getLineDashOffset

    public double getLineDashOffset()
    Gets the current line dash offset. The default value is `0.0`. The line dash offset is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table.
    Returns:
      the line dash offset in the range `(-inf, +inf)`
    Since:
      JavaFX 8u40

  - ### setFont

    public void setFont(Font f)
    Sets the current Font. The default value is specified by `Font.getDefault()`. The font is a text attribute used for any of the text methods as specified in the Rendering Attributes Table. A `null` value will be ignored and the current value will remain unchanged.
    Parameters:
      `f` - the Font or null.

  - ### getFont

    public Font getFont()
    Gets the current Font. The default value is specified by `Font.getDefault()`. The font is a text attribute used for any of the text methods as specified in the Rendering Attributes Table.
    Returns:
      the Font

  - ### setFontSmoothingType

    public void setFontSmoothingType(FontSmoothingType fontsmoothing)
    Sets the current Font Smoothing Type. The default value is `GRAY`. The font smoothing type is a text attribute used for any of the text methods as specified in the Rendering Attributes Table. A `null` value will be ignored and the current value will remain unchanged.

    Note that the `FontSmoothingType` value of `LCD` is only supported over an opaque background. `LCD` text will generally appear as `GRAY` text over transparent or partially transparent pixels, and in some implementations it may not be supported at all on a `Canvas` because the required support does not exist for surfaces which contain an alpha channel as all `Canvas` objects do.

    Parameters:
      `fontsmoothing` - the `FontSmoothingType` or null
    Since:
      JavaFX 8u40

  - ### getFontSmoothingType

    public FontSmoothingType getFontSmoothingType()
    Gets the current Font Smoothing Type. The default value is `GRAY`. The font smoothing type is a text attribute used for any of the text methods as specified in the Rendering Attributes Table.
    Returns:
      the `FontSmoothingType`
    Since:
      JavaFX 8u40

  - ### setTextAlign

    public void setTextAlign(TextAlignment align)
    Defines horizontal text alignment, relative to the text `x` origin. The default value is `LEFT`. The text alignment is a text attribute used for any of the text methods as specified in the Rendering Attributes Table.

    Let horizontal bounds represent the logical width of a single line of text. Where each line of text has a separate horizontal bounds.

    Then TextAlignment is specified as:

    - Left: the left edge of the horizontal bounds will be at `x`.
    - Center: the center, halfway between left and right edge, of the horizontal bounds will be at `x`.
    - Right: the right edge of the horizontal bounds will be at `x`.

    Note: Canvas does not support line wrapping, therefore the text alignment Justify is identical to left aligned text.

    A `null` value will be ignored and the current value will remain unchanged.

    Parameters:
      `align` - `TextAlignment` with values of Left, Center, Right or null.

  - ### getTextAlign

    public TextAlignment getTextAlign()
    Gets the current `TextAlignment`. The default value is `LEFT`. The text alignment is a text attribute used for any of the text methods as specified in the Rendering Attributes Table.
    Returns:
      `TextAlignment` with values of Left, Center, Right, or Justify.

  - ### setTextBaseline

    public void setTextBaseline(VPos baseline)
    Sets the current Text Baseline. The default value is `BASELINE`. The text baseline is a text attribute used for any of the text methods as specified in the Rendering Attributes Table. A `null` value will be ignored and the current value will remain unchanged.
    Parameters:
      `baseline` - `VPos` with values of Top, Center, Baseline, or Bottom or null.

  - ### getTextBaseline

    public VPos getTextBaseline()
    Gets the current Text Baseline. The default value is `BASELINE`. The text baseline is a text attribute used for any of the text methods as specified in the Rendering Attributes Table.
    Returns:
      `VPos` with values of Top, Center, Baseline, or Bottom

  - ### fillText

    public void fillText(String text, double x, double y)
    Fills the given string of text at position x, y with the current fill paint attribute. A `null` text value will be ignored.

    This method will be affected by any of the global common, fill, or text attributes as specified in the Rendering Attributes Table.

    Parameters:
      `text` - the string of text or null.
      `x` - position on the x axis.
      `y` - position on the y axis.

  - ### strokeText

    public void strokeText(String text, double x, double y)
    Draws the given string of text at position x, y with the current stroke paint attribute. A `null` text value will be ignored.

    This method will be affected by any of the global common, stroke, or text attributes as specified in the Rendering Attributes Table.

    Parameters:
      `text` - the string of text or null.
      `x` - position on the x axis.
      `y` - position on the y axis.

  - ### fillText

    public void fillText(String text, double x, double y, double maxWidth)
    Fills text and includes a maximum width of the string. If the width of the text extends past max width, then it will be sized to fit. A `null` text value will be ignored.

    This method will be affected by any of the global common, fill, or text attributes as specified in the Rendering Attributes Table.

    Parameters:
      `text` - the string of text or null.
      `x` - position on the x axis.
      `y` - position on the y axis.
      `maxWidth` - maximum width the text string can have.

  - ### strokeText

    public void strokeText(String text, double x, double y, double maxWidth)
    Draws text with stroke paint and includes a maximum width of the string. If the width of the text extends past max width, then it will be sized to fit. A `null` text value will be ignored.

    This method will be affected by any of the global common, stroke, or text attributes as specified in the Rendering Attributes Table.

    Parameters:
      `text` - the string of text or null.
      `x` - position on the x axis.
      `y` - position on the y axis.
      `maxWidth` - maximum width the text string can have.

  - ### setFillRule

    public void setFillRule(FillRule fillRule)
    Set the filling rule attribute for determining the interior of paths in fill or clip operations. The default value is `FillRule.NON_ZERO`. A `null` value will be ignored and the current value will remain unchanged. The fill rule is a path attribute used for any of the fill or clip path methods as specified in the Rendering Attributes Table.
    Parameters:
      `fillRule` - `FillRule` with a value of Even_odd or Non_zero or null.

  - ### getFillRule

    public FillRule getFillRule()
    Get the filling rule attribute for determining the interior of paths in fill and clip operations. The default value is `FillRule.NON_ZERO`. The fill rule is a path attribute used for any of the fill or clip path methods as specified in the Rendering Attributes Table.
    Returns:
      current fill rule.

  - ### setImageSmoothing

    public void setImageSmoothing(boolean imageSmoothing)
    Sets the image smoothing state. Image smoothing is an Image attribute used to enable or disable image smoothing for `drawImage(all forms)` as specified in the Rendering Attributes Table.
    If image smoothing is `true`, images will be scaled using a higher quality filtering when transforming or scaling the source image to fit in the destination rectangle.
    If image smoothing is `false`, images will be scaled without filtering (or by using a lower quality filtering) when transforming or scaling the source image to fit in the destination rectangle.
    Default value:
      `true`
    Parameters:
      `imageSmoothing` - `true` to enable or `false` to disable smoothing
    Since:
      12

  - ### isImageSmoothing

    public boolean isImageSmoothing()
    Gets the current image smoothing state.
    Default value:
      `true`
    Returns:
      image smoothing state
    Since:
      12

  - ### beginPath

    public void beginPath()
    Resets the current path to empty. The default path is empty. The current path is a path attribute used for any of the path methods as specified in the Rendering Attributes Table and is not affected by the `save()` and `restore()` operations.

  - ### moveTo

    public void moveTo(double x0, double y0)
    Issues a move command for the current path to the given x,y coordinate. The coordinates are transformed by the current transform as they are added to the path and unaffected by subsequent changes to the transform. The current path is a path attribute used for any of the path methods as specified in the Rendering Attributes Table and is not affected by the `save()` and `restore()` operations.
    Parameters:
      `x0` - the X position for the move to command.
      `y0` - the Y position for the move to command.

  - ### lineTo

    public void lineTo(double x1, double y1)
    Adds segments to the current path to make a line to the given x,y coordinate. The coordinates are transformed by the current transform as they are added to the path and unaffected by subsequent changes to the transform. The current path is a path attribute used for any of the path methods as specified in the Rendering Attributes Table and is not affected by the `save()` and `restore()` operations.
    Parameters:
      `x1` - the X coordinate of the ending point of the line.
      `y1` - the Y coordinate of the ending point of the line.

  - ### quadraticCurveTo

    public void quadraticCurveTo(double xc, double yc, double x1, double y1)
    Adds segments to the current path to make a quadratic Bezier curve. The coordinates are transformed by the current transform as they are added to the path and unaffected by subsequent changes to the transform. The current path is a path attribute used for any of the path methods as specified in the Rendering Attributes Table and is not affected by the `save()` and `restore()` operations.
    Parameters:
      `xc` - the X coordinate of the control point
      `yc` - the Y coordinate of the control point
      `x1` - the X coordinate of the end point
      `y1` - the Y coordinate of the end point

  - ### bezierCurveTo

    public void bezierCurveTo(double xc1, double yc1, double xc2, double yc2, double x1, double y1)
    Adds segments to the current path to make a cubic Bezier curve. The coordinates are transformed by the current transform as they are added to the path and unaffected by subsequent changes to the transform. The current path is a path attribute used for any of the path methods as specified in the Rendering Attributes Table and is not affected by the `save()` and `restore()` operations.
    Parameters:
      `xc1` - the X coordinate of first Bezier control point.
      `yc1` - the Y coordinate of the first Bezier control point.
      `xc2` - the X coordinate of the second Bezier control point.
      `yc2` - the Y coordinate of the second Bezier control point.
      `x1` - the X coordinate of the end point.
      `y1` - the Y coordinate of the end point.

  - ### arcTo

    public void arcTo(double x1, double y1, double x2, double y2, double radius)
    Adds segments to the current path to make an arc. The coordinates are transformed by the current transform as they are added to the path and unaffected by subsequent changes to the transform. The current path is a path attribute used for any of the path methods as specified in the Rendering Attributes Table and is not affected by the `save()` and `restore()` operations.

    If `p0` is the current point in the path and `p1` is the point specified by `(x1, y1)` and `p2` is the point specified by `(x2, y2)`, then the arc segments appended will be segments along the circumference of a circle of the specified radius touching and inscribed into the convex (interior) side of `p0->p1->p2`. The path will contain a line segment (if needed) to the tangent point between that circle and `p0->p1` followed by circular arc segments to reach the tangent point between the circle and `p1->p2` and will end with the current point at that tangent point (not at `p2`). Note that the radius and circularity of the arc segments will be measured or considered relative to the current transform, but the resulting segments that are computed from those untransformed points will then be transformed when they are added to the path. Since all computation is done in untransformed space, but the pre-existing path segments are all transformed, the ability to correctly perform the computation may implicitly depend on being able to inverse transform the current end of the current path back into untransformed coordinates.

    If there is no way to compute and inscribe the indicated circle for any reason then the entire operation will simply append segments to force a line to point `p1`. Possible reasons that the computation may fail include:

    - The current path is empty.
    - The segments `p0->p1->p2` are colinear.
    - the current transform is non-invertible so that the current end point of the current path cannot be untransformed for computation.
    Parameters:
      `x1` - the X coordinate of the first point of the arc.
      `y1` - the Y coordinate of the first point of the arc.
      `x2` - the X coordinate of the second point of the arc.
      `y2` - the Y coordinate of the second point of the arc.
      `radius` - the radius of the arc in the range {0.0-positive infinity}.

  - ### arc

    public void arc(double centerX, double centerY, double radiusX, double radiusY, double startAngle, double length)
    Adds path elements to the current path to make an arc that uses Euclidean degrees. This Euclidean orientation sweeps from East to North, then West, then South, then back to East. The coordinates are transformed by the current transform as they are added to the path and unaffected by subsequent changes to the transform. The current path is a path attribute used for any of the path methods as specified in the Rendering Attributes Table and is not affected by the `save()` and `restore()` operations.
    Parameters:
      `centerX` - the center x position of the arc.
      `centerY` - the center y position of the arc.
      `radiusX` - the x radius of the arc.
      `radiusY` - the y radius of the arc.
      `startAngle` - the starting angle of the arc in the range `0-360.0`
      `length` - the length of the baseline of the arc.

  - ### rect

    public void rect(double x, double y, double w, double h)
    Adds path elements to the current path to make a rectangle. The coordinates are transformed by the current transform as they are added to the path and unaffected by subsequent changes to the transform. The current path is a path attribute used for any of the path methods as specified in the Rendering Attributes Table and is not affected by the `save()` and `restore()` operations.
    Parameters:
      `x` - x position of the upper left corner of the rectangle.
      `y` - y position of the upper left corner of the rectangle.
      `w` - width of the rectangle.
      `h` - height of the rectangle.

  - ### appendSVGPath

    public void appendSVGPath(String svgpath)
    Appends an SVG Path string to the current path. If there is no current path the string must then start with either type of move command. A `null` value or incorrect SVG path will be ignored. The coordinates are transformed by the current transform as they are added to the path and unaffected by subsequent changes to the transform. The current path is a path attribute used for any of the path methods as specified in the Rendering Attributes Table and is not affected by the `save()` and `restore()` operations.
    Parameters:
      `svgpath` - the SVG Path string.

  - ### closePath

    public void closePath()
    Closes the path. The current path is a path attribute used for any of the path methods as specified in the Rendering Attributes Table and is not affected by the `save()` and `restore()` operations.

  - ### fill

    public void fill()
    Fills the path with the current fill paint.

    This method will be affected by any of the global common, fill, or path attributes as specified in the Rendering Attributes Table. Note that the path segments were transformed as they were originally added to the current path so the current transform will not affect those path segments again, but it may affect other attributes in affect at the time of the `fill()` operation.

  - ### stroke

    public void stroke()
    Strokes the path with the current stroke paint.

    This method will be affected by any of the global common, stroke, or path attributes as specified in the Rendering Attributes Table. Note that the path segments were transformed as they were originally added to the current path so the current transform will not affect those path segments again, but it may affect other attributes in affect at the time of the `stroke()` operation.

  - ### clip

    public void clip()
    Intersects the current clip with the current path and applies it to subsequent rendering operation as an anti-aliased mask. The current clip is a common attribute used for nearly all rendering operations as specified in the Rendering Attributes Table.

    This method will itself be affected only by the path attributes as specified in the Rendering Attributes Table. Note that the path segments were transformed as they were originally added to the current path so the current transform will not affect those path segments again, but it may affect other attributes in affect at the time of the `stroke()` operation.

  - ### isPointInPath

    public boolean isPointInPath(double x, double y)
    Returns true if the the given x,y point is inside the path.
    Parameters:
      `x` - the X coordinate to use for the check.
      `y` - the Y coordinate to use for the check.
    Returns:
      true if the point given is inside the path, false otherwise.

  - ### clearRect

    public void clearRect(double x, double y, double w, double h)
    Clears a portion of the canvas with a transparent color value.

    This method will be affected only by the current transform, clip, and effect.

    Parameters:
      `x` - X position of the upper left corner of the rectangle.
      `y` - Y position of the upper left corner of the rectangle.
      `w` - width of the rectangle.
      `h` - height of the rectangle.

  - ### fillRect

    public void fillRect(double x, double y, double w, double h)
    Fills a rectangle using the current fill paint.

    This method will be affected by any of the global common or fill attributes as specified in the Rendering Attributes Table.

    Parameters:
      `x` - the X position of the upper left corner of the rectangle.
      `y` - the Y position of the upper left corner of the rectangle.
      `w` - the width of the rectangle.
      `h` - the height of the rectangle.

  - ### strokeRect

    public void strokeRect(double x, double y, double w, double h)
    Strokes a rectangle using the current stroke paint.

    This method will be affected by any of the global common or stroke attributes as specified in the Rendering Attributes Table.

    Parameters:
      `x` - the X position of the upper left corner of the rectangle.
      `y` - the Y position of the upper left corner of the rectangle.
      `w` - the width of the rectangle.
      `h` - the height of the rectangle.

  - ### fillOval

    public void fillOval(double x, double y, double w, double h)
    Fills an oval using the current fill paint.

    This method will be affected by any of the global common or fill attributes as specified in the Rendering Attributes Table.

    Parameters:
      `x` - the X coordinate of the upper left bound of the oval.
      `y` - the Y coordinate of the upper left bound of the oval.
      `w` - the width at the center of the oval.
      `h` - the height at the center of the oval.

  - ### strokeOval

    public void strokeOval(double x, double y, double w, double h)
    Strokes an oval using the current stroke paint.

    This method will be affected by any of the global common or stroke attributes as specified in the Rendering Attributes Table.

    Parameters:
      `x` - the X coordinate of the upper left bound of the oval.
      `y` - the Y coordinate of the upper left bound of the oval.
      `w` - the width at the center of the oval.
      `h` - the height at the center of the oval.

  - ### fillArc

    public void fillArc(double x, double y, double w, double h, double startAngle, double arcExtent, ArcType closure)
    Fills an arc using the current fill paint. A `null` ArcType or non positive width or height will cause the render command to be ignored.

    This method will be affected by any of the global common or fill attributes as specified in the Rendering Attributes Table.

    Parameters:
      `x` - the X coordinate of the arc.
      `y` - the Y coordinate of the arc.
      `w` - the width of the arc.
      `h` - the height of the arc.
      `startAngle` - the starting angle of the arc in degrees.
      `arcExtent` - the angular extent of the arc in degrees.
      `closure` - closure type (Round, Chord, Open) or null.

  - ### strokeArc

    public void strokeArc(double x, double y, double w, double h, double startAngle, double arcExtent, ArcType closure)
    Strokes an Arc using the current stroke paint. A `null` ArcType or non positive width or height will cause the render command to be ignored.

    This method will be affected by any of the global common or stroke attributes as specified in the Rendering Attributes Table.

    Parameters:
      `x` - the X coordinate of the arc.
      `y` - the Y coordinate of the arc.
      `w` - the width of the arc.
      `h` - the height of the arc.
      `startAngle` - the starting angle of the arc in degrees.
      `arcExtent` - arcExtent the angular extent of the arc in degrees.
      `closure` - closure type (Round, Chord, Open) or null

  - ### fillRoundRect

    public void fillRoundRect(double x, double y, double w, double h, double arcWidth, double arcHeight)
    Fills a rounded rectangle using the current fill paint.

    This method will be affected by any of the global common or fill attributes as specified in the Rendering Attributes Table.

    Parameters:
      `x` - the X coordinate of the upper left bound of the oval.
      `y` - the Y coordinate of the upper left bound of the oval.
      `w` - the width at the center of the oval.
      `h` - the height at the center of the oval.
      `arcWidth` - the arc width of the rectangle corners.
      `arcHeight` - the arc height of the rectangle corners.

  - ### strokeRoundRect

    public void strokeRoundRect(double x, double y, double w, double h, double arcWidth, double arcHeight)
    Strokes a rounded rectangle using the current stroke paint.

    This method will be affected by any of the global common or stroke attributes as specified in the Rendering Attributes Table.

    Parameters:
      `x` - the X coordinate of the upper left bound of the oval.
      `y` - the Y coordinate of the upper left bound of the oval.
      `w` - the width at the center of the oval.
      `h` - the height at the center of the oval.
      `arcWidth` - the arc width of the rectangle corners.
      `arcHeight` - the arc height of the rectangle corners.

  - ### strokeLine

    public void strokeLine(double x1, double y1, double x2, double y2)
    Strokes a line using the current stroke paint.

    This method will be affected by any of the global common or stroke attributes as specified in the Rendering Attributes Table.

    Parameters:
      `x1` - the X coordinate of the starting point of the line.
      `y1` - the Y coordinate of the starting point of the line.
      `x2` - the X coordinate of the ending point of the line.
      `y2` - the Y coordinate of the ending point of the line.

  - ### fillPolygon

    public void fillPolygon(double[] xPoints, double[] yPoints, int nPoints)
    Fills a polygon with the given points using the currently set fill paint. A `null` value for any of the arrays will be ignored and nothing will be drawn.

    This method will be affected by any of the global common, fill, or Fill Rule attributes as specified in the Rendering Attributes Table.

    Parameters:
      `xPoints` - array containing the x coordinates of the polygon's points or null.
      `yPoints` - array containing the y coordinates of the polygon's points or null.
      `nPoints` - the number of points that make the polygon.

  - ### strokePolygon

    public void strokePolygon(double[] xPoints, double[] yPoints, int nPoints)
    Strokes a polygon with the given points using the currently set stroke paint. A `null` value for any of the arrays will be ignored and nothing will be drawn.

    This method will be affected by any of the global common or stroke attributes as specified in the Rendering Attributes Table.

    Parameters:
      `xPoints` - array containing the x coordinates of the polygon's points or null.
      `yPoints` - array containing the y coordinates of the polygon's points or null.
      `nPoints` - the number of points that make the polygon.

  - ### strokePolyline

    public void strokePolyline(double[] xPoints, double[] yPoints, int nPoints)
    Strokes a polyline with the given points using the currently set stroke paint attribute. A `null` value for any of the arrays will be ignored and nothing will be drawn.

    This method will be affected by any of the global common or stroke attributes as specified in the Rendering Attributes Table.

    Parameters:
      `xPoints` - array containing the x coordinates of the polyline's points or null.
      `yPoints` - array containing the y coordinates of the polyline's points or null.
      `nPoints` - the number of points that make the polyline.

  - ### drawImage

    public void drawImage(Image img, double x, double y)
    Draws an image at the given x, y position using the width and height of the given image. A `null` image value or an image still in progress will be ignored.

    This method will be affected by any of the global common or image attributes as specified in the Rendering Attributes Table.

    Parameters:
      `img` - the image to be drawn or null.
      `x` - the X coordinate on the destination for the upper left of the image.
      `y` - the Y coordinate on the destination for the upper left of the image.

  - ### drawImage

    public void drawImage(Image img, double x, double y, double w, double h)
    Draws an image into the given destination rectangle of the canvas. The Image is scaled to fit into the destination rectangle. A `null` image value or an image still in progress will be ignored.

    This method will be affected by any of the global common or image attributes as specified in the Rendering Attributes Table.

    Parameters:
      `img` - the image to be drawn or null.
      `x` - the X coordinate on the destination for the upper left of the image.
      `y` - the Y coordinate on the destination for the upper left of the image.
      `w` - the width of the destination rectangle.
      `h` - the height of the destination rectangle.

  - ### drawImage

    public void drawImage(Image img, double sx, double sy, double sw, double sh, double dx, double dy, double dw, double dh)
    Draws the specified source rectangle of the given image to the given destination rectangle of the Canvas. A `null` image value or an image still in progress will be ignored.

    This method will be affected by any of the global common or image attributes as specified in the Rendering Attributes Table.

    Parameters:
      `img` - the image to be drawn or null.
      `sx` - the source rectangle's X coordinate position.
      `sy` - the source rectangle's Y coordinate position.
      `sw` - the source rectangle's width.
      `sh` - the source rectangle's height.
      `dx` - the destination rectangle's X coordinate position.
      `dy` - the destination rectangle's Y coordinate position.
      `dw` - the destination rectangle's width.
      `dh` - the destination rectangle's height.

  - ### getPixelWriter

    public PixelWriter getPixelWriter()
    Returns a `PixelWriter` object that can be used to modify the pixels of the `Canvas` associated with this `GraphicsContext`. All coordinates in the `PixelWriter` methods on the returned object will be in device space since they refer directly to pixels and no other rendering attributes will be applied when modifying pixels using this object.
    Returns:
      the `PixelWriter` for modifying the pixels of this `Canvas`

  - ### setEffect

    public void setEffect(Effect e)
    Sets the effect to be applied after the next draw call, or null to disable effects. The current effect is a common attribute used for nearly all rendering operations as specified in the Rendering Attributes Table.
    Parameters:
      `e` - the effect to use, or null to disable effects

  - ### getEffect

    public Effect getEffect(Effect e)
    Gets a copy of the effect to be applied after the next draw call. A null return value means that no effect will be applied after subsequent rendering calls. The current effect is a common attribute used for nearly all rendering operations as specified in the Rendering Attributes Table.
    Parameters:
      `e` - an `Effect` object that may be used to store the copy of the current effect, if it is of a compatible type
    Returns:
      the current effect used for all rendering calls, or null if there is no current effect

  - ### applyEffect

    public void applyEffect(Effect e)
    Applies the given effect to the entire bounds of the canvas and stores the result back into the same canvas. A `null` value will be ignored. The effect will be applied without any other rendering attributes and under an Identity coordinate transform. Since the effect is applied to the entire bounds of the canvas, some effects may have a confusing result, such as a Reflection effect that will apply its reflection off of the bottom of the canvas even if only a portion of the canvas has been rendered to and will not be visible unless a negative offset is used to bring the reflection back into view.
    Parameters:
      `e` - the effect to apply onto the entire destination or null.