html5 - canvas斜线如何做到抗锯齿?
ringa_lee
ringa_lee 2017-04-17 13:48:31
0
1
1077

canvas使用lineTo()方法绘制的斜线段,会产生锯齿

使用这个方法并没有起到预想中的效果

context.imageSmoothingEnabled = true;

请问在canvas中,一般采取什么方法做到斜线抗锯齿?

ringa_lee
ringa_lee

ringa_lee

모든 응답(1)
大家讲道理

let width = canvas.width,height=canvas.height;
if (window.devicePixelRatio) {
canvas.style.width = width + "px";
canvas.style.height = height + "px";
canvas.height = height * window.devicePixelRatio;
canvas.width = width * window.devicePixelRatio;
ctx.scale(window.devicePixelRatio, window.devicePixelRatio);
}

최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!