Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> Android開發 >> 關於android開發 >> 53.Android Canvas Paint相關內容介紹

53.Android Canvas Paint相關內容介紹

編輯:關於android開發

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. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved