【问题标题】:canvas line glitch画布线故障
【发布时间】:2013-03-22 14:19:45
【问题描述】:

当使用路径在画布上画一条线时,我遇到了一些小故障,如下图所示...我是 android 开发新手..我知道我犯了一些愚蠢的错误,我不知道它是什么.. .如果有人有想法帮助我..谢谢

我的路径代码是

 path.moveTo((this.pos/2),0);
              path.lineTo((this.pos/2),25);
              path.lineTo(this.pos,25);
              path.close();
              canvas.drawPath(path, ppaint);

【问题讨论】:

  • 哪个截图是想要的结果?

标签: android path android-canvas visual-glitch


【解决方案1】:

你可以试试

ctx.beginPath();
ctx.moveTo((this.pos/2),0);
ctx.lineTo((this.pos/2),25);
ctx.lineTo(this.pos,25);
ctx.closePath();
ctx.strokeStyle = "Red";//border color here
ctx.stroke();
ctx.fillStyle = "blue";//fill color here
ctx.fill();

【讨论】:

    【解决方案2】:

    您可以使用canvas.drawLine(this.pos/2, 25, this.pos, 25, ppaint)。 drawPath() 在您的代码中按预期工作;)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-09-27
      • 2014-11-24
      • 2013-07-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-23
      • 1970-01-01
      相关资源
      最近更新 更多