<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>机器人</title>
<style>
body{margin: 0;overflow: hidden;}
#canvas{background: antiquewhite;}
</style>
</head>
<body>
<canvas id="canvas" width="600" height="700">
</canvas>
<script>
const canvas=document.getElementById('canvas');
canvas.width=window.innerWidth;
canvas.height=window.innerHeight;
const ctx=canvas.getContext('2d');
function render(color='red'){
ctx.fillStyle=color;
ctx.lineWidth=40;
ctx.fillRect(50,250,400,200);
ctx.strokeRect(50,250,400,200);
ctx.clearRect(50,300,400,60);
ctx.beginPath();
ctx.moveTo(350,400);
ctx.bezierCurveTo(350,400,250,420,150,400);
ctx.stroke(
使用canvas绘制机器人
最新推荐文章于 2022-06-15 11:03:26 发布