Spiky Bubbles

Developer
Size
2,485 Kb
Views
20,240

How do I make an spiky bubbles?

You can change the numbers to produce different results. Change the circle delta to alter the jaggedness.. What is a spiky bubbles? How do you make a spiky bubbles? This script and codes were developed by David Hartley on 18 November 2022, Friday.

Spiky Bubbles Previews

Spiky Bubbles - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Spiky Bubbles</title> <script src="https://s.codepen.io/assets/libs/modernizr.js" type="text/javascript"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ html, body { width: 100%; height: 100%; overflow: hidden;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <canvas id="canvas"></canvas> <script src="js/index.js"></script>
</body>
</html>

Spiky Bubbles - Script Codes CSS Codes

html, body { width: 100%; height: 100%; overflow: hidden;
}

Spiky Bubbles - Script Codes JS Codes

(function() { function Circle(config) { this.x = config.x || 0; this.y = config.y || 0; this.radius = config.radius || 50; this.numPoints = this.radius * 4; this.delta = this.radius / 1.5; this.points = this.getPoints(); this.colour = this.getColour(); } Circle.prototype = { getPoints: function() { var points = []; var x, y; for (var i=0; i<this.numPoints; i++) { x = (Math.random() * this.delta) - (this.delta / 2); y = (Math.random() * this.delta) - (this.delta / 2); points[i] = {x: x, y: y}; } return points; }, getColour: function() { var r = Math.floor(Math.random() * 255); var g = Math.floor(Math.random() * 255); var b = Math.floor(Math.random() * 255); var a = (Math.random() * 0.3) + 0.1; return "rgba(" + r + "," + g + "," + b + "," + a + ")"; }, draw: function(ctx) { ctx.save(); ctx.lineWidth = Math.round(this.radius / 50); ctx.strokeStyle = this.colour; ctx.fillStyle = this.colour; ctx.beginPath(); var progress, x, y; x = this.x + (this.radius + this.points[0].x) * Math.cos(0); y = this.y + (this.radius + this.points[0].y) * Math.sin(0); ctx.moveTo(x, y); for (var i=1; i<this.numPoints; i++) { progress = 2 * Math.PI / this.numPoints * i; x = this.x + (this.radius + this.points[i].x) * Math.cos(progress); y = this.y + (this.radius + this.points[i].y) * Math.sin(progress); ctx.lineTo(x, y); } ctx.fill(); //ctx.stroke(); ctx.closePath(); ctx.restore(); } }; window.Circle = Circle;
})();
var can = document.getElementById("canvas");
can.width = window.innerWidth;
can.height = window.innerHeight;
var ctx = can.getContext("2d");
var NUMBER = 2000;
for (var i=0; i<NUMBER; i++) { var circle = new Circle({ x: Math.random() * can.width, y: Math.random() * can.height, radius: Math.round(Math.random() * (Math.min(can.width, can.height) / 10)) }); circle.draw(ctx);
}
Spiky Bubbles - Script Codes
Spiky Bubbles - Script Codes
Home Page Home
Developer David Hartley
Username davidhartley
Uploaded November 18, 2022
Rating 3
Size 2,485 Kb
Views 20,240
Do you need developer help for Spiky Bubbles?

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!

David Hartley (davidhartley) Script Codes
Create amazing sales emails 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!