Translate + Canvas = Blurry Text

时光总嘲笑我的痴心妄想 提交于 2019-12-01 10:43:46

问题


There are more than a few "CSS transform = blurry text" entries on SO already but I think I have a unique doozy here. I have tried all the other fixes with no avail.

I'm implementing the CSS transform center / middle align method:

.centered {
    position: absolute;
    top: 50%;
    left: 50%;
    -webkit-transform-style: preserve-3d;
    -webkit-transform: translate(-50%,-50%);
}

Once I apply an image via drawImage AND resize the canvas that is underneath the .centered element, the text starts blurring on the "half pixel". The -webkit-transform-style: preserve-3d fix has no effect. This only happens in Chrome and Safari.

Here's a pen with a reduced test case: http://codepen.io/andrewtibbetts/pen/owzJa

By resizing the window, you'll notice that the blurring stops if the text is not directly above the canvas.

来源:https://stackoverflow.com/questions/24393224/translate-canvas-blurry-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!