Cash by Brownian Motion

Size
3,530 Kb
Views
46,552

How do I make an cash by brownian motion?

This is how it works:. What is a cash by brownian motion? How do you make a cash by brownian motion? This script and codes were developed by Johan Karlsson on 24 July 2022, Sunday.

Cash by Brownian Motion Previews

Cash by Brownian Motion - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Cash 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.7/p5.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.7/addons/p5.dom.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Cash by Brownian Motion - Script Codes CSS Codes

html, body { margin: 0;
}
canvas { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); display: block;
}
p { font-size: 10px; position: absolute; z-index: 10; left: 20px;
}

Cash by Brownian Motion - Script Codes JS Codes

"use strict";
/* Johan Karlsson (DonKarlssonSan)
*/
function Particle() { this.x = random(w); this.y = random(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 nrOfParticles;
var iterations;
var tick;
var theImage;
var px;
var w;
var h;
var p;
function preload() { theImage = loadImage("https://s3-us-west-2.amazonaws.com/s.cdpn.io/254249/johnny%20cash%20resize.png");
}
function setup() { cursor(HAND); tick = 0; iterations = 50; nrOfParticles = 300; w = theImage.width; h = theImage.height; createCanvas(w, h); reset(); stroke(0, 5); p = createP('0');
}
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 m = (px[off] + px[off + 1] + px[off + 2]) / 3; var stepSize = map(m, 0, 255, 2, 30); p.move(stepSize); p.draw(); }); tick += 1; } p.html(tick);
}
function initParticles() { particles = []; for (var i = 0; i < nrOfParticles; i++) { particles.push(new Particle()); }
}
function initImage() { image(theImage, 0, 0); var img = get(0, 0, w, h); img.loadPixels(); px = img.pixels; background(255);
}
function reset() { tick = 0; initParticles(); clear(); initImage();
}
function mouseClicked() { reset();
}
Cash by Brownian Motion - Script Codes
Cash by Brownian Motion - Script Codes
Home Page Home
Developer Johan Karlsson
Username DonKarlssonSan
Uploaded July 24, 2022
Rating 3
Size 3,530 Kb
Views 46,552
Do you need developer help for Cash 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 blog posts 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!