Brownian Gnats
How do I make an brownian gnats?
Click canvas to reset.I'm exploring Brownian Motion. Here I combined it with the concept of particle trails, as explained by David Shiffman on Coding Train. Instead of drawing dots on the trail, I draw lines from the current position to all the points in the trail.. What is a brownian gnats? How do you make a brownian gnats? This script and codes were developed by Johan Karlsson on 24 July 2022, Sunday.
Brownian Gnats - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Brownian Gnats</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <script src='https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.6/p5.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Brownian Gnats - Script Codes CSS Codes
html, body { margin: 0;
}
canvas { display: block;
}
Brownian Gnats - Script Codes JS Codes
"use strict";
/* Johan Karlsson (DonKarlssonSan) Click canvas to reset.
*/
function Particle() { this.pos = createVector(random(windowWidth), random(windowHeight)); this.tail = []; this.tailLength = 7;
}
Particle.prototype.move = function () { if (this.tail.length > this.tailLength) { this.tail.splice(0, 1); } this.tail.push(this.pos.copy()); this.pos.x += random(-particleStepMax, particleStepMax); this.pos.y += random(-particleStepMax, particleStepMax);
};
Particle.prototype.draw = function () { var _this = this; this.tail.forEach(function (pos) { line(_this.pos.x, _this.pos.y, pos.x, pos.y); });
};
var particles;
var particleStepMax;
function setup() { cursor(HAND); particleStepMax = 6; initParticles(); createCanvas(windowWidth, windowHeight);
}
function draw() { background(255); particles.forEach(function (p) { p.move(); p.draw(); });
}
function initParticles() { particles = []; for (var i = 0; i < 40; i++) { particles.push(new Particle()); }
}
function windowResized() { resizeCanvas(windowWidth, windowHeight);
}
function mouseClicked() { initParticles(); background(255);
}
Developer | Johan Karlsson |
Username | DonKarlssonSan |
Uploaded | July 24, 2022 |
Rating | 4.5 |
Size | 2,822 Kb |
Views | 74,888 |
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 |
Diffusion-Limited Aggregation - Line | 2,550 Kb |
Antenna Generator | 2,624 Kb |
Rotating Neon Curves | 3,770 Kb |
In Tribute to Simon Plouffe | 2,376 Kb |
The Birth of a Sine Wave | 2,607 Kb |
Random Fractal | 2,751 Kb |
Wayward Walker Worms | 3,123 Kb |
Moss by Brownian Motion | 2,792 Kb |
Photobooth - Webcam with realtime CSS filters. | 4,390 Kb |
Circuit Board Warper | 4,057 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 |
Tic Tac Toe | Volv | 4,862 Kb |
Full page table inside the grid | Twikito | 1,864 Kb |
CSS3 Butterfly | Timohausmann | 3,430 Kb |
Simple star rating using js and data-uri | TheEnd | 5,795 Kb |
BlueBox Fork | Huskynation | 12,675 Kb |
SVG Text Masking | JMChristensen | 2,141 Kb |
Loading animation | Codeams | 2,408 Kb |
Mondrian | Chrisarmstrong | 2,787 Kb |
Objects | Bonzaipenguin | 2,616 Kb |
Rrremark.com Overlay Highlighter | Derickruiz | 4,438 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!