Text by Brownian Motion
How do I make an text by brownian motion?
What is a text by brownian motion? How do you make a text by brownian motion? This script and codes were developed by Johan Karlsson on 24 July 2022, Sunday.
Text by Brownian Motion - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Text by Brownian Motion</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>
Text by Brownian Motion - Script Codes CSS Codes
html, body { margin: 0;
}
canvas { display: block;
}
Text by Brownian Motion - Script Codes JS Codes
"use strict";
/* Johan Karlsson (DonKarlssonSan)
*/
function Particle() { this.x = random([0, w]); this.y = random([0, h]); this.oldX = this.x; this.oldY = this.y;
}
Particle.prototype.move = function (stepSize) { this.oldX = this.x; this.oldY = this.y; this.x += random(-stepSize, stepSize); this.y += random(-stepSize, stepSize); if (this.x < 0) this.x = 0; if (this.x > w) this.x = w; if (this.y < 0) this.y = 0; if (this.y > h) this.y = h;
};
Particle.prototype.draw = function () { line(this.oldX, this.oldY, this.x, this.y);
};
var particles;
var iterations;
var px;
var w;
var h;
function setup() { cursor(HAND); iterations = 5; w = windowWidth; h = windowHeight; createCanvas(w, h); reset(); stroke(0, 10);
}
function draw() { for (var i = 0; i < iterations; i++) { particles.forEach(function (p) { var x = floor(p.x); var y = floor(p.y); var off = (y * w + x) * 4; var stepSize = 30; if (px[off + 3] > 100) { stepSize = 2; } p.move(stepSize); p.draw(); }); }
}
function initParticles() { particles = []; for (var i = 0; i < 50; i++) { particles.push(new Particle()); }
}
function initImage() { var message = "I love you"; var tSize = 150; textSize(tSize); var tWidth = textWidth(message); text(message, w / 2 - tWidth / 2, h / 2 + tSize / 2); var image = get(0, 0, w, h); image.loadPixels(); px = image.pixels; background(255);
}
function reset() { initParticles(); clear(); initImage();
}
function windowResized() { resizeCanvas(windowWidth, windowHeight); w = windowWidth; h = windowHeight; reset();
}
function mouseClicked() { reset();
}
Developer | Johan Karlsson |
Username | DonKarlssonSan |
Uploaded | July 24, 2022 |
Rating | 4.5 |
Size | 3,182 Kb |
Views | 68,816 |
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 |
Antenna Generator | 2,624 Kb |
Portrait by Brownian Motion | 3,612 Kb |
Random Fractal | 2,751 Kb |
In Tribute to Simon Plouffe | 2,376 Kb |
Particle Text | 5,685 Kb |
Cash by Brownian Motion | 3,530 Kb |
Phone Case Pattern Animation | 2,774 Kb |
The Birth of a Sine Wave | 2,607 Kb |
Rainbow 6-fold Pentille | 4,311 Kb |
Lissajous x Lissajous | 3,369 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 |
The Fantastic Mr Fox | MalZiiirA | 10,435 Kb |
V.35 The Monolith Update - Hero Release Notes | Jordan | 12,045 Kb |
Minimal Menu | Achudars | 3,430 Kb |
A Pen by Moeid Saleem | Moeidsaleem | 1,862 Kb |
Canvas Orbital Trails v2 | Jackrugile | 3,421 Kb |
CSS Bot Confusion | Jpod | 3,456 Kb |
Flex layout example | Mofny | 1,663 Kb |
React Markdown Previewer | C0d0er | 3,190 Kb |
404 Error Page | WebSonick | 3,203 Kb |
Starfield using KineticJS | Asp | 3,512 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!