Algorithmic Animation with Javascript Tail
How do I make an algorithmic animation with javascript tail?
What is a algorithmic animation with javascript tail? How do you make a algorithmic animation with javascript tail? This script and codes were developed by Wenting Zhang on 07 November 2022, Monday.
Algorithmic Animation with Javascript Tail - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Algorithmic Animation with Javascript Tail</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <canvas id="myCanvas" width="1440" height="768"></canvas> <script src="js/index.js"></script>
</body>
</html>
Algorithmic Animation with Javascript Tail - Script Codes CSS Codes
body { margin: 0px; padding: 0px;
}
#myCanvas { background-color: #000;
}
Algorithmic Animation with Javascript Tail - Script Codes JS Codes
function Point(x, y) { this.x = x; this.y = y;
}
function QueueLine(n, color, radius) { this.n = n; this.color = color; this.radius = radius; this.position = []; for (var i = 0; i < n; i++) { this.position.push(new Point(0, 0)); } this.positionB = []; for (var i = 0; i < n; i++) { this.positionB.push(new Point(0, 0)); } var self = this; window.addEventListener('mousemove', function(pos) { self.mouseMove(self, pos) }, false); //http://stackoverflow.com/questions/1338599/addeventlistener-this
}
QueueLine.prototype.draw = function() { context.fillStyle = this.color; context.arc(this.position[0].x + 0.5 * (this.positionB[0].x - this.position[0].x), this.position[0].y + 0.5 * (this.positionB[0].y - this.position[0].y), this.radius, 0, 2 * Math.PI); this.position[0].x = this.position[0].x + 0.5 * (this.positionB[0].x - this.position[0].x); this.position[0].y = this.position[0].y + 0.5 * (this.positionB[0].y - this.position[0].y); for (var i = 1; i < this.n; i++) { this.positionB[i].x = this.position[i - 1].x; this.positionB[i].y = this.position[i - 1].y; context.beginPath(); context.arc(this.position[i].x + 0.5 * (this.positionB[i].x - this.position[i].x), this.position[i].y + 0.5 * (this.positionB[i].y - this.position[i].y), this.radius - 0.4 * i, 0, 2 * Math.PI); this.position[i].x = this.position[i].x + 0.5 * (this.positionB[i].x - this.position[i].x); this.position[i].y = this.position[i].y + 0.5 * (this.positionB[i].y - this.position[i].y); context.fill(); }
};
QueueLine.prototype.mouseMove = function(self, pos) { self.positionB[0].x = pos.clientX; self.positionB[0].y = pos.clientY;
};
var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
window.requestAnimFrame = (function(callback) { return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(callback) { window.setTimeout(callback, 1000 / 60); };
})();
var yourQueueLine = new QueueLine(14, "#ffff00", 7);
//var myQueueLine = new QueueLine(12, "rgba(255, 255, 255, 0.4)", 10);
function animate() { // update // clear context.clearRect(0, 0, canvas.width, canvas.height); // draw stuff //myQueueLine.draw(); yourQueueLine.draw(); // request new frame requestAnimFrame(function() { animate(); });
}
animate();
Developer | Wenting Zhang |
Username | wentin |
Uploaded | November 07, 2022 |
Rating | 3 |
Size | 2,356 Kb |
Views | 12,144 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Responsify images | 2,140 Kb |
Profession.is type transitions | 12,481 Kb |
P5.js start point | 1,504 Kb |
ResponsifyJS demo | 5,586 Kb |
Three.js start point | 1,866 Kb |
100 days of research | 7,754 Kb |
A Pen by Wenting Zhang | 1,570 Kb |
Comedy Central Loading SVG | 7,744 Kb |
Getting x-height and descender line | 2,822 Kb |
SVG Animation | 30,040 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Google Chrome Icon using Pure CSS in one DIV | Grssam | 3,627 Kb |
Fixed Scrolling Nav Bar | Philsinatra | 0 Kb |
Cars going | Netoguimaraes | 1,699 Kb |
Slick Slider | Wearebold | 5,913 Kb |
AngularJS Datalist Directive | M-e-conroy | 2,366 Kb |
Import shader in three.js | Khangeldy | 2,636 Kb |
Multi column experiment. | Spylefkaditis | 2,805 Kb |
Flat buttons for Eliassen.com | Kdooley89 | 1,737 Kb |
Polygon Logo in CSS | Kai | 3,412 Kb |
Pricing Table | Semenchenko | 6,784 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!