绘制半透明的形状没有重叠 [英] Drawing translucent shapes without overlapping
问题描述
我画几个圈与透明度。集团和它的位置的数量是不固定的。目前,我设置了油漆透明色
对象,并绘制的圆圈在为与画布
对象循环。但是,这会导致重叠。
I am drawing several circles with transparency. The number of circles and their positions are not fixed. Currently I am setting the transparent color in a Paint
object and drawing the circles in a for loop with the Canvas
object. But that causes overlapping.
我曾想过的方法:
- 渲染所有的圈子比主画布以外的东西不透明。
- 设置透明度。
- 画在画布上的最终目标。
I have thought of a method: - Render all the circles as opaque on something other than the main canvas. - Set the transparency. - Draw the final object on canvas.
我如何实现在Android?
How do i implement that on android?
推荐答案
创建ARGB888新位图,并借鉴它的画布,没有透明度的各种形状。
然后绘制新位图到使用上你叫setAlpha画图主画布前面
Create a new bitmap with ARGB888, and draw on it's canvas all your shapes with no transparency. Then draw the new bitmap into the main canvas using a Paint on which you called setAlpha earlier
这篇关于绘制半透明的形状没有重叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!