它有三幅画布A、B和C。
A
是控制画布。B
你会注意到缩放在方向上平移,但B
在Firefox 中缩放仅在方向上平移。哪个实现是正确的?x
y
x
还要注意旋转的C
. 在 Chrome 中它看起来非常丑陋,但在 Firefox 中它看起来很好。我该如何解决?
我有最新的 Chrome 和 Firefox 5。
编码
$(function() {
$('canvas').each(function(i) {
var c = $(this);
c.attr('height', '200px');
c.attr('width', '200px');
c.css('border', '1px solid black');
var ctx = c.get(0).getContext('2d');
switch (i) {
case 0:
ctx.translate(100, 100);
ctx.fillText('A', 0, 0);
break;
case 1:
ctx.translate(100, 100);
ctx.scale(16, 16);
ctx.fillText('B', 0, 0);
ctx.scale(1 / 16, 1 / 16);
ctx.fillText('o', 0, 0);
break;
case 2:
ctx.translate(100, 100);
ctx.scale(16, 16);
ctx.rotate(1);
ctx.fillText('C', 0, 0);
ctx.rotate(-1);
ctx.scale(1 / 16, 1 / 16);
ctx.fillText('o', 0, 0);
break;
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<canvas></canvas>
<canvas></canvas>
<canvas></canvas>
<canvas></canvas>
可以在这里找到一个工作示例