Wednesday, 30 May 2018

Android Canvas change color of intersection of shapes and texts

I'm trying to change color of intersection of shapes and text using Canvas. As you can see in the imagei have 2 shapes and 1 text with different paints.
This is without any PorterDuffXfermode, and PorterDuffColorFilter mode added to any paint. I want intersection of shapes to be particular color, for example white, and text red or white like the images below.
In my example, text is at the bottom, circle middle and rectangle above but it's insignificant, i'm just trying to figure out how it works and how should intersection can be set to particular color.
As you can see in this imageimage background is black, circles are white and text is black. When circles overlap intersection of circles turns to black and overlapping section of text turns to white.
I can achieve this with
canvas.drawColor(Color.TRANSPARENT, Mode.CLEAR);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_OUT));

if circle and rectangle are both white and background is black. When i change background color to any other color, text is not visible, shapes are black.
I also wonder how can i get similar results like in this imageon the image Can overlapping sections for circle, rectangle and text can be set to specific color?


from Android Canvas change color of intersection of shapes and texts

1 comment:

  1. https://www.wizweb.in

    Wizweb Technology is a leading software development company custom website design, software development, SMS Provider, Bulk sms, transactional sms, promotional sms, mobile app development, Hosting Solution, seo(search engine optimization) and Digital marketing etc.

    ReplyDelete