53.Android Canvas Paint相关内容介绍
Android Canvas Paint
</div>Canvas
裁剪画布:
Region.Op.INTERSECT 取两者交集,默认的方式 Region.Op.DIFFERENCE 第一次上减去与第而次的交集 Region.Op.REPLACE 显示第二次的 Region.Op.REVERSE_DIFFERENCE 第二次上减去与第一次的交集 Region.Op.UNION 取全集 Region.Op.XOR 取补集,就是全集的减去交集的剩余部分显示clipPath(Path path)
clipPath(Path path, Region.Op op)
clipRect(Rect rect, Region.Op op)
clipRect(RectF rect, Region.Op op)
clipRect(int left, int top, int right, int bottom)
clipRect(float left, float top, float right, float bottom)
clipRect(RectF rect)
clipRect(float left, float top, float right, float bottom, Region.Op op)
clipRect(Rect rect)
clipRegion(Region region)
clipRegion(Region region, Region.Op op)
变换矩阵:
concat(Matrix matrix)
绘制圆弧
drawArc(RectF oval, float startAngle, float sweepAngle, boolean useCenter, Paint paint)
drawArc(float left, float top, float right, float bottom, float startAngle, float sweepAngle, boolean useCenter, Paint paint)
绘制Bitmap
drawBitmap(int[] colors, int offset, int stride, float x, float y, int width, int height, boolean hasAlpha, Paint paint)
drawBitmap(Bitmap bitmap, Matrix matrix, Paint paint)
drawBitmap(int[] colors, int offset, int stride, int x, int y, int width, int height, boolean hasAlpha, Paint paint)
drawBitmap(Bitmap bitmap, Rect src, RectF dst, Paint paint)
drawBitmap(Bitmap bitmap, float left, float top, Paint paint)
drawBitmap(Bitmap bitmap, Rect src, Rect dst, Paint paint)
绘制扭曲Bitmap
drawBitmapMesh(Bitmap bitmap, int meshWidth, int meshHeight, float[] verts, int vertOffset, int[] colors, int colorOffset, Paint paint)
绘制圆形
drawCircle(float cx, float cy, float radius, Paint paint)
绘制背景
drawARGB(int a, int r, int g, int b)
drawColor(int color)
drawColor(int color, PorterDuff.Mode mode)
drawPaint(Paint paint)
drawRGB(int r, int g, int b)
绘制线条
drawLine(float startX, float startY, float stopX, float stopY, Paint paint)
drawLines(float[] pts, Paint paint)
drawLines(float[] pts, int offset, int count, Paint paint)
绘制椭圆
drawOval(float left, float top, float right, float bottom, Paint paint)
drawOval(RectF oval, Paint paint)
绘制路径,可画任意多边形
drawPath(Path path, Paint paint)
绘制图片
drawPicture(Picture picture, RectF dst)
drawPicture(Picture picture)
drawPicture(Picture picture, Rect dst)
绘制点
drawPoint(float x, float y, Paint paint)
drawPoints(float[] pts, int offset, int count, Paint paint)
drawPoints(float[] pts, Paint paint)
绘制文字,可指定每个文字的位置
drawPosText(char[] text, int index, int count, float[] pos, Paint paint)
drawPosText(String text, float[] pos, Paint paint)
绘制矩形
drawRect(float left, float top, float right, float bottom, Paint paint)
drawRect(RectF rect, Paint paint)
drawRect(Rect r, Paint paint)
绘制圆角矩形
drawRoundRect(float left, float top, float right, float bottom, float rx, float ry, Paint paint)
drawRoundRect(RectF rect, float rx, float ry, Paint paint)
绘制文字
drawText(String text, float x, float y, Paint paint)
drawText(CharSequence text, int start, int end, float x, float y, Paint paint)
drawText(char[] text, int index, int count, float x, float y, Paint paint)
drawText(String text, int start, int end, float x, float y, Paint paint)
绘制在路径上的文字
drawTextOnPath(String text, Path path, float hOffset, float vOffset, Paint paint)
drawTextOnPath(char[] text, int index, int count, Path path, float hOffset, float vOffset, Paint paint)
绘制文字具体位置和大小
drawTextRun(CharSequence text, int start, int end, int contextStart, int contextEnd, float x, float y, boolean isRtl, Paint paint)
drawTextRun(char[] text, int index, int count, int contextIndex, int contextCount, float x, float y, boolean isRtl, Paint paint)
绘制顶点数据,也可绘制扭曲图片
drawVertices(Canvas.VertexMode mode, int vertexCount, float[] verts, int vertOffset, float[] texs, int texOffset, int[] colors, int colorOffset, short[] indices, int indexOffset, int indexCount, Paint paint)
获取Canvas上截取的矩形
getClipBounds()
getClipBounds(Rect bounds)
获取Canvas画布像素密度
getDensity()
获取画布过滤器
getDrawFilter()
获取画布宽高
getHeight()
getWidth()
获取画布的矩阵
getMatrix(Matrix ctm)
getMatrix()
获取Bitmap绘制画布上允许的最大高度和宽度
getMaximumBitmapHeight()
getMaximumBitmapWidth()
获取画布上的私有堆栈状态的矩阵或截图个数
getSaveCount()
是否硬件加速
isHardwareAccelerated()
不透明?
isOpaque()
保存当前画布状态,妙用将是神技
save()
save(int saveFlags)
类似save(),在现在的层上新建一层,调用restore后回复原状态
saveLayer(RectF bounds, Paint paint, int saveFlags)
saveLayer(RectF bounds, Paint paint)
saveLayer(float left, float top, float right, float bottom, Paint paint)
saveLayer(float left, float top, float right, float bottom, Paint paint, int saveFlags)
saveLayerAlpha(RectF bounds, int alpha, int saveFlags)
saveLayerAlpha(RectF bounds, int alpha)
saveLayerAlpha(float left, float top, float right, float bottom, int alpha, int saveFlags)
saveLayerAlpha(float left, float top, float right, float bottom, int alpha)
取回上次save时候的状态
restore()
restoreToCount(int saveCount)
画布翻转
translate(float dx, float dy)
画布旋转
rotate(float degrees)
rotate(float degrees, float px, float py)
画布缩放
scale(float sx, float sy)
scale(float sx, float sy, float px, float py)
Bitmap创建画布
setBitmap(Bitmap bitmap)
设置画布像