源码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>spread</title>
<style type="text/css">
body {
overflow: hidden;
background: #eee;
}
</style>
</head>
<body>
<canvas id="canvas" width="100" height="100"></canvas>
<script type="text/javascript">
'use strict';
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
var width = undefined,
height = undefined;
var forces = [],
particles = [];
var nParticles = 250;
var p = 0;
var V2 = function () {
function V2(x, y) {
_classCallCheck(this, V2);
this.x = x || 0;
this.y = y || 0;
}
V2.prototype.add = function add(vector) {
this.x += vector.x;
this.y += vector.y;
};
V2.prototype.reset = function reset(x, y) {
this.x = x;
this.y = y;
};
V2.prototype.lerp &#