Ribbons

Developer
Size
2,140 Kb
Views
36,432

How do I make an ribbons?

What is a ribbons? How do you make a ribbons? This script and codes were developed by Ben Matthews on 10 September 2022, Saturday.

Ribbons Previews

Ribbons - Script Codes HTML Codes

<!DOCTYPE html>
<html class="https://github.com/processing/p5.js/releases/download/0.5.6/p5.min.js">
<head> <meta charset="UTF-8"> <title>Ribbons</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <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>

Ribbons - Script Codes CSS Codes

* { margin:0; padding:0; }
html, body { width:100%; height:100%; }
canvas { display:block; }

Ribbons - Script Codes JS Codes

window.addEventListener('resize', resize, false);
var hues = [ 0, 50, 220
];
function Ribbon(){ this.x = random()*width; this.y = random()*height; this.width = random()*20 + 20; this.hue = hues[floor(random()*hues.length)]; this.balance = random()*50 + 50; this.speed = random()*3 + 3; this.angle = floor(random()*8)*45; this.height = 0;
}
Ribbon.prototype.tick = function(){ this.height += this.speed; if (((height*2 - this.height)/height*2) < 0){ this.x = random()*width; this.y = random()*height; this.width = random()*20 + 20; this.hue = hues[floor(random()*hues.length)]; this.balance = random()*50 + 50; this.speed = random()*3 + 3; this.angle = floor(random()*8)*45; this.height = 0; }
}
Ribbon.prototype.render = function(){ translate(this.x, this.y); rotate(this.angle); noStroke(); var alpha = ((height*2 - this.height)/height*2); fill(this.hue, 80, this.balance, alpha); rect(0, 0, this.width, this.height); fill(this.hue, 100, this.balance + 10, alpha); rect(0, 0, this.width/2, this.height); resetMatrix();
}
var ribbons;
function setup(){ angleMode(DEGREES); rectMode(CENTER); colorMode(HSB, 360, 100, 100); createCanvas(); resize(); ribbons = []; for (var i = 0; i < 100; i++){ ribbons.push(new Ribbon()); }
}
function draw(){ background(0); if (ribbons == undefined) return; for (var i = 0; i < ribbons.length; i++){ ribbons[i].tick(); ribbons[i].render(); }
}
function resize(){ resizeCanvas(window.innerWidth, window.innerHeight);
}
Ribbons - Script Codes
Ribbons - Script Codes
Home Page Home
Developer Ben Matthews
Username tsuhre
Uploaded September 10, 2022
Rating 3.5
Size 2,140 Kb
Views 36,432
Do you need developer help for Ribbons?

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!

Ben Matthews (tsuhre) Script Codes
Create amazing SEO 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!