在HTML5画布上绘制点 [英] Drawing a dot on HTML5 canvas
本文介绍了在HTML5画布上绘制点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用 context.moveTo()
和 context.lineTo()$ c $在HTML5画布上绘制线条非常简单c>函数。
我不太确定是否可以绘制一个点,即单个像素的颜色。 lineTo函数不绘制单个像素行(显然)。
I'm not quite sure if it's possible to draw a dot i.e. color a single pixel. The lineTo function wont draw a single pixel line (obviously).
有没有方法来做这个?
推荐答案
出于性能原因,如果你可以避免它,不要画一个圆。只需绘制宽度和高度为1的矩形:
For performance reasons, don't draw a circle if you can avoid it. Just draw a rectangle with a width and height of one:
ctx.fillRect(10,10,1,1); // fill in the pixel at (10,10)
这篇关于在HTML5画布上绘制点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文