1.范圍裁切
image.png
1.1 clipRect():裁切一個(gè)矩形區(qū)域朵耕,該區(qū)域內(nèi)的內(nèi)容會(huì)被保留
切割Bitmap的一個(gè)矩形區(qū)域
在save()和restore()為恢復(fù)裁切范圍
1.2 clipPath():裁切一個(gè)path
1.3 clipOutRect()/clipOutPath():保留矩形區(qū)域/Path外的圖形
2.Canvas的幾何變換(變換的canvas坐標(biāo)系)
Canvas 的?何變換?法參照的是 View 的坐標(biāo)系扮碧,?繪制?法
(drawXxx())參照的是 Canvas ??的坐標(biāo)系。
2.1 translate(x鹤耍,y)
這樣canvas就會(huì)先移動(dòng)再繪制
先移動(dòng)再繪制
2.2 rotate(degree)
將canvas移動(dòng)多少度
2.3 多重變換
多重變換一起時(shí)要倒著寫毕骡,比如要實(shí)現(xiàn)先旋轉(zhuǎn)再移動(dòng)就要先使用translate再rotate
先旋轉(zhuǎn)再移動(dòng)
先畫bitmap再移動(dòng)再旋轉(zhuǎn)
3.Matrix 的?何變換:可實(shí)現(xiàn)更多的形變
- preTranslate(x, y) / postTranslate(x, y)
- preRotate(degree) / postRotate(degree)
- preScale(x, y) / postScale(x, y)
- preSkew(x, y) / postSkew(x, y)
其中 preXxx() 效果和 Canvas 的準(zhǔn)同名?法相同释涛, postXxx() 效果和 Canvas
的準(zhǔn)同名?法順序相反亭畜。
所以用post方法可以“正著寫”繪制內(nèi)容
4.Camera
可做三維旋轉(zhuǎn)
參考了https://www.bilibili.com/video/BV1Xx411H7HE?spm_id_from=333.999.0.0