<bdo id='aTsId'></bdo><ul id='aTsId'></ul>

    <tfoot id='aTsId'></tfoot>

  • <i id='aTsId'><tr id='aTsId'><dt id='aTsId'><q id='aTsId'><span id='aTsId'><b id='aTsId'><form id='aTsId'><ins id='aTsId'></ins><ul id='aTsId'></ul><sub id='aTsId'></sub></form><legend id='aTsId'></legend><bdo id='aTsId'><pre id='aTsId'><center id='aTsId'></center></pre></bdo></b><th id='aTsId'></th></span></q></dt></tr></i><div id='aTsId'><tfoot id='aTsId'></tfoot><dl id='aTsId'><fieldset id='aTsId'></fieldset></dl></div>

    <small id='aTsId'></small><noframes id='aTsId'>

  • <legend id='aTsId'><style id='aTsId'><dir id='aTsId'><q id='aTsId'></q></dir></style></legend>

        在画布中绘制 1px 粗线会创建 2px 粗线

        Drawing a 1px thick line in canvas creates a 2px thick line(在画布中绘制 1px 粗线会创建 2px 粗线)
          <bdo id='L9Yln'></bdo><ul id='L9Yln'></ul>
        • <tfoot id='L9Yln'></tfoot>

                  <tbody id='L9Yln'></tbody>
                <legend id='L9Yln'><style id='L9Yln'><dir id='L9Yln'><q id='L9Yln'></q></dir></style></legend>

                1. <i id='L9Yln'><tr id='L9Yln'><dt id='L9Yln'><q id='L9Yln'><span id='L9Yln'><b id='L9Yln'><form id='L9Yln'><ins id='L9Yln'></ins><ul id='L9Yln'></ul><sub id='L9Yln'></sub></form><legend id='L9Yln'></legend><bdo id='L9Yln'><pre id='L9Yln'><center id='L9Yln'></center></pre></bdo></b><th id='L9Yln'></th></span></q></dt></tr></i><div id='L9Yln'><tfoot id='L9Yln'></tfoot><dl id='L9Yln'><fieldset id='L9Yln'></fieldset></dl></div>
                2. <small id='L9Yln'></small><noframes id='L9Yln'>

                  本文介绍了在画布中绘制 1px 粗线会创建 2px 粗线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在这个 jsfiddle 中有一条 lineWidth 为 1 的线.

                  In this jsfiddle there's a line with a lineWidth of 1.

                  http://jsfiddle.net/mailrox/9bMPD/350/

                  例如:

                  ctx.lineWidth = 1;
                  

                  但是在画布上绘制的线条是 2px 粗的,你如何创建一个 1px 粗的线条.

                  However the line is 2px thick when it's drawn on the canvas, how do you create a 1px thick line.

                  我可以绘制一个矩形(高度为 1 像素),但我希望这条线也适用于对角线.那么如何让这条线达到 1px 高呢?

                  I could draw a rectangle (with 1px height) however I want the line to also work on diagonals. So how do you get this line to be 1px high?

                  谢谢!

                  推荐答案

                  Canvas 从半个像素开始计算

                  Canvas calculates from the half of a pixel

                  ctx.moveTo(50,150.5);
                  ctx.lineTo(150,150.5);
                  

                  所以从一半开始会解决它

                  So starting at a half will fix it

                  固定版本:http://jsfiddle.net/9bMPD/357/

                  这个答案解释了为什么它会这样工作.

                  This answer explains why it works that way.

                  这篇关于在画布中绘制 1px 粗线会创建 2px 粗线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to make rooftext effect and valley text effect in HTML5 (or Fabric.js)(如何在 HTML5(或 Fabric.js)中制作屋顶文字效果和山谷文字效果)
                  Draw border around nontransparent part of image on canvas(在画布上的图像不透明部分周围绘制边框)
                  dragging and resizing an image on html5 canvas(在 html5 画布上拖动图像并调整其大小)
                  What#39;s the difference between a boolean as primitive and a boolean as property of an object?(作为原始对象的布尔值和作为对象属性的布尔值有什么区别?)
                  I want to do animation of an object along a particular path(我想沿特定路径对对象进行动画处理)
                  How to upload image into HTML5 canvas(如何将图像上传到 HTML5 画布中)
                    <tbody id='EPThr'></tbody>

                  1. <tfoot id='EPThr'></tfoot>
                    <i id='EPThr'><tr id='EPThr'><dt id='EPThr'><q id='EPThr'><span id='EPThr'><b id='EPThr'><form id='EPThr'><ins id='EPThr'></ins><ul id='EPThr'></ul><sub id='EPThr'></sub></form><legend id='EPThr'></legend><bdo id='EPThr'><pre id='EPThr'><center id='EPThr'></center></pre></bdo></b><th id='EPThr'></th></span></q></dt></tr></i><div id='EPThr'><tfoot id='EPThr'></tfoot><dl id='EPThr'><fieldset id='EPThr'></fieldset></dl></div>
                    • <bdo id='EPThr'></bdo><ul id='EPThr'></ul>

                          <small id='EPThr'></small><noframes id='EPThr'>

                          <legend id='EPThr'><style id='EPThr'><dir id='EPThr'><q id='EPThr'></q></dir></style></legend>