【问题标题】:Canvas LineTo not working IOS / IPADCanvas LineTo 不工作 IOS / IPAD
【发布时间】:2019-01-20 08:22:10
【问题描述】:

嘿,我用画布画了一个简单的点

    ctx.lineWidth = 5;
    ctx.lineJoin = 'round';
    ctx.lineCap = 'round';
    ctx.strokeStyle = 'blue';
 ctx.beginPath();
        //ctx.moveTo(last_mouse.x, last_mouse.y);
ctx.lineTo(120, 40);

但它在 IOS 上不显示点,仅在 Android / Windows 上显示

【问题讨论】:

  • 在 iOS 上不显示 do 但在 Android/iOS 上显示 ????请更正您的问题。
  • 在IOS IPAD上不显示点
  • @HelderSepu Chrome 在所有平台上

标签: javascript ios html canvas


【解决方案1】:

您的代码在任何浏览器上都没有为我绘制任何东西...

我在末尾添加了一个适当的 moveTo 和一个笔画,这是示例:

<canvas id="canvas" style="border:1px solid #000000;"></canvas>
<script>
  var canvas = document.getElementById('canvas');
  var ctx = canvas.getContext('2d');
  ctx.lineJoin = ctx.lineCap = 'round';

  // Draw a Blue dot on the middle of the canvas
  ctx.beginPath();
  ctx.lineWidth = 50;
  ctx.strokeStyle = 'blue';
  ctx.lineTo(canvas.width / 2, canvas.height / 2);
  ctx.stroke();

  // Draw a diagonal Red line on the canvas
  ctx.beginPath();
  ctx.lineWidth = 5;
  ctx.strokeStyle = 'red';
  ctx.moveTo(20, 20);
  ctx.lineTo(canvas.width - 20, canvas.height - 20);
  ctx.stroke();
</script>

【讨论】:

    猜你喜欢
    • 2016-10-06
    • 1970-01-01
    • 2018-09-18
    • 1970-01-01
    • 2011-05-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多