canvas绘制三角形
效果圖
html結構
????
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>canvas2</title>
<link rel="stylesheet" href="">
</head>
<body>
<canvas id="canvas" style ="border:1px solid #aaa;diplay:block;margin:50px auto;">
當前瀏覽器不支持canvas,請更換瀏覽器后再試
</canvas>
</body>
</html>
js腳本
?? ?<script>
window.onload = function(){
var canvas = document.getElementById('canvas');
canvas.width = 800;
canvas.height = 800;
var context = canvas.getContext('2d');
context.beginPath();
context.moveTo(100,100);
context.lineTo(700,700);
context.lineTo(100,700);
context.lineTo(100,100);
context.closePath();
context.lineWidth = 10;
context.strokeStyle = "#058";
context.stroke();
}
</script>
轉載于:https://blog.51cto.com/suyanzhu/1892680
總結
以上是生活随笔為你收集整理的canvas绘制三角形的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 百度地图根据经纬度计算瓦片行列号
- 下一篇: discuz回贴通知插件实现-配置邮件服