改编:html canvas 画心电图网格

改编自:http://blog.csdn.net/yc1022/article/details/40094775

<!DOCTYPE html>

<html>
<head>
<title>The ECG waveform</title>
</head>
<canvas id="ecg1" width="600px" height="600px" ></canvas>
<canvas id="ecg2" width="750px" height="750px" ></canvas>
<script type="text/javascript"> 
function drawGrid()
{
var c_canvas1 = document.getElementById("ecg1");
var context1 = c_canvas1.getContext("2d");
drawSmallGrid(context1, 450, 450);
drawMediumGrid(context1, 450, 450);
drawBigGrid(context1, 450, 450);

var c_canvas2 = document.getElementById("ecg2");
var context2 = c_canvas2.getContext("2d");
drawSmallGrid(context2, c_canvas2.width, c_canvas2.height);
drawMediumGrid(context2, c_canvas2.width, c_canvas2.height);
drawBigGrid(context2, c_canvas2.width, c_canvas2.height);
return;

 
function drawContextGrid(context, width, height, xInterval, yInterval)
{
context.beginPath();
for (var x = 0.5; x < width; x += xInterval) 
{
context.moveTo(x, 0);
context.lineTo(x, height);
context.stroke(); 
}

for (var y = 0.5; y < height; y += yInterval) 
{
context.moveTo(0, y);
context.lineTo(width, y);
context.stroke(); 
}
context.closePath();
return;
}

function drawSmallGrid(context, width, height)
{
context.strokeStyle = "#f1dedf";
context.strokeWidth=1;
drawContextGrid(context, width, height, 3, 3);
return;

      
function drawMediumGrid(context, width, height)
{
context.strokeStyle = "#f0adaa";
context.strokeWidth=1;
drawContextGrid(context, width, height, 15, 15);
return;

 
function drawBigGrid(context, width, height)
{
context.strokeStyle = "#e0514b";
context.strokeWidth=1;
drawContextGrid(context, width, height, 75, 75);
return;
}


drawGrid();

     </script>
</html>
  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值