Moss by Brownian Motion

Size
2,792 Kb
Views
50,600

How do I make an moss by brownian motion?

Click the canvas to restart and set a new random max step size. Max step size is 5 pixels initially.I have a collection with Pens based on Brownian Motion.. What is a moss by brownian motion? How do you make a moss by brownian motion? This script and codes were developed by Johan Karlsson on 24 July 2022, Sunday.

Moss by Brownian Motion Previews

Moss by Brownian Motion - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Moss 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>

Moss by Brownian Motion - Script Codes CSS Codes

html, body { margin: 0;
}
canvas { display: block;
}

Moss by Brownian Motion - Script Codes JS Codes

"use strict";
/* Johan Karlsson (DonKarlssonSan) Click the canvas to restart and set a new random max step size. Max step size is 5 pixels initially.
*/
function Particle() { this.x = random(windowWidth); this.y = random(windowHeight); this.h = random(70, 150); this.oldX = this.x; this.oldY = this.y;
}
Particle.prototype.move = function () { this.oldX = this.x; this.oldY = this.y; this.x += random(-particleStepMax, particleStepMax); this.y += random(-particleStepMax, particleStepMax);
};
Particle.prototype.draw = function () { stroke(this.h, 40, 90, 0.05); line(this.oldX, this.oldY, this.x, this.y);
};
var particles;
var particleStepMax;
var iterations;
function setup() { cursor(HAND); particleStepMax = 5; iterations = 50; initParticles(); createCanvas(windowWidth, windowHeight); colorMode(HSB); background("black");
}
function draw() { for (var i = 0; i < iterations; i++) { particles.forEach(function (p) { p.move(); p.draw(); }); }
}
function initParticles() { particles = []; for (var i = 0; i < 100; i++) { particles.push(new Particle()); }
}
function windowResized() { resizeCanvas(windowWidth, windowHeight); background("black");
}
function mouseClicked() { particleStepMax = random(40); initParticles(); background("black");
}
Moss by Brownian Motion - Script Codes
Moss by Brownian Motion - Script Codes
Home Page Home
Developer Johan Karlsson
Username DonKarlssonSan
Uploaded July 24, 2022
Rating 3
Size 2,792 Kb
Views 50,600
Do you need developer help for Moss by Brownian Motion?

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!

Johan Karlsson (DonKarlssonSan) Script Codes
Create amazing web content with AI!

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!