53.Android Canvas Paint相關內容介紹

來源:互聯網
上載者:User

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)

  

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.