I'm trying to get the background of a html5-starfield transparent.But why error?
This with background color black http://www.thediscopalace.com/testing.php
And this if background transparent http://www.thediscopalace.com/testing1.php
I change context.fillStyle='rgb(36,14,118)';
= BLACK to context.fillStyle='rgba(36,14,118, 0)';
= TRANSPARENT
The problem is in fact, that actually you're not cleaning the canvas before drawing new stars state. So you just need to change context.fillRect(0,0,w,h)
inside anim()
function to context.clearRect(0,0,w,h)
.
It was working initially, because canvas was filled with opaque color each time new stars state were drawn, but after your changes that color become transparent.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.