利用html5标签画圆
程序员文章站
2022-04-24 22:03:52
...
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
</head>
<body>
<canvas id='myCanvas' width='500px' height='300px' style='border:1px solid #CCC'>您的浏览器不支持canvas标签</canvas>
</body>
<script>
//开始画图,通过javascript画出来
//1得到画布:
var canvas = document.getElementById('myCanvas');
//得到画笔,获得二维的画布
var ctx = canvas.getContext('2d');
//开始画圆
ctx.beginPath();
ctx.fillStyle = 'red';
//(圆心,半径,从三点为圆心,弧度)
ctx.arc(50,50,20,0,Math.PI*2,true);
ctx.closePath();
ctx.fill();
</script>
</html>
<html>
<head>
<meta charset='utf-8' />
</head>
<body>
<canvas id='myCanvas' width='500px' height='300px' style='border:1px solid #CCC'>您的浏览器不支持canvas标签</canvas>
</body>
<script>
//开始画图,通过javascript画出来
//1得到画布:
var canvas = document.getElementById('myCanvas');
//得到画笔,获得二维的画布
var ctx = canvas.getContext('2d');
//开始画圆
ctx.beginPath();
ctx.fillStyle = 'red';
//(圆心,半径,从三点为圆心,弧度)
ctx.arc(50,50,20,0,Math.PI*2,true);
ctx.closePath();
ctx.fill();
</script>
</html>
上一篇: Python给你的头像加上圣诞帽
下一篇: python的几个高级特性