2

I don't know if what I'm asking is possible.
I've a Paint with Color.BLACK with 0.2f of alpha and two objects:

enter image description here

They both use the same Paint. I've also tested with 2 different Paint objects changing only the PorterDuffXfermode but I had no success. What I want is to avoid the overlapped areas to become darker, in other words, I don't want them to "add" their alpha channels. I want the same alpha for all the objects (even when they overlap). Is it possible? How can I achieve it?
Thanks for your time.

genpfault
  • 51,148
  • 11
  • 85
  • 139
GuilhE
  • 11,591
  • 16
  • 75
  • 116

1 Answers1

2

Use a single path for both objects.

Path path = new Path();
path.moveTo(..
path.lineTo(..
path.addCircle(...
canvas.drawPath(path, paint);

But while typing this, I remembered that this works only if both objects have same style - either both fill or both stroke or both fill&stroke

With two different paint objects, I don't think it is possible.

Nabin Bhandari
  • 15,949
  • 6
  • 45
  • 59
  • In this case they share the same Paint object so it works perfectly! addCircle > addArc > drawPath. Thanks :) – GuilhE Nov 02 '17 at 03:20
  • Happy to help :) – Nabin Bhandari Nov 02 '17 at 03:24
  • Although this answers my question, if I want to animate the "spot" over the "circular" path, this approach has a little problem, the paths aren't removed/cleared. This will leave a trace. – GuilhE Nov 03 '17 at 16:58