html canvas缩放抗锯齿,我可以关闭HTML

It must antialias vector graphics

Antialiasing is required for correct plotting of vector graphics that involves non-integer coordinates (0.4, 0.4), which all but very few clients will do.

When given non-integer coordinates, the canvas has two options:

Antialias - paint the pixels around the coordinate with respect to how far the integer coordinate is from non-integer one (the rounding error).

Round - apply some rounding function to the non-integer coordinate (so 1.4 will become 1, for example).

The later strategy will work for static graphics, although for small graphics (a circle with radius of 2) curves will show clear steps rather than smooth curve.

The real problem is when the graphics is translated (moved) - the jumps between one pixel and another (1.6 => 2, 1.4 => 1), mean that the origin of the shape may jump with relation to the parent container (constantly shifting 1 pixel up/down and left/right).

Some tips

Tip #1: You can soften (or harden) antialiasing by scaling the canvas (say by x) then apply the reciprocal scale (1/x) to the geometries yourself (not using the canvas).

Compare (no scaling):

127jr.png

with (canvas scale: 0.75; manual scale: 1.33):

ccjt2.png

and (canvas scale: 1.33; manual scale: 0.75):

fWWBp.png

Tip #2: If a jaggy look is really what you're after, try to draw each shape a few times (without erasing). With each draw, the antialiasing pixels get darker.

Compare. After drawing once:

P96ie.png

After drawing thrice:

eICmM.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值