canvas教程

53.Android Canvas Paint相关内容介绍

字号+ 作者:H5之家 来源:H5之家 2017-05-23 15:04 我要评论( )

53.Android Canvas Paint相关内容介绍。53.Android Canvas Paint相关内容介绍 Android Canvas Paint Canvas 裁剪画布: Region.Op.INTERSECT 取两者交集,默认的

53.Android Canvas Paint相关内容介绍
Android Canvas Paint

 

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)

设置画布像素密度

setDensity(int density)

设置画布过滤器

setDrawFilter(DrawFilter filter)

设置画布矩阵

setMatrix(Matrix matrix)

设置画布扭曲

skew(float sx, float sy)

Paint

设置颜色和透明度

setARGB(int a, int r, int g, int b)

设置透明度

setAlpha(int a)

设置抗锯齿

setAntiAlias(boolean aa)

设置颜色

setColor(int color)

图像抖动处理:图片颜色更加平滑和饱满,图像更加清晰 。

setDither(boolean dither)

为true,图像在动画进行中会滤掉对Bitmap图像的优化,加快显示速度,依赖于dither和xfermode的设置

setFilterBitmap(boolean filter)

设置MaskFilter实现滤镜的效果

setMaskFilter(MaskFilter maskfilter)

设置颜色过滤器,绘制颜色时实现不用颜色的变换效果

setColorFilter(ColorFilter colorfilter)

设置绘制路径的效果,如点画线等

setPathEffect(PathEffect effect)

设置图像效果,使用Shader可以绘制出各种渐变效果

setShader(Shader shader)

设置图形下面的阴影层,产生阴影效果

setShadowLayer(float radius ,float dx,float dy,int color)

设置画笔的样式

setStyle(Paint.Style style)

设置笔刷的图形样式

setStrokeCap(Paint.Cap cap)

设置绘制时各图形的结合方式

setStrokeJoin(Paint.Join join)

设置笔刷的粗细

setStrokeWidth(float width)

设置图形重叠时的处理方式

setXfermode(Xfermode xfermode)

设置实现粗体文字

setFakeBoldText(boolean fakeBoldText)

true = 有助于文本在LCD屏幕上的显示效果

setSubpixelText(boolean subpixelText)

设置绘制文字的对齐方向

setTextAlign(Paint.Align align)

设置绘制文字x轴的缩放比例

setTextScaleX(float scaleX)

设置绘制文字的字号大小

setTextSize(float textSize)

设置斜体文字,skewX为倾斜弧度

setTextSkewX(float skewX)

设置Typeface对象

setTypeface(Typeface typeface)

设置下划线

setUnderlineText(boolean underlineText)

设置删除线

setStrikeThruText(boolean strikeThruText)

 

 

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • HTML5 Canvas锯齿图代码实例_html5教程技巧

    HTML5 Canvas锯齿图代码实例_html5教程技巧

    2017-05-23 16:00

  • HTML5之Canvas基础绘图教程

    HTML5之Canvas基础绘图教程

    2017-05-22 16:00

  • android手机裸眼3D技术原理和编程实现

    android手机裸眼3D技术原理和编程实现

    2017-05-22 15:00

  • HTML5 Canvas draw方法制作动画效果示例_html5教程技巧

    HTML5 Canvas draw方法制作动画效果示例_html5教程技巧

    2017-05-22 12:04

网友点评