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.VisitorNested classes/interfaces inherited from interface react.Closeable
Closeable.Set, Closeable.Util -
Field Summary
Fields inherited from class playn.scene.ImageLayer
forceHeight, forceWidth, regionFields inherited from class playn.scene.Layer
DEBUG_RECTS, state -
Constructor Summary
ConstructorsConstructorDescriptionCanvasLayer(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.voidclose()Disposes this layer, removing it from its parent layer.voidend()Informs this layer that a drawing operation has just completed.floatheight()Returns the height of this layer.voidresize(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.floatwidth()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:ImageLayerSets the texture rendered by this layer. One can suppliednullto 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:
setTilein classImageLayer
-
setTile
Description copied from class:ImageLayerSets 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:
setTilein classImageLayer
-
width
public float width()Description copied from class:LayerReturns the width of this layer. Note: not all layers know their size. Those that don't return 0.- Overrides:
widthin classImageLayer
-
height
public float height()Description copied from class:LayerReturns the height of this layer. Note: not all layers know their size. Those that don't return 0.- Overrides:
heightin classImageLayer
-
close
public void close()Description copied from class:LayerDisposes 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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classImageLayer
-