How to draw transparent PNG on canvas in Firefox?

I set up a small structure for rendering positioned and animated graphics on the <canvas> - primarily to help me understand this.

I downloaded a random sprite sheet from the Internet for testing - it has a transparent background that seems to work fine in Chrome, on my iPhone and Safari.

This is a demo: http://martywallace.com/simplecanvas/

In Firefox, however, transparent sprite sections load as white, which looks like this:

enter image description here

Is there any Firefox way to enable transparency or is it not supported?

+4
source share
1 answer

Here's what [stupidity disclaimer] happened:

  • I uploaded the initially transparent image and tested it on Chrome, Safari and iPhone.
  • The image was 1 MB, so I reduced it to PNG8 (and forgot to allow transparency when exporting).
  • The cached version of the image was used in browsers that I tested (which I did not notice).
  • When I switched to Firefox, a new opaque was used (due to the lack of previous caching).

Result: Firefox displays transparent PNG files, happy that this question is closed as "too localized."

+1
source

Source: https://habr.com/ru/post/1400111/


All Articles