<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>滚动的小球 原型链</title>
</head>
<body>
<canvas id="canvas"></canvas>
<script type="text/javascript">
let canvas=document.getElementById("canvas");
let ctx=canvas.getContext("2d");
canvas.width=1000;
canvas.height=500;
canvas.style.backgroundColor="#000";
// 绘制图形
function ball(x,y,color){
this.x=x;//x坐标
this.y=y;//y坐标
this.r=40;//半径
this.color=color;//颜色
}
ball.prototype={
constructor:ball,
rand(){
ctx.save