发现imooc markdown的代码运行功能,感觉不错。但是貌似没找到使用说明。为了能更好的了解该功能,测试一下:
<!DOCTYPE html>
<html lang="en">
<head>
<style>
html,body {margin:0;height:100%;overflow:hidden;}
</style>
<meta charset="UTF-8">
<title>随风而行之青衫磊落险峰行测试imooc的markdown run功能</title>
</head>
<body>
<canvas id="myCanvas" width="800" height="600" style="border: 1px solid black">
你的浏览器还不支持哦
</canvas>
</body>
<script>
function drawGrid(backcolor,color, stepx, stepy) {
context.save()
context.strokeStyle = color;
context.fillStyle = backcolor;
context.lineWidth = 0.5;
context.fillRect(0, 0, context.canvas.width, context.canvas.height);
context.globalAlpha = 0.1;
context.beginPath();
for (var i = stepx + 0.5; i < context.canvas.width; i += stepx) {
context.moveTo(i, 0);
context.lineTo(i, context.canvas.height);
}
context.stroke();
context.beginPath();
for (var i = stepy + 0.5; i < context.canvas.height; i += stepy) {
context.moveTo(0, i);
context.lineTo(context.canvas.width, i);
}
context.stroke();
context.restore();
}
var canvas=document.getElementById("myCanvas");
var context =canvas.getContext('2d');
drawGrid('black','white',10,10);
</script>
</html>
期待一下是否能在markdown run中正常运行,显示出canvas2d绘制出来的黑色背景网格
热门评论
太帅了,可以做演示。
这个功能的确是很吸引人!