![](/img/trans.png)
[英]How to draw line path on top of arc using Canvas paint in Android
[英]How to draw with an “inverted” paint in Android Canvas?
我在畫布上畫了一些東西,我想要畫一個倒置的圓圈:
canvas.drawCircle(zx, zy, 8f, myPaint);
如何將圓形像素的myPaint
配置為基礎像素的反色?
謝謝
嘗試這個
float mx [] = {
-1.0f, 0.0f, 0.0f, 1.0f, 0.0f,
0.0f, -1.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, -1.0f, 1.0f, 0.0f,
1.0f, 1.0f, 1.0f, 1.0f, 0.0f
};
ColorMatrix cm = new ColorMatrix(mx);
p.setColorFilter(new ColorMatrixColorFilter(cm));
canvas.drawCircle(zx, zy, 8f, p);
我會說用於反轉的顏色矩陣應該如下所示:
float mx [] = {
-1.0f, 0.0f, 0.0f, 0.0f, 255.0f,
0.0f, -1.0f, 0.0f, 0.0f, 255.0f,
0.0f, 0.0f, -1.0f, 0.0f, 255.0f,
0.0f, 0.0f, 0.0f, 1.0f, 0.0f
};
以下是矩陣的更多信息:
myPaint.setColor(Integer.MAX_VALUE - color);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.