html5中canvas繪製線段
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>繪製線段</title>
</head>
<body>
<canvas id="myCanvas" width="500" height="500"></canvas>
<!--
context.moveto(x,y);
context.lineto(x,y);
x,y 座標
每次畫線都從moveTo的點到lineTo的點,
如果沒有moveTo那麼第一次lineTo的效果和moveTo一樣,
每次lineTo後如果沒有moveTo,那麼下次lineTo的開始點為前一次lineTo的結束點
-->
<script type="text/javascript">
var canvas=document.getElementById('myCanvas');
var context=canvas.getContext('2d');
context.strokeStyle="blue";
context.lineTo(100,100);
context.lineTo(100,200);
context.moveTo(100,200);
context.lineTo(200,100);
context.stroke();
</script>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title>繪製線段</title>
</head>
<body>
<canvas id="myCanvas" width="500" height="500"></canvas>
<!--
context.moveto(x,y);
context.lineto(x,y);
x,y 座標
每次畫線都從moveTo的點到lineTo的點,
如果沒有moveTo那麼第一次lineTo的效果和moveTo一樣,
每次lineTo後如果沒有moveTo,那麼下次lineTo的開始點為前一次lineTo的結束點
-->
<script type="text/javascript">
var canvas=document.getElementById('myCanvas');
var context=canvas.getContext('2d');
context.strokeStyle="blue";
context.lineTo(100,100);
context.lineTo(100,200);
context.moveTo(100,200);
context.lineTo(200,100);
context.stroke();
</script>
</body>
</html>
相關文章
- html5中canvas線段繪製太陽花HTMLCanvas
- html5中canvas繪製貝塞爾曲線HTMLCanvas
- html5中canvas貝塞爾曲線繪製菊花HTMLCanvas
- html5中canvas繪製矩形HTMLCanvas
- canvas核心技術-如何繪製線段Canvas
- html5中canvas繪製圓形HTMLCanvas
- canvas 繪製線條Canvas
- canvas繪製直線Canvas
- html5中的canvas繪製橢圓的方法HTMLCanvas
- canvas 繪製雙線技巧Canvas
- html5 canvas學習--繪製文字HTMLCanvas
- HTML5使用canvas繪製圖形HTMLCanvas
- canvas繪製sin正弦曲線Canvas
- 使用 HTML5 Canvas 繪製的水滴效果HTMLCanvas
- canvas繪製網格射線效果Canvas
- HTML5 Canvas ( 矩形的繪製 ) rect, strokeRect, fillRectHTMLCanvas
- HTML5 Canvas使用路徑——繪製圓形HTMLCanvas
- canvas繪製經典星空連線效果Canvas
- HTML5 Canvas(實戰:繪製餅圖2 Tooltip)HTMLCanvas
- HTML5利用canvas繪製矩形程式碼例項HTMLCanvas
- canvas 繪製矩形Canvas
- canvas 繪製扇形Canvas
- canvas 繪製文字Canvas
- canvas繪製拋物線程式碼例項Canvas線程
- 繪製SVG內容到Canvas的HTML5應用SVGCanvasHTML
- 在Canvas中繪製Geojson資料CanvasJSON
- canvas 繪製圓形Canvas
- canvas繪製流星效果Canvas
- canvas繪製帶有漸變效果的直線Canvas
- 如何使用echart中獲取canvas繪製到自己的canvas上去Canvas
- Canvas 繪製雷達圖Canvas
- canvas繪製動畫的技巧Canvas動畫
- canvas 繪製立體圓環Canvas
- canvas 繪製文字詳解Canvas
- canvas 繪製圓角矩形Canvas
- canvas 繪製矩形缺角Canvas
- canvas繪製風車效果Canvas
- canvas繪製笑臉表情Canvas