Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: Canvas

[33:7] extends: Node

Wraps JavaFX Canvas, an image surface that supports direct drawing via a GraphicsContext. Unlike scene graph nodes, drawing operations are immediate and do not create child nodes. Call getGraphicsContext() to obtain the drawing API. Canvas has no class-specific CSS properties beyond those inherited from Node.

CSS Properties -- Node

Property Values Default Description
-fx-blend-mode add | blue | color-burn | color-dodge | darken | difference | exclusion | green | hard-light | lighten | multiply | overlay | red | screen | soft-light | src-atop | src-in | src-out | src-over null Blend mode used when compositing this node with nodes beneath it.
-fx-cursor null | crosshair | default | hand | move | e-resize | h-resize | ne-resize | nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize | v-resize | text | wait | <url> null (inherits) Mouse cursor shape shown when the pointer is over this node. Inherits from parent by default.
-fx-effect <effect> null A visual effect (e.g. DropShadow, InnerShadow) applied to the rendered node.
-fx-focus-traversable true | false false Whether this node participates in focus traversal.
-fx-view-order <number> 0 Adjusts rendering and hit-test order within the parent without changing the scene graph order.
-fx-opacity <number> [0.0 - 1.0] 1 Opacity of the node. 0 is fully transparent, 1 is fully opaque.
-fx-rotate <number> 0 Rotation angle in degrees applied around the node's center point.
-fx-scale-x <number> 1 Scale factor along the X axis about the node's center.
-fx-scale-y <number> 1 Scale factor along the Y axis about the node's center.
-fx-scale-z <number> 1 Scale factor along the Z axis about the node's center.
-fx-translate-x <number> 0 Translation offset along the X axis in pixels.
-fx-translate-y <number> 0 Translation offset along the Y axis in pixels.
-fx-translate-z <number> 0 Translation offset along the Z axis in pixels.
visibility visible | hidden | collapse | inherit visible Controls whether the node is rendered and participates in layout.
-fx-managed true | false true When false, the parent layout does not manage this node's position or size.

Methods

  • Canvas (double Width, double Height)

    Creates a new Canvas with the specified width and height.

    • @p Width is a double with the canvas width in pixels.
    • @p Height is a double with the canvas height in pixels.
  • getGraphicsContext ()

    Returns a GraphicsContext object for drawing on this canvas.

    • @r A GraphicsContext object.
  • getWidth ()

    Returns the width of the canvas.

    • @r A double with the width.
  • getHeight ()

    Returns the height of the canvas.

    • @r A double with the height.