JSFiddle - React, Tailwind, and code Playground
by ArtJH
HTML
<script src="https://code.jquery.com/pep/0.4.3/pep.js"></script>
CSS
body, html { margin: 0;
background: #000}
canvas { position: fixed; touch-action: none; }
JavaScript
let canvas, ctx;
let render, init;
let blob;
class Blob {
constructor() {
this.points = [];
}
init() {
for(let i = 0; i < this.numPoints; i++) {
let point = new Point(this.divisional * ( i + 1 ), this);
// point.acceleration = -1 + Math.random() * 2;
this.push(point);
}
}
render() {
let canvas = this.canvas;
let ctx = this.ctx;
let position = this.position;
let pointsArray = this.points;
let radius = this.radius;
let points = this.numPoints;
let divisional = this.divisional;
let center = this.center;
ctx.clearRect(0,0,canvas.width,canvas.height);
pointsArray[0].solveWith(pointsArray[points-1], pointsArray[1]);
let p0 = pointsArray[points-1].position;
let p1 = pointsArray[0].position;
let _p2 = p1;
ctx.beginPath();
ctx.moveTo(center.x, center.y);
var img = new Image(); ...