I'm trying to add my pixelart to the canvas, but there I met the problem. That image is blurry so I added in canvas css style image-rendering: pixelated. But it's same as before. When I add same style to image outside canvas it's well pixelated. Can someone give me a tip? Why it doesn't work in canvas? Thank you for all replies!
Javascript:
ctx.drawImage(this.img, this.x - this.size/2, this.y - this.size/2, this.size, this.size)
CSS:
#canvas {
position: relative;
image-rendering: pixelated;
width: 256px;
height: 256px;
}
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.