网页设计之笑脸

此博客展示了如何使用HTML5 Canvas元素进行图形绘制。首先创建了一个红色边框的矩形,接着绘制了一个粉色填充的三角形,然后是一个黄色填充的圆形,并在其内部添加了两个黑色小圆作为眼睛。最后清除了一部分圆形内的区域。
摘要由CSDN通过智能技术生成
<!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<title>无标题文档</title>

</head>

<body>
<canvas id="myCanvas" width="400" height="300" style="border:1px solid red"	>对不起,您的浏览器不支持画布</canvas>
<script>
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.beginPath();
ctx.moveTo(10,10);
ctx.lineTo(390,10);
ctx.lineTo(390,290);
ctx.closePath();
ctx.stroke();

ctx.beginPath();
ctx.moveTo(10,10);
ctx.lineTo(10,290);
ctx.lineTo(390,290);
ctx.closePath();
ctx.fillStyle="pink";
ctx.fill();

ctx.beginPath();
ctx.arc(200,150,100,0,Math.PI*2,true);
ctx.fillStyle="yellow";
ctx.stroke();
ctx.fill();
ctx.beginPath();
ctx.arc(150,120,20,0,Math.PI*2,true);
ctx.arc(250,120,20,0,Math.PI,true);
ctx.fillStyle="black";
ctx.fill();
ctx.beginPath();
ctx.arc(200,170,50,0,Math.PI,false);
ctx.fillStyle="red";
ctx.fill();
ctx.stroke();

ctx.beginPath();
ctx.clearRect(150,110,10,10);

</script>
</body>
</html>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

错误代码937

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值