Canvas繪製圖形
阿新 • • 發佈:2018-11-05
1.Android 利用canvas畫各種圖形(點、直線、弧、圓、橢圓、文字、矩形、多邊形、曲線、圓角矩形)
參考:
https://blog.csdn.net/u013831257/article/details/50556098
https://blog.csdn.net/qq_21751781/article/details/64128399
2.canvas.drawRoundRect方法,繪製圓角矩形
https://blog.csdn.net/liuzhi0724/article/details/44461945
3.Android Canvas設定繪畫時重疊部分的處理模式【含效果圖】
http://www.cnblogs.com/DonkeyTomy/articles/3215137.html
原理:顏色混合模式(Alpha通道相關)
https://blog.csdn.net/u013831257/article/details/50494832
呼叫方式
Paint shaderPaint = new Paint(); LinearGradient shader = new LinearGradient(0, mHeight, 0, flection.getHeight(), 0x70ffffff, 0x00ffffff, TileMode.MIRROR); shaderPaint.setShader(shader); //android.graphics.PorterDuff.Mode.DST_IN:只在源影象和目標影象相交的地方繪製目標影象 shaderPaint.setXfermode(new PorterDuffXfermode(android.graphics.PorterDuff.Mode.DST_IN)); //畫出漸變顏色 canvas.drawRect(0, mHeight+gap, mWidth, background.getHeight(), shaderPaint);