【问题标题】:How to make a transparent canvas without error?如何无错误地制作透明画布?
【发布时间】:2016-07-10 10:01:48
【问题描述】:

我正在尝试让 html5-starfield 的背景透明。但是为什么会出错?

这与背景颜色黑色 http://www.thediscopalace.com/testing.php

如果背景透明http://www.thediscopalace.com/testing1.php

我将context.fillStyle='rgb(36,14,118)'; = BLACK 更改为 context.fillStyle='rgba(36,14,118, 0)'; = 透明

【问题讨论】:

    标签: javascript ajax html animation canvas


    【解决方案1】:

    问题实际上是,实际上你在绘制新的星星状态之前并没有清理画布。所以你只需要把context.fillRect(0,0,w,h)里面的anim()改成context.clearRect(0,0,w,h)

    它最初可以工作,因为每次绘制新的星星状态时,画布都会填充不透明的颜色,但在您更改后,颜色会变为透明。

    【讨论】:

      猜你喜欢
      • 2011-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-02
      • 2014-01-11
      • 2019-06-13
      • 2017-04-12
      • 2011-07-02
      相关资源
      最近更新 更多