代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<canvas class = "canvas"></canvas>
<script>
var S = {
start: function(){
Draw.init();
//Draw.drawRadial();
Shape.switchShape(Shape.drawHeart());
Draw.loop(function(){
Shape.render();
});
}
};
Point = function(args){
this.x = args.x;
this.y = args.y;
this.z = args.z;
this.a = args.a;
};
Dot = function(x,y){
this.p = new Point({
x:x,
y:y,
z:5,
a:1,
h:0
});
this.e = 0.07;
this.s = true;
this.t = this.clone();
this.q = [];
};
Dot.prototype = {
clone: function(){
return new Point({
x: this.x,
y: this.y,
z: this.z,
a: this.a,
h: this.h
});
},
move: function(p){
this.q.push(p);
},
moveTowards: function(n){
var dx = this.p.x - n.x,
dy = this.p.y - n.y,
dl = Math.sqrt(dx * dx + dy * dy),
e = this.e * dl;
if(this.h === -1){
this.