Copy and crop images in Javascript

前端 未结 4 1278
死守一世寂寞
死守一世寂寞 2020-12-15 00:57

I\'m trying to create a small 2D game in Javascript/Canvas which consists of several animated sprites. I\'d like to cut down on the number of HTTP requests, so I combined ea

4条回答
  •  一个人的身影
    2020-12-15 01:02

    Just load the image in an img tag with style attribute display set to hidden. Then crop the image on an off screen canvas, then write that off screen canvas to your main canvas as required.

提交回复
热议问题