context.beginPath(); context.moveTo( 100, 100 ); context.lineTo( 400, 100 ); context.closePath(); context.stroke(); context.beginPath(); context.strokeStyle = 'red'; context.moveTo( 100.5, 200.5 ); context.lineTo( 400.5, 200.5 ); context.closePath(); context.stroke();
drawGrid('#09f', 10, 10); function drawGrid(color, stepx, stepy) { context.save() context.strokeStyle = color; context.lineWidth = 0.5; context.clearRect(0, 0, context.canvas.width, context.canvas.height); for (var i = stepx + 0.5; i < context.canvas.width; i += stepx) { context.beginPath(); context.moveTo(i, 0); context.lineTo(i, context.canvas.height); context.stroke(); } for (var i = stepy + 0.5; i < context.canvas.height; i += stepy) { context.beginPath(); context.moveTo(0, i); context.lineTo(context.canvas.width, i); context.stroke(); } context.restore(); }
以上就是html5 1px问题以及绘制坐标系网格的方法的详细内容,更多请关注Gxl网其它相关文章!
查看更多关于html51px问题以及绘制坐标系网格的方法的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did72040