javascript - Canvas LineTo 不工作 IOS / IPAD
问题描述
嘿,我用画布画了一个简单的点
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 上显示
解决方案
您的代码在任何浏览器上都没有为我绘制任何东西......
我在最后添加了一个适当的 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>
推荐阅读
- python - 在 django 中使用 ElasticSearch 和 docker 时遇到 connectionError
- python - 哨兵没有收到异常
- javascript - 如何自动获取用户的地理位置值并将其作为 POST 请求发送到后端
- spring - 更改了 application.properties 中的 server.port 但无法正常工作
- jquery - 如何在jQgrid中找到当前行?
- javascript - 带有 for 循环的冒泡排序无法按预期工作
- c# - 如何在方法期间通过依赖注入从池中获取 DbContext 的实例?
- reactjs - 如何使用 React Router 访问 Redux 存储?
- shell - ZSH Listen to Command Not Found
- html - Freemarker 模板返回字符串而不是 html 元素