Why does the Processing `fill()` with alpha never completely fill?

落爺英雄遲暮 提交于 2019-12-01 18:03:31

Here's a post explaining what's going on: http://processing.org/discourse/beta/num_1138703939.html

Basically, the problem is that Processing stores colors as ints, but takes float arguments. When combining colors, Processing rounds the floats to ints. In your case, your color is getting stuck at a value of 63, 63, 63 because at that point the blending is too slight to make a difference that is detectable after rounding.

The solution is to do the fading from the source, not by overlaying an alpha color over top.

The default background color is darker than the color you assigned to the first rectangle, thus it gets black sooner.

  • Why doesn't it eventually fade to black, as in why does drawing another dark rectangle on top of the white one not erase it eventually (I'm thinking along the lines of putting tinted windows over each other; eventually even the brightest light won't shine through), and
  • Why doesn't it eventually fade to black, as in why is this the behavior intended by the Processing community?

Also, in your original code (not the above sample) you're probably drawing the white rectangle continuously, so it will never fade.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!