如何在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);
链接地址: http://www.djcxy.com/p/52571.html

上一篇: How to draw with an "inverted" paint in Android Canvas?

下一篇: Does ko.toJSON() work with dates?