Example usage for Java android.graphics Canvas fields, constructors, methods, implement or subclass
The text is from its open source code.
int | MATRIX_SAVE_FLAG Restore the current matrix when restore() is called. |
int | CLIP_SAVE_FLAG Restore the current clip when restore() is called. |
int | HAS_ALPHA_LAYER_SAVE_FLAG The layer requires a per-pixel alpha channel. |
int | FULL_COLOR_LAYER_SAVE_FLAG The layer requires full 8-bit precision for each color channel. |
int | CLIP_TO_LAYER_SAVE_FLAG Clip drawing to the bounds of the offscreen layer, omit at your own peril. |
int | ALL_SAVE_FLAG Restore everything when restore() is called (standard save flags). |
Canvas(@NonNull Bitmap bitmap) Construct a canvas with the specified bitmap to draw into. | |
Canvas(long nativeCanvas) | |
Canvas() Construct an empty raster canvas. |
boolean | clipPath(@NonNull Path path) Intersect the current clip with the specified path. |
boolean | clipPath(@NonNull Path path, @NonNull Region.Op op) Modify the current clip with the specified path. |
boolean | clipRect(float left, float top, float right, float bottom) Intersect the current clip with the specified rectangle, which is expressed in local coordinates. |
boolean | clipRect(int left, int top, int right, int bottom) Intersect the current clip with the specified rectangle, which is expressed in local coordinates. |
boolean | clipRect(@NonNull RectF rect) Intersect the current clip with the specified rectangle, which is expressed in local coordinates. |
boolean | clipRect(@NonNull Rect rect) Intersect the current clip with the specified rectangle, which is expressed in local coordinates. |
boolean | clipRect(@NonNull RectF rect, @NonNull Region.Op op) Modify the current clip with the specified rectangle. |
boolean | clipRect(@NonNull Rect rect, @NonNull Region.Op op) Modify the current clip with the specified rectangle, which is expressed in local coordinates. |
boolean | clipRect(float left, float top, float right, float bottom, @NonNull Region.Op op) Modify the current clip with the specified rectangle, which is expressed in local coordinates. |
boolean | clipRegion(@NonNull Region region) Intersect the current clip with the specified region. |
void | concat(@Nullable Matrix matrix) Preconcat the current matrix with the specified matrix. |
void | drawArc(@NonNull RectF oval, float startAngle, float sweepAngle, boolean useCenter, @NonNull Paint paint) Draw the specified arc, which will be scaled to fit inside the specified oval. |
void | drawARGB(int a, int r, int g, int b) Fill the entire canvas' bitmap (restricted to the current clip) with the specified ARGB color, using srcover porterduff mode. |
void | drawBitmap(@NonNull Bitmap bitmap, float left, float top, @Nullable Paint paint) Draw the specified bitmap, with its top/left corner at (x,y), using the specified paint, transformed by the current matrix. |
void | drawBitmap(@NonNull Bitmap bitmap, @Nullable Rect src, @NonNull RectF dst, @Nullable Paint paint) Draw the specified bitmap, scaling/translating automatically to fill the destination rectangle. |
void | drawBitmap(@NonNull Bitmap bitmap, @Nullable Rect src, @NonNull Rect dst, @Nullable Paint paint) Draw the specified bitmap, scaling/translating automatically to fill the destination rectangle. |
void | drawBitmap(@NonNull Bitmap bitmap, @NonNull Matrix matrix, @Nullable Paint paint) Draw the bitmap using the specified matrix. |
void | drawBitmapMesh(@NonNull Bitmap bitmap, int meshWidth, int meshHeight, @NonNull float[] verts, int vertOffset, @Nullable int[] colors, int colorOffset, @Nullable Paint paint) Draw the bitmap through the mesh, where mesh vertices are evenly distributed across the bitmap. |
void | drawCircle(float cx, float cy, float radius, @NonNull Paint paint) Draw the specified circle using the specified paint. |
void | drawColor(@ColorInt int color, @NonNull PorterDuff.Mode mode) Fill the entire canvas' bitmap (restricted to the current clip) with the specified color and porter-duff xfermode. |
void | drawColor(@ColorInt int color) Fill the entire canvas' bitmap (restricted to the current clip) with the specified color, using srcover porterduff mode. |
void | drawLine(float startX, float startY, float stopX, float stopY, @NonNull Paint paint) Draw a line segment with the specified start and stop x,y coordinates, using the specified paint. |
void | drawLines(@Size(multiple = 4) @NonNull float[] pts, @NonNull Paint paint) |
void | drawLines(@Size(multiple = 4) @NonNull float[] pts, int offset, int count, @NonNull Paint paint) Draw a series of lines. |
void | drawOval(@NonNull RectF oval, @NonNull Paint paint) Draw the specified oval using the specified paint. |
void | drawOval(float left, float top, float right, float bottom, @NonNull Paint paint) Draw the specified oval using the specified paint. |
void | drawPaint(@NonNull Paint paint) Fill the entire canvas' bitmap (restricted to the current clip) with the specified paint. |
void | drawPath(@NonNull Path path, @NonNull Paint paint) Draw the specified path using the specified paint. |
void | drawPicture(@NonNull Picture picture) Save the canvas state, draw the picture, and restore the canvas state. |
void | drawPoint(float x, float y, @NonNull Paint paint) Helper for drawPoints() for drawing a single point. |
void | drawRect(float left, float top, float right, float bottom, @NonNull Paint paint) Draw the specified Rect using the specified paint. |
void | drawRect(@NonNull RectF rect, @NonNull Paint paint) Draw the specified Rect using the specified paint. |
void | drawRect(@NonNull Rect r, @NonNull Paint paint) Draw the specified Rect using the specified Paint. |
void | drawRGB(int r, int g, int b) Fill the entire canvas' bitmap (restricted to the current clip) with the specified RGB color, using srcover porterduff mode. |
void | drawRoundRect(@NonNull RectF rect, float rx, float ry, @NonNull Paint paint) Draw the specified round-rect using the specified paint. |
void | drawText(@NonNull String text, float x, float y, @NonNull Paint paint) Draw the text, with origin at (x,y), using the specified paint. |
void | drawText(@NonNull char[] text, int index, int count, float x, float y, @NonNull Paint paint) Draw the text, with origin at (x,y), using the specified paint. |
void | drawText(@NonNull String text, int start, int end, float x, float y, @NonNull Paint paint) Draw the text, with origin at (x,y), using the specified paint. |
void | drawText(@NonNull CharSequence text, int start, int end, float x, float y, @NonNull Paint paint) Draw the specified range of text, specified by start/end, with its origin at (x,y), in the specified Paint. |
void | drawTextOnPath(@NonNull String text, @NonNull Path path, float hOffset, float vOffset, @NonNull Paint paint) Draw the text, with origin at (x,y), using the specified paint, along the specified path. |
boolean | getClipBounds(@Nullable Rect bounds) Return the bounds of the current clip (in local coordinates) in the bounds parameter, and return true if it is non-empty. |
Rect | getClipBounds() Retrieve the bounds of the current clip (in local coordinates). |
int | getHeight() Returns the height of the current drawing layer |
void | getMatrix(@NonNull Matrix ctm) Return, in ctm, the current transformation matrix. |
int | getMaximumBitmapHeight() Returns the maximum allowed height for bitmaps drawn with this canvas. |
int | getMaximumBitmapWidth() Returns the maximum allowed width for bitmaps drawn with this canvas. |
int | getSaveCount() Returns the number of matrix/clip states on the Canvas' private stack. |
int | getWidth() Returns the width of the current drawing layer |
boolean | isHardwareAccelerated() Indicates whether this Canvas uses hardware acceleration. |
void | restore() This call balances a previous call to save(), and is used to remove all modifications to the matrix/clip state since the last save call. |
void | restoreToCount(int saveCount) Efficient way to pop any calls to save() that happened after the save count reached saveCount. |
void | rotate(float degrees, float px, float py) Preconcat the current matrix with the specified rotation. |
void | rotate(float degrees) Preconcat the current matrix with the specified rotation. |
int | save() Saves the current matrix and clip onto a private stack. |
int | save(@Saveflags int saveFlags) Based on saveFlags, can save the current matrix and clip onto a private stack. |
int | saveLayer(@Nullable RectF bounds, @Nullable Paint paint, @Saveflags int saveFlags) This behaves the same as save(), but in addition it allocates and redirects drawing to an offscreen bitmap. |
int | saveLayer(float left, float top, float right, float bottom, @Nullable Paint paint, @Saveflags int saveFlags) Helper version of saveLayer() that takes 4 values rather than a RectF. |
int | saveLayerAlpha(float left, float top, float right, float bottom, int alpha, @Saveflags int saveFlags) Helper for saveLayerAlpha() that takes 4 values instead of a RectF. |
int | saveLayerAlpha(@Nullable RectF bounds, int alpha, @Saveflags int saveFlags) This behaves the same as save(), but in addition it allocates and redirects drawing to an offscreen bitmap. |
void | scale(float sx, float sy) Preconcat the current matrix with the specified scale. |
void | scale(float sx, float sy, float px, float py) Preconcat the current matrix with the specified scale. |
void | setBitmap(@Nullable Bitmap bitmap) Specify a bitmap for the canvas to draw into. |
void | setDensity(int density) Specifies the density for this Canvas' backing bitmap. |
void | setDrawFilter(@Nullable DrawFilter filter) |
void | setMatrix(@Nullable Matrix matrix) Completely replace the current matrix with the specified matrix. |
void | translate(float dx, float dy) Preconcat the current matrix with the specified translation |