Sand Traveler
How do I make an sand traveler?
An attempted recreation of Jared Tarbell's "Sand Traveler"See: http://www.complexification.net/gallery/machines/sandTraveler/index.php. What is a sand traveler? How do you make a sand traveler? This script and codes were developed by Ben Matthews on 10 September 2022, Saturday.
Sand Traveler - Script Codes HTML Codes
<!DOCTYPE html>
<html class="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.7/p5.min.js">
<head> <meta charset="UTF-8"> <title>Sand Traveler</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <button id="generate" onclick="createAttractors()">generate</button> <script src='https://github.com/processing/p5.js/releases/download/0.5.6/p5.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Sand Traveler - Script Codes CSS Codes
* { margin:0; padding:0; }
html, body { width:100%; height:100%; }
canvas { display:block; }
#generate { position: absolute; top: 10px; left: 10px;
}
Sand Traveler - Script Codes JS Codes
window.addEventListener('resize', resize, false);
var numAttractors = 500;
var numParticles = 1;
var attractors = [];
var speed = .5;
function Attractor(){ this.x = floor(random()*width); this.y = floor(random()*height); this.xMove = random()*speed; this.yMove = random()*speed; this.moveTo = undefined; var hue = random()*15 + 25; var sat = random()*100; var bal = random()*100; this.color = color(hue, sat, bal, 20);
}
Attractor.prototype.render = function(){ if (this.moveTo == undefined) return; var xDiff = this.moveTo.x - this.x; var yDiff = this.moveTo.y - this.y; var angle = atan2(yDiff, xDiff); this.x += cos(angle)*speed; this.y += sin(angle)*speed; var radius = sqrt(xDiff*xDiff + yDiff*yDiff)/5; // fill(this.color); // ellipse(this.x, this.y, radius); stroke(this.color); for (var i = 0; i < numParticles; i++){ var randA = random()*2*PI - PI; var randR = random()*radius; var x = cos(randA)*randR + this.x; var y = sin(randA)*randR + this.y; point(x, y) }
}
function setup(){ createCanvas(); colorMode(HSB, 360, 100, 100, 100); angleMode(DEGREES); resize(); createAttractors();
}
function createAttractors(){ background(0); attractors = []; for (var i = 0; i < numAttractors; i++){ attractors.push(new Attractor()); } for (var i = 0; i < numAttractors; i++){ var a = attractors[i]; while(a.moveTo == undefined){ var index = floor(random()*numAttractors); var cand = attractors[index]; if (!(cand.x == a.x && cand.y == a.y)){ a.moveTo = cand; } } }
}
function draw(){ noStroke(); for (var n = 0; n < 10; n++){ for (var i = 0; i < attractors.length; i++){ attractors[i].render(); } }
}
function resize(){ resizeCanvas(window.innerWidth, window.innerHeight);
}
Developer | Ben Matthews |
Username | tsuhre |
Uploaded | September 10, 2022 |
Rating | 3 |
Size | 2,467 Kb |
Views | 20,240 |
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 |
Tree Generator V2 | 5,891 Kb |
Random Chess Game | 3,330 Kb |
GameBunny1 | 2,270 Kb |
Snow | 2,078 Kb |
Flame Animation Test 2 | 2,937 Kb |
Maze Runners | 3,628 Kb |
Ellipses | 2,312 Kb |
Fractal Fun | 3,965 Kb |
Ribbons | 2,140 Kb |
Conways Fireworks | 2,960 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 |
Material design - button rainbow circle | Kunukn | 3,652 Kb |
IE flex collapse bug fix | Rowno | 2,678 Kb |
Revolving Text Landing Page Trial | TimRuby | 2,976 Kb |
Sticky div | Kaslab | 2,225 Kb |
Pure CSS read more toggle | Idered | 2,344 Kb |
Fun animations with CSS3 | Minimalmonkey | 2,360 Kb |
A form arranged using automatic placement. | Vikasford | 2,103 Kb |
Sencha Touch 2.3.1 Basic Grid Example | Trozdol | 2,770 Kb |
Flexbox slider | Rendro | 3,459 Kb |
Responsive Minimal Blog Layout | Hackthevoid | 5,261 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!