Canvas错误地绘制文本

时间:2016-10-30 13:12:13

标签: javascript html5 canvas

我编写了用canvas绘制文本的代码。它看起来如下所示:

        var canvas = $('<canvas>').css("width", width).css("height", me.scaleHeight);
        var context = canvas[0].getContext("2d");
        context.font = "30px sans-serif";

        for (var x = 0; x < width; x++) {
            context.fillText(x*showValue, x*ppt*showValue, 20);
        }

具有此属性的画布颜料:

  fillStyle: "#000000"
  filter: "none"
  font:"30px sans-serif"
  globalAlpha:1
  globalCompositeOperation:"source-over"
  imageSmoothingEnabled:true
  imageSmoothingQuality:"low"
  lineCap:"butt"
  lineDashOffset:0
  lineJoin:"miter"
  lineWidth:1
  miterLimit:10
  shadowBlur:0
  shadowColor:"rgba(0, 0, 0, 0)"
  shadowOffsetX:0
  shadowOffsetY:0
  strokeStyle:"#000000"
  textAlign:"center"
  textBaseline:"top"
  webkitImageSmoothingEnabled:true

Resulted image

我设置的属性是错误的?

0 个答案:

没有答案