Package playn.scene
Class CanvasLayer
java.lang.Object
playn.scene.Layer
playn.scene.ImageLayer
playn.scene.CanvasLayer
- All Implemented Interfaces:
AutoCloseable
,Closeable
-
Nested Class Summary
Nested classes/interfaces inherited from class playn.scene.Layer
Layer.HitTester, Layer.Origin, Layer.State, Layer.Visitor
Nested classes/interfaces inherited from interface react.Closeable
Closeable.Set, Closeable.Util
-
Field Summary
Fields inherited from class playn.scene.ImageLayer
forceHeight, forceWidth, region
Fields inherited from class playn.scene.Layer
DEBUG_RECTS, state
-
Constructor Summary
ConstructorDescriptionCanvasLayer
(Graphics gfx, float width, float height) Creates a canvas layer with a backing canvas of sizewidth x height
(in display units).CanvasLayer
(Graphics gfx, Canvas canvas) Creates a canvas layer with the supplied backing canvas.CanvasLayer
(Graphics gfx, IDimension size) Creates a canvas layer with a backing canvas ofsize
(in display units). -
Method Summary
Modifier and TypeMethodDescriptionbegin()
Starts a drawing operation on this layer's backing canvas.void
close()
Disposes this layer, removing it from its parent layer.void
end()
Informs this layer that a drawing operation has just completed.float
height()
Returns the height of this layer.void
resize
(float width, float height) Resizes the canvas that is displayed by this layer.Sets the texture rendered by this layer.Sets the tile rendered by this layer to the asynchronous result oftile
.float
width()
Returns the width of this layer.Methods inherited from class playn.scene.Layer
absorbHits, alpha, debugPrint, depth, disposed, events, hasEventListeners, hitTest, hitTestDefault, interactive, name, onAdded, onDisposed, onRemoved, origin, origin, originX, originY, paint, parent, rotation, scale, scaledHeight, scaledWidth, scaleX, scaleY, setAlpha, setBatch, setDepth, setHitTester, setInteractive, setName, setOrigin, setOrigin, setRotation, setScale, setScale, setScaleX, setScaleY, setTint, setTranslation, setTranslation, setTx, setTy, setVisible, tint, toString, transform, translation, translation, tx, ty, visible, visit
-
Constructor Details
-
CanvasLayer
-
CanvasLayer
-
CanvasLayer
Creates a canvas layer with the supplied backing canvas. The canvas will immediately be uploaded to the GPU for display.
-
-
Method Details
-
resize
public void resize(float width, float height) Resizes the canvas that is displayed by this layer.Note: this throws away the old canvas and creates a new blank canvas with the desired size. Thus this should immediately be followed by a
begin()
/end()
pair which updates the contents of the new canvas. Until then, it will display the old image data. -
begin
Starts a drawing operation on this layer's backing canvas. Thus must be follwed by a call toend()
when the drawing is complete. -
end
public void end()Informs this layer that a drawing operation has just completed. The backing canvas image data is uploaded to the GPU. -
setTile
Description copied from class:ImageLayer
Sets the texture rendered by this layer. One can suppliednull
to release and clear any texture currently being rendered and leave this layer in an uninitialized state. This isn't something one would normally do, but could be useful if one was free-listing image layers for some reason.- Overrides:
setTile
in classImageLayer
-
setTile
Description copied from class:ImageLayer
Sets the tile rendered by this layer to the asynchronous result oftile
. When the future completes, this layer's tile will be set. Until then, the current tile (if any) will continue to be rendered.- Overrides:
setTile
in classImageLayer
-
width
public float width()Description copied from class:Layer
Returns the width of this layer. Note: not all layers know their size. Those that don't return 0.- Overrides:
width
in classImageLayer
-
height
public float height()Description copied from class:Layer
Returns the height of this layer. Note: not all layers know their size. Those that don't return 0.- Overrides:
height
in classImageLayer
-
close
public void close()Description copied from class:Layer
Disposes this layer, removing it from its parent layer. Any resources associated with this layer are freed, and it cannot be reused after being disposed. Disposing a layer that has children will dispose them as well.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classImageLayer
-