What does the multiply blend mode does?

61 views
Skip to first unread message

Chetan Pandey

unread,
Apr 20, 2024, 1:16:06 PMApr 20
to skia-discuss
Hi everyone

I am using drawRect method of SkCanvas. In drawRect method we pass the rect and the SKPaint image. Now in SkPaint we pass a parameter called blend mode

Now in my case I am using multiply blend mode. And on the canvas where I am drawing this new rect, I already have a number of rect there. Now the question here is does the multiply blend mode considers all the rects that were present before or just the topmost one which is displayed 

Example: Skia Fiddle
Based on the example, 
Now if I draw a rect with multiply blend mode on the rect3 then will it be consider only the last rect ( the white one ) for blending or will consider all the 3 rects present on the screen

Brian Osman

unread,
Apr 20, 2024, 3:01:04 PMApr 20
to skia-d...@googlegroups.com
The blend mode doesn't know anything about the individual objects that were drawn before - it only knows about the COLOR of the pixel that's there. So it depends on how those previous rects were drawn. If you drew them with alpha blending, then a little bit of color from each one would be present, and the final rect would do a blend against that color. But if you draw a transparent rect, then an opaque one, the color underneath will just be the color of the second rect. If you then draw a rect in multiply (or ANY blend mode), it just does math using the color that's been written most recently.

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/1f1e7c0f-8063-4baa-9697-956ab205ea5cn%40googlegroups.com.

Chetan Pandey

unread,
Apr 21, 2024, 1:00:34 PMApr 21
to skia-discuss
Okay considering the example that I gave, multiply blend would do a blend against all the three colors, i.e., red, green and white right?

So now if I make the underneath color transparent, the borders I am getting, that I'll not be able to achieve right?
So is there a way of getting the border and as well as doing blend with only white and not with other colors.

Reply all
Reply to author
Forward
0 new messages