public class Canvas extends Object
This class draws text, image, and basic graphics such as rectangle, circle, and line.
It uses attributes in Paint, such as color, paint style, and line thickness.
Coordinates in this class are in unit of pixels.
| 限定符和类型 | 类 | 说明 |
|---|---|---|
static class |
Canvas.ClipOp |
Enumerates the modes for clipping the canvas with a particular path.
|
static class |
Canvas.PorterDuffMode |
Enumerates color blend modes.
|
static class |
Canvas.VertexMode |
Enumerates graphic shapes formed by connecting vertices.
|
| 构造器 | 说明 |
|---|---|
Canvas() |
Default constructor used to create a
Canvas instance. |
Canvas(long nativeCanvasHandle) |
The constructor used to create a
Canvas instance by the nativeHandle. |
Canvas(Texture texture) |
A constructor used to create a
Canvas instance for off-screen rendering with the specified
texture. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
clipPath(Path path,
Canvas.ClipOp op) |
Clips the canvas with the specified path in the given mode.
|
void |
clipRect(float left,
float top,
float right,
float bottom) |
Modifies the canvas size based on the specified rectangle values.
|
void |
clipRect(int left,
int top,
int right,
float bottom) |
Modifies the canvas size based on the specified rectangle values.
|
void |
clipRect(Rect rect) |
Cuts a specified rectangle from this canvas.
|
void |
clipRect(RectFloat rect) |
Clips a specified rectangle out of a canvas.
|
void |
clipRect(RectFloat rect,
Canvas.ClipOp op) |
Clips a specified rectangle in a specified mode.
|
void |
concat(Matrix matrix) |
Transforms the current matrix with a specified matrix.
|
void |
drawArc(RectFloat rect,
Arc arc,
Paint paint) |
Draws an arc on the canvas.
|
void |
drawArc(RectFloat rect,
Arc arc,
Paint paint,
Color color) |
Draws an arc on the canvas.
|
void |
drawChangelessTexture(float posX,
float posY,
Texture texture) |
Draws a changeless texture.
|
void |
drawChars(Paint paint,
char[] charArray,
float xCoor,
float yCoor) |
Draws text of the char type.
|
void |
drawCharSequence(Paint paint,
CharSequence charSequence,
float xCoor,
float yCoor) |
Draws text of the CharSequence type.
|
void |
drawCircle(float x,
float y,
float radius,
Paint paint) |
Draws a circle on the canvas.
|
void |
drawCircle(float x,
float y,
float radius,
Paint paint,
Color color) |
Draws a circle on this canvas based on x- and y-coordinates of the circle's center, radius of the circle,
a specified paint and color.
|
void |
drawCircle(Circle circle,
Paint paint) |
Draws a circle on this canvas with a specified paint.
|
void |
drawCircle(Circle circle,
Paint paint,
Color color) |
Draws a circle on this canvas with a specified paint, and color.
|
void |
drawCircle(Point center,
float radius,
Paint paint) |
Draws a circle on this canvas based on specified center coordinates and radius.
|
void |
drawCircle(Point center,
float radius,
Paint paint,
Color color) |
Draws a circle on this canvas based on a specified center, radius, paint, and color.
|
void |
drawColor(int color,
BlendMode mode) |
Fills this canvas with a specified color.
|
void |
drawColor(int color,
Canvas.PorterDuffMode mode) |
Fills the canvas with a specified color.
|
void |
drawDeformedPixelMap(PixelMapHolder holder,
PixelMapDrawInfo drawInfo,
Paint paint) |
Draws a pixel map that can be deformed.
|
void |
drawLine(float startX,
float startY,
float endX,
float endY,
Paint paint) |
Draws a line on this canvas based on specified coordinates of start and end points.
|
void |
drawLine(float startX,
float startY,
float endX,
float endY,
Paint paint,
Color color) |
Draws a line on this canvas with a specified paint and color, based on specified coordinates of start
and end points.
|
void |
drawLine(Line line,
Paint paint) |
Draws a line on this canvas.
|
void |
drawLine(Line line,
Paint paint,
Color color) |
Draws a line on this canvas with a specified paint and color.
|
void |
drawLine(Point startPoint,
Point endPoint,
Paint paint) |
Draws a straight line on the canvas.
|
void |
drawLines(float[] points,
int offset,
int drawCount,
Paint paint) |
Draws multiple specified line segments.
|
void |
drawLines(float[] points,
Paint paint) |
Draws multiple lines on a canvas.
|
void |
drawOval(RectFloat rect,
Paint paint) |
Draws an oval on the canvas.
|
void |
drawOval(RectFloat rect,
Paint paint,
Color color) |
Draws an oval on the canvas.
|
void |
drawPaint(Paint paint) |
Fills the canvas with a specified paint.
|
void |
drawPath(Path path,
Paint paint) |
Draws a path using the specified paint.
|
void |
drawPicture(Picture picture) |
Draws a picture.
|
void |
drawPicture(Picture picture,
RectFloat destRectangle) |
Draws a picture in a specified area.
|
void |
drawPixelMapHolder(PixelMapHolder holder,
float left,
float top,
Paint paint) |
Draws a specific
PixelMapHolder object and specifies the distance from the object to the upper left
corner of the parent component. |
void |
drawPixelMapHolderCircleShape(PixelMapHolder holder,
RectFloat rectSrc,
float pointX,
float pointY,
float radius) |
Draws a circular
PixelMapHolder object. |
void |
drawPixelMapHolderRect(PixelMapHolder holder,
RectFloat rect,
Paint paint) |
Draws a
PixelMapHolder object into a destination rectangle. |
void |
drawPixelMapHolderRect(PixelMapHolder holder,
RectFloat rectSrc,
RectFloat rectDst,
Paint paint) |
Draws a rectangular
PixelMapHolder object into a destination rectangle. |
void |
drawPixelMapHolderRoundRectShape(PixelMapHolder holder,
RectFloat rectSrc,
RectFloat rectDst,
float radiusX,
float radiusY) |
Draws a round-rectangular
PixelMapHolder object. |
void |
drawPoint(float posX,
float posY,
Paint paint) |
Draws a point.
|
void |
drawPoint(Point pos,
Paint paint) |
Draws a point on this canvas.
|
void |
drawPoint(Point point,
Paint paint,
Color color) |
Draws a point on this canvas at a specified position, with a specified paint and color.
|
void |
drawPoints(float[] pts,
int offset,
int count,
Paint paint) |
Draws a group of points.
|
void |
drawPolylineShadow(float[] points,
Point startColorPoint,
Point endColorPoint,
Paint paint) |
Draws a gradient polyline.
|
void |
drawRect(float left,
float top,
float right,
float bottom,
Paint paint) |
Draws the specified rectangle on the canvas.
|
void |
drawRect(float left,
float top,
float right,
float bottom,
Paint paint,
Color color) |
Draws a rectangle on this canvas based specified bounds, with a specified paint and color.
|
void |
drawRect(RectFloat rect,
Paint paint) |
Draws a rectangle on the canvas.
|
void |
drawRect(RectFloat rectFloat,
Paint paint,
Color color) |
Draws a rectangle on this canvas with a specified paint and color.
|
void |
drawRect(Rect rect,
Paint paint) |
Draws the specified rectangle on the canvas.
|
void |
drawRegion(Region region,
Paint paint) |
Draws a region on this canvas.
|
void |
drawRoundRect(RectFloat rect,
float radiusX,
float radiusY,
Paint paint) |
Draws a rounded rectangle on the canvas.
|
void |
drawRoundRect(RectFloat rect,
float radiusX,
float radiusY,
Paint paint,
Color color) |
Draws a rounded rectangle on the canvas.
|
void |
drawText(Paint paint,
String text,
float x,
float y) |
Draws text at the specified coordinate origin.
|
void |
drawTextOnPath(Paint paint,
String text,
Path path,
float advance,
float offset) |
Draws text on the specified path.
|
void |
drawTexture(float posX,
float posY,
Texture texture) |
Draws the texture that stores the drawing result on the screen.
|
void |
drawVertices(Canvas.VertexMode mode,
Vertices vertices,
Paint paint) |
Draws vertices.
|
Rect |
getDeviceClipBounds() |
Obtains the clip bounds represented by device coordinates.
|
boolean |
getDeviceClipBounds(Rect bounds) |
Obtains the clip bounds represented by device coordinates, which is specified by
bounds. |
int |
getDeviceDensity(Context context) |
Obtains the device density.
|
Rect |
getLocalClipBounds() |
Return the bounds of the clip in the parameter and return true if it is not empty.
|
boolean |
getLocalClipBounds(Rect bounds) |
Obtains the clip bounds represented by local coordinates.
|
void |
getMatrix(Matrix matrix) |
Obtains the current transformation matrix on the canvas.
|
int |
getSaveCount() |
Obtains the number of canvas states saved on the stack.
|
boolean |
quickReject(float left,
float top,
float right,
float bottom) |
Quickly checks whether the canvas's visible area intersects with the clip area.
|
boolean |
quickRejectPath(Path path) |
Quickly checks whether specified path does not intersect the clip region.
|
boolean |
quickRejectRect(RectFloat rectFloat) |
Quickly checks whether specified rectangle does not intersect the clip region.
|
void |
resetMatrix() |
Resets the matrix.
|
void |
restore() |
Restores the canvas to its latest drawing state saved.
|
void |
restoreToCount(int saveCount) |
Restores the canvas to the drawing state specified by
saveCount. |
void |
rotate(float degree) |
Rotates this canvas.
|
void |
rotate(float degree,
float x,
float y) |
Rotates the canvas by a given angle relative to the rotation center.
|
int |
save() |
Saves the drawing state of the canvas.
|
int |
saveLayer(RectFloat bounds,
Paint paint) |
Saves the current layer and creates a layer of a specified size.
|
int |
saveLayerAlpha(RectFloat bounds,
int alpha) |
Saves the current layer and creates a layer with a specified size and alpha value.
|
void |
scale(float scaleX,
float scaleY) |
Scales the canvas according to the anchor point.
|
void |
scale(float scaleX,
float scaleY,
float pointX,
float pointY) |
Scales a canvas with an anchor point.
|
void |
setMatrix(Matrix matrix) |
Replaces the matrix stored in a canvas with a new one.
|
void |
setTexture(Texture texture) |
Sets the canvas texture for off-screen rendering.
|
void |
skew(float sx,
float sy) |
Skews this
Canvas. |
void |
translate(float distanceX,
float distanceY) |
Translates a canvas by a specified distance.
|
public Canvas()
Canvas instance.public Canvas(long nativeCanvasHandle)
Canvas instance by the nativeHandle.nativeCanvasHandle - Indicates the nativeHandle.public void drawRect(RectFloat rect, Paint paint)
The rectangle is drawn using the parameter RectFloat.
rect - Indicates the coordinates of the upper left and lower right corners of the rectangle.paint - Indicates paint attributes describing color, line thickness, and paint style.public void drawRect(RectFloat rectFloat, Paint paint, Color color)
rectFloat - Indicates the rectangle to draw.paint - Indicates the paint used to draw the rectangle, which defines paint attributes such as the color,
line thickness, and paint style.color - Indicates the specified paint color.public void drawRect(float left,
float top,
float right,
float bottom,
Paint paint)
left - Indicates the left bound of the rectangle.top - Indicates the top bound of the rectangle.right - Indicates the right bound of the rectangle.bottom - Indicates the bottom bound of the rectangle.paint - Indicates the paint attributes including the color, line thickness, and paint style.public void drawRect(float left,
float top,
float right,
float bottom,
Paint paint,
Color color)
left - Indicates the value for the left bound of the rectangle.top - Indicates the value for the top bound of the rectangle.right - Indicates the value for the right bound of the rectangle.bottom - Indicates the value for the bottom bound of the rectangle.paint - Indicates the paint used to draw the rectangle, which defines paint attributes such as the color,
line thickness, and paint style.color - Indicates the specified paint color.public void drawRect(Rect rect, Paint paint)
rect - Indicates the rectangle to draw.paint - Indicates the paint attributes including the color, line thickness, and paint style.public void drawCircle(float x,
float y,
float radius,
Paint paint)
The circle is drawn using specified center, radius, and Paint attributes.
x - Indicates the X-axis coordinate of the center.y - Indicates the Y-axis coordinate of the center.radius - Indicates the radius.paint - Indicates paint attributes describing color, line thickness, and paint style.public void drawCircle(Point center, float radius, Paint paint)
center - Indicates the coordinates of the circle's center.radius - Indicates the radius of the circle.paint - Indicates the paint used to draw the circle, which defines paint attributes such as the color,
line thickness, and paint style.public void drawCircle(float x,
float y,
float radius,
Paint paint,
Color color)
x - Indicates the x-coordinate of the circle's center.y - Indicates the y-coordinate of the circle's center.radius - Indicates the radius of the circle.paint - Indicates the paint used to draw the circle, which defines paint attributes such as the color,
line thickness, and paint style.color - Indicates the paint color.public void drawCircle(Circle circle, Paint paint)
circle - Indicates the circle to draw.paint - Indicates the paint used to draw the circle, which defines paint attributes such as the color,
line thickness, and paint style.public void drawCircle(Circle circle, Paint paint, Color color)
circle - Indicates the circle to draw.paint - Indicates the paint used to draw the circle, which defines paint attributes such as the color,
line thickness, and paint style.color - Indicates the paint color.public void drawCircle(Point center, float radius, Paint paint, Color color)
center - Indicates the coordinates of the circle's center.radius - Indicates the radius of the circle.paint - Indicates the paint used to draw the circle, which defines paint attributes such as the color,
line thickness, and paint style.color - Indicates the specified paint color.public void drawRoundRect(RectFloat rect, float radiusX, float radiusY, Paint paint)
The rounded rectangle is drawn using the parameter RectFloat, and the X-axis and Y-axis radiuses
of the ovals used to round the corners of the rectangle.
rect - Indicates the coordinates of the upper left and lower right corners of the enclosing rectangle
of the rounded corner.radiusX - Indicates the X-axis radius of the ovals used to round the corners of the enclosing rectangle.radiusY - Indicates the Y-axis radius of the ovals used to round the corners of the enclosing rectangle.paint - Indicates paint attributes describing color, line thickness, and paint style.public void drawRoundRect(RectFloat rect, float radiusX, float radiusY, Paint paint, Color color)
The rounded rectangle is drawn using the parameter RectFloat, and the X-axis and Y-axis radiuses
of the ovals used to round the corners of the rectangle.
rect - Indicates the coordinates of the upper left and lower right corners of the enclosing rectangle
of the rounded corner.radiusX - Indicates the X-axis radius of the ovals used to round the corners of the enclosing rectangle.radiusY - Indicates the Y-axis radius of the ovals used to round the corners of the enclosing rectangle.paint - Indicates paint attributes describing color, line thickness, and paint style.color - Indicates the color.public void drawLine(Point startPoint, Point endPoint, Paint paint)
The straight line is drawn using specified start and end coordinates.
startPoint - Indicates the start coordinate of the line.endPoint - Indicates the end coordinate of the line.paint - Indicates paint attributes describing color, line thickness, and paint style.public void drawLine(float startX,
float startY,
float endX,
float endY,
Paint paint)
startX - Indicates the x-coordinate of the line's start point.startY - Indicates the y-coordinate of the line's start point.endX - Indicates the x-coordinate of the line's end point.endY - Indicates the y-coordinate of the line's end point.paint - Indicates the paint used to draw the line, which defines paint attributes such as the color,
line thickness, and paint style.public void drawLine(float startX,
float startY,
float endX,
float endY,
Paint paint,
Color color)
startX - Indicates the x-coordinate of the line's start point.startY - Indicates the y-coordinate of the line's start point.endX - Indicates the x-coordinate of the line's end point.endY - Indicates the y-coordinate of the line's end point.paint - Indicates the paint used to draw the line, which defines paint attributes such as the color,
line thickness, and paint style.color - Indicates the specified paint color.public void drawLine(Line line, Paint paint)
line - Indicates the line to draw.paint - Indicates the paint used to draw the line, which defines paint attributes such as the color,
line thickness, and paint style.public void drawLine(Line line, Paint paint, Color color)
line - Indicates the line to draw.paint - Indicates the paint used to draw the line, which defines paint attributes such as the color,
line thickness, and paint style.color - Indicates the specified paint color.public void drawOval(RectFloat rect, Paint paint)
The oval is drawn according to the position and size of its enclosing rectangle.
rect - Indicates the coordinates of the upper left and lower right corners of the enclosing rectangle of
the oval.paint - Indicates paint attributes describing color, line thickness, and paint style.public void drawRegion(Region region, Paint paint)
region - Indicates the region to draw.paint - Indicates the paint used to draw the region, which defines paint attributes such as the color,
line thickness, and paint style.public void drawOval(RectFloat rect, Paint paint, Color color)
The oval is drawn according to the position and size of its enclosing rectangle.
rect - Indicates the coordinates of the upper left and lower right corners of the enclosing rectangle of
the oval.paint - Indicates paint attributes describing color, line thickness, and paint style.color - Indicates the color.public void drawArc(RectFloat rect, Arc arc, Paint paint)
The arc is drawn using the RectFloat and Arc objects.
rect - Indicates the coordinates of the upper left and lower right corners of the enclosing rectangle
of the arc.arc - Indicates the arc parameters such as the start angle, sweep angle, and whether to draw
the lines from both end points of the arc to its center.paint - Indicates paint attributes describing color, line thickness, and paint style.public void drawArc(RectFloat rect, Arc arc, Paint paint, Color color)
rect - Indicates the coordinates of the upper left and lower right corners of the enclosing rectangle
of the arc.arc - Indicates the arc parameters such as the start angle, sweep angle, and whether to draw
the lines from both end points of the arc to its center.paint - Indicates paint attributes describing color, line thickness, and paint style.color - Indicates the color.public void drawPolylineShadow(float[] points,
Point startColorPoint,
Point endColorPoint,
Paint paint)
The gradient polyline is specified by the start and end points, start and end coordinates of the
gradient color, and the Paint attributes.
points - Indicates the float array that represents the start and end points of the polyline. Each float
array contains four elements. If you want to draw two gradient polylines, eight elements (four per array) are
required.startColorPoint - Indicates the start coordinate of the gradient color.endColorPoint - Indicates the end coordinate of the gradient color.paint - Indicates paint attributes such as gradient color, line thickness, and paint style.public int save()
When this method is called, the drawing state is saved to a Canvas stack.
When the restore() method is called, the canvas is restored to the latest
drawing state saved.
public void restore()
This method is used with the save() interface.
public void restoreToCount(int saveCount)
saveCount.
This method pops out all drawing states that have been saved to the stack. The value of
saveCount must be greater than or equal to 1. Values less than 1 are treated as 1.
saveCount - Indicates the drawing state to which the canvas restores.public void setMatrix(Matrix matrix)
setMatrix is used to implement the translation, rotation, and scaling of a matrix.
matrix - Indicates the new matrix with which the current matrix is replaced.public void resetMatrix()
public void clipRect(Rect rect)
rect - Indicates the rectangle to cut.public void clipRect(RectFloat rect)
rect - Indicates the coordinates of the upper left and lower right corners of
the rectangle into which the canvas is clipped.public void clipRect(RectFloat rect, Canvas.ClipOp op)
rect - Indicates the rectangle to clip.op - Indicates the clipping mode, either ClipOp#INTERSECT or ClipOp#DIFFERENCE.public void clipRect(float left,
float top,
float right,
float bottom)
left - Indicates the left bound of the rectangle.top - Indicates the top bound of the rectangle.right - Indicates the right bound of the rectangle.bottom - Indicates the bottom bound of the rectangle.public void clipRect(int left,
int top,
int right,
float bottom)
left - Indicates the left bound of the rectangle.top - Indicates the top bound of the rectangle.right - Indicates the right bound of the rectangle.bottom - Indicates the bottom bound of the rectangle.public void rotate(float degree)
degree - Indicates the clockwise rotation angle.public void rotate(float degree,
float x,
float y)
degree - Indicates the clockwise rotation angle of the canvas.x - Indicates the X-axis coordinate of the rotation center.y - Indicates the Y-axis coordinate of the rotation center.public void scale(float scaleX,
float scaleY,
float pointX,
float pointY)
The canvas will scale according to the scaling multiples on X-axis and Y-axis of the anchor point.
scaleX - Indicates scaling multiple on X-axis used to scale the canvas.scaleY - Indicates scaling multiple on Y-axis used to scale the canvas.pointX - Indicates the X-axis coordinate of the scaling anchor point.pointY - Indicates the Y-axis coordinate of the scaling anchor point.public void scale(float scaleX,
float scaleY)
scaleX - Indicates scaling multiple on X-axis used to scale the canvas.scaleY - Indicates scaling multiple on Y-axis used to scale the canvas.public void translate(float distanceX,
float distanceY)
distanceX - Indicates the distance on the X-axis by which the canvas will translate, in pixels.distanceY - Indicates the distance on the Y-axis by which the canvas will translate, in pixels.public void drawText(Paint paint, String text, float x, float y)
paint - Indicates paint attributes describing color, line thickness, and font size.text - Indicates the text to draw, in string.x - Indicates the X-axis of the origin of the text to draw.y - Indicates the Y-axis of the baseline of the text to draw.public void drawCharSequence(Paint paint, CharSequence charSequence, float xCoor, float yCoor)
paint - Indicates the paint used to draw the text, including the text color, font, font size, and line
height.charSequence - Indicates the text to draw.xCoor - Indicates the x-coordinate of the text to draw.yCoor - Indicates the y-coordinate of the text to draw.public void drawChars(Paint paint, char[] charArray, float xCoor, float yCoor)
paint - Indicates the paint used to draw the text, including the text color, font, font size, and line
height.charArray - Indicates the text to draw.xCoor - Indicates the x-coordinate of the text to draw.yCoor - Indicates the y-coordinate of the text to draw.public void drawTextOnPath(Paint paint, String text, Path path, float advance, float offset)
paint - Indicates paint attributes describing text color, size and so on.text - Indicates the text to draw.path - Indicates the path used to draw the text.advance - Indicates the distance between the start point of path and text.offset - Indicates the vertical distance between text's baseline and path.public void setTexture(Texture texture)
texture - Indicates the texture to set.public void drawLines(float[] points,
Paint paint)
The start and end points of each line must be specified.
points - Indicates the floating point array. Each floating point array contains four values.paint - Indicates paint attributes describing color, line thickness, and font size.public void drawLines(float[] points,
int offset,
int drawCount,
Paint paint)
points - Indicates the array of start and end points for each line segment. Two adjacent points in the array
can form a vertex coordinate.offset - Indicates the offset of the elements in the points array.drawCount - Indicates the number of consecutive elements in the points array, that is, the number of
line segments to draw. The value of this parameter is a multiple of 4, and the sum of drawCount and
offset is less than or equal to the number of elements in the points array.paint - Indicates the paint to use, which specifies the line segment attributes, such as the color, paint
style, and line thickness.public void drawDeformedPixelMap(PixelMapHolder holder, PixelMapDrawInfo drawInfo, Paint paint)
This method can be used to deform a pixel map to produce effects such as rippling and floating.
holder - Indicates the holder of the pixel map to be deformed.drawInfo - Indicates the drawing information. You can set this parameter to deform the pixel map for
producing different effects. For details about the parameter settings, see PixelMapDrawInfo.paint - Indicates the paint used to draw the pixel map. This parameter can be null.public void drawPixelMapHolder(PixelMapHolder holder, float left, float top, Paint paint)
PixelMapHolder object and specifies the distance from the object to the upper left
corner of the parent component.holder - Indicates the PixelMapHolder object to draw.left - Indicates the distance from the PixelMapHolder object to the left edge of the parent
component.top - Indicates the distance from the PixelMapHolder object to the top edge of the parent component.paint - Indicates paint attributes such as color and alpha value.public void drawPixelMapHolderRect(PixelMapHolder holder, RectFloat rect, Paint paint)
PixelMapHolder object into a destination rectangle.
If its size does not fit the destination rectangle, the PixelMapHolder object automatically scales
to the same size as the destination rectangle.
holder - Indicates the PixelMapHolder object to draw.rect - Indicates the coordinates of the upper left and lower right corners of the PixelMapHolder
object.paint - Indicates paint attributes such as color and alpha value.public void drawPixelMapHolderRect(PixelMapHolder holder, RectFloat rectSrc, RectFloat rectDst, Paint paint)
PixelMapHolder object into a destination rectangle.
If its size does not fit the destination rectangle, the Canvas automatically scales to the same
size as the destination rectangle.
holder - Indicates the PixelMapHolder object.rectSrc - Indicates the coordinates of the upper left and lower right corners of the source rectangle
that specifies the PixelMapHolder object.rectDst - Indicates the coordinates of the upper left and lower right corners of the destination rectangle.paint - Indicates paint attributes such as color and alpha value.public void drawPixelMapHolderCircleShape(PixelMapHolder holder, RectFloat rectSrc, float pointX, float pointY, float radius)
PixelMapHolder object.
The object is clipped into the source rectangle, and its position and size are specified by
pointX, pointY, and radius.
holder - Indicates the PixelMapHolder object.rectSrc - Indicates the coordinates of the upper left and lower right corners of the source rectangle.pointX - Indicates the X-axis coordinate of the center of the circular PixelMapHolder object.pointY - Indicates the Y-axis coordinate of the center of the circular PixelMapHolder object.radius - Indicates the radius of the circular PixelMapHolder object, in pixels.public void drawPixelMapHolderRoundRectShape(PixelMapHolder holder, RectFloat rectSrc, RectFloat rectDst, float radiusX, float radiusY)
PixelMapHolder object.
The object is clipped into the source rectangle, and its position and size are specified by
rectDst, radiusX, and radiusY.
holder - Indicates the PixelMapHolder object.rectSrc - Indicates the coordinates of the upper left and lower right corners of the source rectangle.rectDst - Indicates the coordinates of the upper left and lower right corners of the destination rectangle.radiusX - Indicates the X-axis radius of the ovals used to round the corners of the PixelMapHolder
object, in pixels.radiusY - Indicates the Y-axis radius of the ovals used to round the corners of thePixelMapHolder
object, in pixels.public void drawPath(Path path, Paint paint)
The path effect depends on the paint style.
path - Indicates the path to draw.paint - Indicates the specified paint, which describes attributes such as paint fill and path effect.public void drawTexture(float posX,
float posY,
Texture texture)
posX - Indicates the X-axis coordinate of the texture to draw.posY - Indicates the Y-axis coordinate of the texture to draw.texture - Indicates the pixelmap file storing the drawing result.public void drawChangelessTexture(float posX,
float posY,
Texture texture)
Different from Canvas#drawTexture, this method can be used to efficiently draw a changeless texture,
for example, the background of a compass dial.
posX - Indicates the x-coordinate of the canvas texture.posY - Indicates the y-coordinate of the canvas texture.texture - Indicates the texture to draw.public void clipPath(Path path, Canvas.ClipOp op)
path - Indicates the path to clip the canvas.op - Indicates the mode for clipping the canvas. For details about available values, see ClipOp.public void drawPoint(float posX,
float posY,
Paint paint)
posX - Indicates the x-coordinate of the point to draw.posY - Indicates the y-coordinate of the point to draw.paint - Indicates the paint used to draw the point.public void drawPoint(Point point, Paint paint, Color color)
point - Indicates the position of the point to draw.paint - Indicates the paint used to draw the point, which defines paint attributes such as the color,
line thickness, and paint style.color - Indicates the specified paint color.public void drawPoint(Point pos, Paint paint)
pos - Indicates the point to draw.paint - Indicates the paint used to draw the point, which defines paint attributes such as the color,
line thickness, and paint style.public void drawPaint(Paint paint)
paint - Indicates the paint used to fill the canvas.public void drawColor(int color,
Canvas.PorterDuffMode mode)
color - Indicates an integer representing the color used to fill the canvas.mode - Indicates the color blend mode, as enumerated in PorterDuffMode.public void drawColor(int color,
BlendMode mode)
color - Indicates an integer representing the color used to fill the canvas.mode - Indicates the color blend mode, as enumerated in BlendMode.public void concat(Matrix matrix)
matrix - Indicates the specified matrix, as defined in Matrix.public Rect getLocalClipBounds()
public boolean getLocalClipBounds(Rect bounds)
bounds - Indicates the clip bounds.true if the clip region is not empty; returns false otherwise.public Rect getDeviceClipBounds()
public boolean getDeviceClipBounds(Rect bounds)
bounds.bounds - Indicates the clip bounds.true if the clip region is not empty; returns false otherwise.public void getMatrix(Matrix matrix)
matrix - Indicates the obtained transformation matrix.public int getSaveCount()
public int saveLayer(RectFloat bounds, Paint paint)
bounds - Indicates the size of the new layer.paint - Indicates the paint used to create a layer.public int saveLayerAlpha(RectFloat bounds, int alpha)
bounds - Indicates the size of the new layer.alpha - Indicates the alpha value of the new layer.public int getDeviceDensity(Context context)
context - Indicates the application context.public void skew(float sx,
float sy)
Canvas.sx - Indicates the tangent of the horizontal skew angle.sy - Indicates the tangent of the vertical skew angle.public void drawVertices(Canvas.VertexMode mode, Vertices vertices, Paint paint)
This method is used to draw graphics with specified vertex modes, positions, colors, and number of vertices.
mode - Indicates the vertex mode, as enumerated in VertexMode.vertices - Indicates the information about the vertices to draw, as defined in Vertices.paint - Indicates the paint used to draw vertices.public void drawPicture(Picture picture)
picture - Indicates the picture that contains recorded drawing calls.public void drawPicture(Picture picture, RectFloat destRectangle)
picture - Indicates the picture that contains recorded drawing calls.destRectangle - Indicates the destination rectangle area to hold the picture. The picture is scaled to adapt
to this area.public boolean quickReject(float left,
float top,
float right,
float bottom)
left - Indicates the coordinates of the left edge of the visible area.top - Indicates the coordinates of the top edge of the visible area.right - Indicates the coordinates of the right edge of the visible area.bottom - Indicates the coordinates of the bottom edge of the visible area.true if the canvas's visible area does not intersect with the clip area; returns
false otherwise.public boolean quickRejectRect(RectFloat rectFloat)
rectFloat - Indicates the specified rectangle.true if the specified rectangle does not intersect the clip region;
returns false otherwise.public boolean quickRejectPath(Path path)
path - Indicates the specified path.true if the specified path does not intersect the clip region;
returns false otherwise.public void drawPoints(float[] pts,
int offset,
int count,
Paint paint)
pts - Indicates an array of coordinates for points (x1, y1), (x2, y2), and more.offset - Indicates the offset from where drawing starts in the array.count - Indicates the number of values in the array of coordinates. This value must be an even number,
because each point has two coordinates.paint - Indicates the paint used to draw points.