P5.js Tail

Developer
Size
1,745 Kb
Views
40,480

How do I make an p5.js tail?

What is a p5.js tail? How do you make a p5.js tail? This script and codes were developed by Wenting Zhang on 07 November 2022, Monday.

P5.js Tail Previews

P5.js Tail - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>p5.js Tail</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">
</head>
<body> <script src='http://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.2/p5.js'></script> <script src="js/index.js"></script>
</body>
</html>

P5.js Tail - Script Codes JS Codes

var myTail;
function setup() { ellipseMode(CENTER); createCanvas(1440, 768); background(0); myTail = new Tail(7);
}
function draw() { myTail.update(); background("rgba(0,0,0,0.2)"); myTail.draw();
}
function Tail(n) { this.n = n; this.positions = []; for (var i = 0; i < this.n; i++) { var newPos = createVector(0, 0); append(this.positions, newPos); }
}
Tail.prototype.update = function(){ this.positions[0] = createVector(mouseX, mouseY); for(var i=1; i<this.n; i++){ this.positions[i] = p5.Vector.lerp(this.positions[i], this.positions[i-1], 0.1); }
}
Tail.prototype.draw = function(){ noStroke(); randomSeed(23); for (var i = 0; i < this.n; i++) { colorMode(HSB, 1, 1, 1); fill(random(), 0.6, 0.9); ellipse(this.positions[i].x, this.positions[i].y, 20, 20); }
}
P5.js Tail - Script Codes
P5.js Tail - Script Codes
Home Page Home
Developer Wenting Zhang
Username wentin
Uploaded November 07, 2022
Rating 3
Size 1,745 Kb
Views 40,480
Do you need developer help for P5.js Tail?

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!

Wenting Zhang (wentin) 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!