| Modifier and Type | Class and Description |
|---|---|
static class |
Canvas.Composite
Values that may be used with
setCompositeOperation(Composite). |
static interface |
Canvas.Drawable
Facilitates drawing images and image regions to a canvas.
|
static class |
Canvas.LineCap
Values that may be used with
setLineCap(LineCap). |
static class |
Canvas.LineJoin
Values that may be used with
setLineJoin(LineJoin). |
Closeable.Set, Closeable.Util| Modifier and Type | Field and Description |
|---|---|
float |
height
The height of this canvas.
|
Image |
image
The image that underlies this canvas.
|
float |
width
The width of this canvas.
|
| Modifier and Type | Method and Description |
|---|---|
abstract Canvas |
clear()
Clears the entire canvas to
rgba(0, 0, 0, 0). |
abstract Canvas |
clearRect(float x,
float y,
float width,
float height)
Clears the specified region to
rgba (0, 0, 0, 0). |
abstract Canvas |
clip(Path clipPath)
Intersects the current clip with the specified path.
|
abstract Canvas |
clipRect(float x,
float y,
float width,
float height)
Intersects the current clip with the supplied rectangle.
|
void |
close()
Informs the platform that this canvas, and its backing image will no longer be used.
|
Gradient |
createGradient(Gradient.Config config)
Creates a gradient fill pattern.
|
Path |
createPath()
Creates a path object.
|
Canvas |
draw(Canvas.Drawable image,
float x,
float y)
Draws
image at the specified location (x, y). |
Canvas |
draw(Canvas.Drawable image,
float x,
float y,
float w,
float h)
Draws a scaled image at the specified location
(x, y) size (w x h). |
Canvas |
draw(Canvas.Drawable image,
float dx,
float dy,
float dw,
float dh,
float sx,
float sy,
float sw,
float sh)
Draws a subregion of a image
(sw x sh) @ (sx, sy) at the specified size
(dw x dh) and location (dx, dy). |
abstract Canvas |
drawArc(float cx,
float cy,
float r,
float startAngle,
float arcAngle)
Draws an arc of a circle centered at cx, cy, with radius r.
|
Canvas |
drawCentered(Canvas.Drawable image,
float x,
float y)
Draws
image centered at the specified location. |
abstract Canvas |
drawLine(float x0,
float y0,
float x1,
float y1)
Draws a line between the two specified points.
|
abstract Canvas |
drawPoint(float x,
float y)
Draws a single point at the specified location.
|
abstract Canvas |
drawText(java.lang.String text,
float x,
float y)
Draws text at the specified location.
|
abstract Canvas |
fillCircle(float x,
float y,
float radius)
Fills a circle at the specified center and radius.
|
abstract Canvas |
fillPath(Path path)
Fills the specified path.
|
abstract Canvas |
fillRect(float x,
float y,
float width,
float height)
Fills the specified rectangle.
|
abstract Canvas |
fillRoundRect(float x,
float y,
float width,
float height,
float radius)
Fills the specified rounded rectangle.
|
abstract Canvas |
fillText(TextLayout text,
float x,
float y)
Fills the text at the specified location.
|
abstract Canvas |
restore()
Restores the canvas's previous state.
|
abstract Canvas |
rotate(float radians)
Rotates the current transformation matrix by the specified angle in radians.
|
abstract Canvas |
save()
The save and restore methods preserve and restore the state of the canvas,
but not specific paths or graphics.
|
abstract Canvas |
scale(float x,
float y)
Scales the current transformation matrix by the specified amount.
|
abstract Canvas |
setAlpha(float alpha)
Set the global alpha value to be used for all painting.
|
abstract Canvas |
setCompositeOperation(Canvas.Composite composite)
Sets the Porter-Duff composite operation to be used for all painting.
|
abstract Canvas |
setFillColor(int color)
Sets the color to be used for fill operations.
|
abstract Canvas |
setFillGradient(Gradient gradient)
Sets the gradient to be used for fill operations.
|
abstract Canvas |
setFillPattern(Pattern pattern)
Sets the pattern to be used for fill operations.
|
abstract Canvas |
setLineCap(Canvas.LineCap cap)
Sets the line-cap mode for strokes.
|
abstract Canvas |
setLineJoin(Canvas.LineJoin join)
Sets the line-join mode for strokes.
|
abstract Canvas |
setMiterLimit(float miter)
Sets the miter limit for strokes.
|
abstract Canvas |
setStrokeColor(int color)
Sets the color for strokes.
|
abstract Canvas |
setStrokeWidth(float strokeWidth)
Sets the width for strokes, in pixels.
|
abstract Image |
snapshot()
Returns an immutable snapshot of the image that backs this canvas.
|
abstract Canvas |
strokeCircle(float x,
float y,
float radius)
Strokes a circle at the specified center and radius.
|
abstract Canvas |
strokePath(Path path)
Strokes the specified path.
|
abstract Canvas |
strokeRect(float x,
float y,
float width,
float height)
Strokes the specified rectangle.
|
abstract Canvas |
strokeRoundRect(float x,
float y,
float width,
float height,
float radius)
Strokes the specified rounded rectangle.
|
abstract Canvas |
strokeText(TextLayout text,
float x,
float y)
Strokes the text at the specified location.
|
Texture |
toTexture()
Calls
toTexture(Texture.Config) with the default texture config. |
Texture |
toTexture(Texture.Config config)
A helper function for creating a texture from this canvas's image, and then disposing this
canvas.
|
abstract Canvas |
transform(float m11,
float m12,
float m21,
float m22,
float dx,
float dy)
Multiplies the current transformation matrix by the given matrix.
|
abstract Canvas |
translate(float x,
float y)
Translates the current transformation matrix by the given amount.
|
public final Image image
public final float width
public final float height
public abstract Image snapshot()
public void close()
public abstract Canvas clear()
rgba(0, 0, 0, 0).public abstract Canvas clearRect(float x, float y, float width, float height)
rgba (0, 0, 0, 0).public abstract Canvas clip(Path clipPath)
public abstract Canvas clipRect(float x, float y, float width, float height)
public Path createPath()
public Gradient createGradient(Gradient.Config config)
public Canvas draw(Canvas.Drawable image, float x, float y)
image at the specified location (x, y).public Canvas drawCentered(Canvas.Drawable image, float x, float y)
image centered at the specified location. Subtracts image.width/2 from x
and image.height/2 from y.public Canvas draw(Canvas.Drawable image, float x, float y, float w, float h)
(x, y) size (w x h).public Canvas draw(Canvas.Drawable image, float dx, float dy, float dw, float dh, float sx, float sy, float sw, float sh)
(sw x sh) @ (sx, sy) at the specified size
(dw x dh) and location (dx, dy).
TODO (jgw): Document whether out-of-bounds source coordinates clamp, repeat, or do nothing.public abstract Canvas drawLine(float x0, float y0, float x1, float y1)
public abstract Canvas drawPoint(float x, float y)
public abstract Canvas drawArc(float cx, float cy, float r, float startAngle, float arcAngle)
The start and arc angles are specified in radians. Angles are interpreted such that 0 radians is at the 3 o'clock position. Positive values indicate a counter-clockwise rotation while negative values indicate a clockwise rotation.
public abstract Canvas drawText(java.lang.String text, float x, float y)
public abstract Canvas fillCircle(float x, float y, float radius)
public abstract Canvas fillRect(float x, float y, float width, float height)
public abstract Canvas fillRoundRect(float x, float y, float width, float height, float radius)
x - the x coordinate of the upper left of the rounded rectangle.y - the y coordinate of the upper left of the rounded rectangle.width - the width of the rounded rectangle.height - the width of the rounded rectangle.radius - the radius of the circle to use for the corner.public abstract Canvas fillText(TextLayout text, float x, float y)
public abstract Canvas rotate(float radians)
public abstract Canvas save()
public abstract Canvas scale(float x, float y)
public abstract Canvas setAlpha(float alpha)
Values outside the range [0,1] will be clamped to the range [0,1].
alpha - alpha value in range [0,1] where 0 is transparent and 1 is opaquepublic abstract Canvas setCompositeOperation(Canvas.Composite composite)
public abstract Canvas setFillColor(int color)
public abstract Canvas setFillGradient(Gradient gradient)
public abstract Canvas setFillPattern(Pattern pattern)
public abstract Canvas setLineCap(Canvas.LineCap cap)
public abstract Canvas setLineJoin(Canvas.LineJoin join)
public abstract Canvas setMiterLimit(float miter)
public abstract Canvas setStrokeColor(int color)
public abstract Canvas setStrokeWidth(float strokeWidth)
public abstract Canvas strokeCircle(float x, float y, float radius)
public abstract Canvas strokeRect(float x, float y, float width, float height)
public abstract Canvas strokeRoundRect(float x, float y, float width, float height, float radius)
x - the x coordinate of the upper left of the rounded rectangle.y - the y coordinate of the upper left of the rounded rectangle.width - the width of the rounded rectangle.height - the width of the rounded rectangle.radius - the radius of the circle to use for the corner.public abstract Canvas strokeText(TextLayout text, float x, float y)
public Texture toTexture()
toTexture(Texture.Config) with the default texture config.public Texture toTexture(Texture.Config config)
public abstract Canvas transform(float m11, float m12, float m21, float m22, float dx, float dy)
public abstract Canvas translate(float x, float y)
Copyright © 2018. All Rights Reserved.