DGM.-
DGM.-

Reputation: 151

Is there any possibility to overlay images in canvas?

So that is, is there any possibility to overlay images in canvas?

Upvotes: 1

Views: 720

Answers (1)

Simon Sarris
Simon Sarris

Reputation: 63812

Please be a lot more detailed next time. I assume you mean overlay images with some sort of transparency.


Yes. All you need to do is call drawImage with the several images in the order you want them to appear.

Before you draw any given image you can change its opacity by setting ctx.globalAlpha to a number between 0 and 1. Make sure you set it back afterward the drawImage call that you wanted it to affect, so the next image gets drawn as intended.

Upvotes: 3

Related Questions