public class Surface extends java.lang.Object implements Closeable
Note: all rendering operations to a surface must be enclosed in calls to
begin()
and end()
. This ensures that the batch into which
the surface is rendering is properly flushed to the GPU at the right times.
Closeable.Set, Closeable.Util
Constructor and Description |
---|
Surface(Graphics gfx,
RenderTarget target,
QuadBatch defaultBatch)
Creates a surface which will render to
target using defaultBatch as its
default quad renderer. |
Modifier and Type | Method and Description |
---|---|
float |
alpha()
Returns the currently configured alpha.
|
Surface |
begin()
Starts a series of drawing commands to this surface.
|
Surface |
clear()
Clears the entire surface to transparent blackness.
|
Surface |
clear(float red,
float green,
float blue,
float alpha)
Clears the entire surface to the specified color.
|
void |
close() |
int |
combineTint(int tint)
Combines
tint with the current tint via Tint.combine(int, int) . |
Surface |
concatenate(AffineTransform xf,
float originX,
float originY)
Concatenates
xf onto this surface's transform, accounting for the origin . |
Surface |
draw(Tile tile,
float x,
float y)
Draws a tile at the specified location:
x, y . |
Surface |
draw(Tile tile,
float x,
float y,
float w,
float h)
Draws a tile at the specified location
(x, y) and size (w x h) . |
Surface |
draw(Tile tile,
float dx,
float dy,
float dw,
float dh,
float sx,
float sy,
float sw,
float sh)
Draws a scaled subset of an image (defined by
(sx, sy) and (w x h) ) at the
specified location (dx, dy) and size (dw x dh) . |
Surface |
draw(Tile tile,
int tint,
float x,
float y,
float w,
float h)
Draws a tile at the specified location
(x, y) and size (w x h) , with tint
tint . |
Surface |
draw(Tile tile,
int tint,
float dx,
float dy,
float dw,
float dh,
float sx,
float sy,
float sw,
float sh)
Draws a scaled subset of an image (defined by
(sx, sy) and (w x h) ) at the
specified location (dx, dy) and size (dw x dh) , with tint tint . |
Surface |
drawCentered(Tile tile,
float x,
float y)
Draws a texture tile, centered at the specified location.
|
Surface |
drawLine(float x0,
float y0,
float x1,
float y1,
float width)
Fills a line between the specified coordinates, of the specified display unit width.
|
Surface |
drawLine(XY a,
XY b,
float width)
Fills a line between the specified coordinates, of the specified display unit width.
|
Surface |
end()
Completes a series of drawing commands to this surface.
|
void |
endClipped()
Ends a series of drawing commands that were clipped per a call to
startClipped(int, int, int, int) . |
Surface |
fillRect(float x,
float y,
float width,
float height)
Fills the specified rectangle.
|
boolean |
intersects(float x,
float y,
float w,
float h)
Returns whether the given rectangle intersects the render target area of this surface.
|
void |
popBatch(QuadBatch oldBatch)
Restores the batch that was in effect prior to a
pushBatch(playn.core.QuadBatch) call. |
Surface |
preConcatenate(AffineTransform xf)
Pre-concatenates
xf onto this surface's transform. |
QuadBatch |
pushBatch(QuadBatch newBatch)
Configures this surface to use
batch , if non-null. |
Surface |
restoreTx()
Restores the transform previously stored by
saveTx() . |
Surface |
rotate(float angle)
Rotates the current transformation matrix by the specified angle in radians.
|
Surface |
saveTx()
Saves the current transform.
|
Surface |
scale(float sx,
float sy)
Scales the current transformation matrix by the specified amount on each axis.
|
Surface |
setAlpha(float alpha)
Set the alpha component of this surface's current tint.
|
void |
setCheckIntersection(boolean checkIntersection)
Configures this surface to check the bounds of drawn
Tile s to ensure that they
intersect our visible bounds before adding them to our GPU batch. |
Surface |
setFillColor(int color)
Sets the color to be used for fill operations.
|
Surface |
setFillPattern(Texture texture)
Sets the texture to be used for fill operations.
|
Surface |
setTint(int tint)
Sets the tint to be applied to draw operations, as
ARGB . |
boolean |
startClipped(int x,
int y,
int width,
int height)
Starts a series of drawing commands that are clipped to the specified rectangle (in view
coordinates, not OpenGL coordinates).
|
int |
tint()
Returns the currently configured tint.
|
Surface |
transform(float m00,
float m01,
float m10,
float m11,
float tx,
float ty)
Multiplies the current transformation matrix by the given matrix.
|
Surface |
translate(float x,
float y)
Translates the current transformation matrix by the given amount.
|
AffineTransform |
tx()
Returns the current transform.
|
public Surface(Graphics gfx, RenderTarget target, QuadBatch defaultBatch)
target
using defaultBatch
as its
default quad renderer.public void setCheckIntersection(boolean checkIntersection)
Tile
s to ensure that they
intersect our visible bounds before adding them to our GPU batch. If you draw a lot of totally
out of bounds images, this may increase your draw performance.public Surface begin()
public Surface end()
public QuadBatch pushBatch(QuadBatch newBatch)
batch
, if non-null. NOOPs otherwise.popBatch(playn.core.QuadBatch)
when rendering is done with this
batch.public void popBatch(QuadBatch oldBatch)
pushBatch(playn.core.QuadBatch)
call.public AffineTransform tx()
public Surface saveTx()
public boolean startClipped(int x, int y, int width, int height)
endClipped()
when the clipped drawing commands are done.endClipped()
.public void endClipped()
startClipped(int, int, int, int)
.public Surface translate(float x, float y)
public Surface scale(float sx, float sy)
public Surface rotate(float angle)
public Surface transform(float m00, float m01, float m10, float m11, float tx, float ty)
public Surface concatenate(AffineTransform xf, float originX, float originY)
xf
onto this surface's transform, accounting for the origin
.public Surface preConcatenate(AffineTransform xf)
xf
onto this surface's transform.public float alpha()
public Surface setAlpha(float alpha)
setTint(int)
.
Values outside the range [0,1] will be clamped to the range [0,1].
alpha
- value in range [0,1] where 0 is transparent and 1 is opaque.public int tint()
public Surface setTint(int tint)
ARGB
. NOTE: this will
overwrite any value configured via setAlpha(float)
. Either include your desired alpha in
the high bits of tint
or call setAlpha(float)
after calling this method.public int combineTint(int tint)
tint
with the current tint via Tint.combine(int, int)
.public Surface setFillColor(int color)
public Surface setFillPattern(Texture texture)
public boolean intersects(float x, float y, float w, float h)
public Surface clear()
public Surface clear(float red, float green, float blue, float alpha)
[0,1]
.public Surface draw(Tile tile, float x, float y, float w, float h)
(x, y)
and size (w x h)
.public Surface draw(Tile tile, int tint, float x, float y, float w, float h)
(x, y)
and size (w x h)
, with tint
tint
. Note: this will override any tint and alpha currently configured on
this surface.public Surface draw(Tile tile, float dx, float dy, float dw, float dh, float sx, float sy, float sw, float sh)
(sx, sy)
and (w x h)
) at the
specified location (dx, dy)
and size (dw x dh)
.public Surface draw(Tile tile, int tint, float dx, float dy, float dw, float dh, float sx, float sy, float sw, float sh)
(sx, sy)
and (w x h)
) at the
specified location (dx, dy)
and size (dw x dh)
, with tint tint
.
Note: this will override any tint and alpha currently configured on this surface.public Surface drawCentered(Tile tile, float x, float y)
public Surface drawLine(XY a, XY b, float width)
public Surface drawLine(float x0, float y0, float x1, float y1, float width)
public Surface fillRect(float x, float y, float width, float height)
Copyright © 2019. All Rights Reserved.