AvoidXferMode Tolerance

Posted by kayahr on Stack Overflow See other posts from Stack Overflow or by kayahr
Published on 2010-03-31T14:19:54Z Indexed on 2010/03/31 14:23 UTC
Read the original article Hit count: 216

I have a problem with the following code:

protected void onDraw(Canvas canvas)
{
    Paint paint = new Paint();

    // Draw a blue circle
    paint.setColor(Color.BLUE);
    canvas.drawCircle(100, 100, 50, paint);

    // Draw a red circle where it collides with the blue one
    paint.setXfermode(new AvoidXfermode(Color.BLUE, 0, Mode.TARGET));
    paint.setColor(Color.RED);
    canvas.drawCircle(50, 50, 50, paint);
}

According to the API documentation of AvoidXfermode the tolerance value 0 means that it looks for an EXACT color match. This should work here because I specify the same color as I used for drawing the first circle. But the result is that the red circle is not drawn at all. When I use a tolerance value of 255 instead then it works (red circle is drawn where it collides with the blue one) but that sounds wrong because with such a high tolerance I think it should draw the circle EVERYWHERE.

So what's wrong here? API Documentation? Android? Me?

© Stack Overflow or respective owner

Related posts about android

Related posts about android-sdk