|
@@ -0,0 +1,34 @@
|
|
|
+<!DOCTYPE html>
|
|
|
+<html lang="en">
|
|
|
+<head>
|
|
|
+ <meta charset="UTF-8">
|
|
|
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
+ <title>Document</title>
|
|
|
+ <style>
|
|
|
+ #can{
|
|
|
+ /* width: 500px;
|
|
|
+ height: 500px; */
|
|
|
+ background-color: yellow;
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+</head>
|
|
|
+<body>
|
|
|
+ <canvas id="can" width="500" height="500"></canvas>
|
|
|
+ <script>
|
|
|
+ var oCan = document.getElementById('can');
|
|
|
+ // 初始化canvas
|
|
|
+ var oCtx = oCan.getContext('2d');
|
|
|
+ // 设置线条样式
|
|
|
+ oCtx.lineWidth = 10;
|
|
|
+ oCtx.strokeStyle = 'red';
|
|
|
+ // 绘制一个条直线
|
|
|
+ // 落笔点
|
|
|
+ oCtx.moveTo(100,100);
|
|
|
+ // 抬笔点
|
|
|
+ oCtx.lineTo(400,400);
|
|
|
+ oCtx.lineTo(400,100);
|
|
|
+ // 绘制
|
|
|
+ oCtx.stroke();
|
|
|
+ </script>
|
|
|
+</body>
|
|
|
+</html>
|