这样可以吗老师?
来源:4-10 编程练习
lcyjerry
2020-04-05 15:19:34
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>案例</title>
<style>
canvas{background-color:lightblue;}
</style>
</head>
<body>
<canvas id="canvas" width="600px" height="600px">您的浏览器不支持</canvas>
<script>
var canvas=document.getElementById("canvas");
var ctx=canvas.getContext("2d");
//在此处编写代码
ctx.translate(300,300);
ctx.save();
ctx.arc(0,0,100,0,Math.PI*2,true);
ctx.fillStyle = "rgba(255,0,0,1)";
ctx.fill();
ctx.beginPath()
for(var i = 0;i < 4;i++){
ctx.rotate(Math.PI/2);
ctx.moveTo(90,0);
ctx.lineTo(100,0);
}
ctx.moveTo(0,0);
ctx.lineTo(80,0);
ctx.moveTo(0,0);;
ctx.lineTo(10,-70);
ctx.stroke();
</script>
</body>
</html>
1回答
樱桃小胖子
2020-04-06
同学你好,效果实现的是可以的,继续加油,祝学习愉快!
相似问题