Circles

Developer
Size
2,621 Kb
Views
10,120

How do I make an circles?

What is a circles? How do you make a circles? This script and codes were developed by Pogany on 09 November 2022, Wednesday.

Circles Previews

Circles - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>circles</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <canvas id="canvas">http://www.colourlovers.com/palette/482774/dream_magnet</canvas> <script src="js/index.js"></script>
</body>
</html>

Circles - Script Codes CSS Codes

body { background-color: #343838;
}
canvas { display: block; margin: 0 auto; margin: calc(50vh - 250px) auto 0; background-color: #343838;
}

Circles - Script Codes JS Codes

var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
var cw = canvas.width = 500, cx = cw / 2;
var ch = canvas.height = 500, cy = ch / 2;
var R = 150;
var rad = Math.PI / 180;
var frames = 0;
ctx.strokeStyle = "#343838";
ctx.lineWidth = .5;
var colors = ["#005F6B","#008C9E","#00B4CC","#00DFFC"];
particles = [];
function Particle() { this.R = ~~(Math.random() * R + 1); this.a = ~~(Math.random() * 360) * rad; this.x = cx + this.R * Math.cos(this.a); this.y = cy + this.R * Math.sin(this.a); this.color = colors[~~(Math.random() * colors.length)]; this.r = 1; this.v = ~~(Math.random() * 20 + 5)/25;
}
Particle.prototype.draw = function() { ctx.beginPath(); ctx.fillStyle = this.color; ctx.arc(this.x, this.y, this.r, 0, 2 * Math.PI); ctx.fill(); ctx.stroke()
} var particle = new Particle(); particle.draw(); particles.push(particle);
function testCollisionWall(p){ var dx = cx - p.x; var dy = cy - p.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist + p.r >= R) { return true; }
}
function testCollisionParticles(p1, p2) { var dx = p2.x - p1.x; var dy = p2.y - p1.y; var dist = Math.sqrt(dx * dx + dy * dy); if (p1.r + p2.r + 2*ctx.lineWidth >= dist) { return true; }
}
function Draw() { elId = window.requestAnimationFrame(Draw); ctx.clearRect(0, 0, cw, ch); //if (frames % 10 == 0) { var particle = new Particle(); flag = false for (var i = 0; i < particles.length; i++) { if (testCollisionParticles(particles[i], particle)) { flag = true; break; } } if (flag == false) particles.push(particle); //}
for (var i = 0; i < particles.length; i++) { if(testCollisionWall(particles[i])){particles[i].v = 0;} for (var j = i + 1; j < particles.length; j++) { if (testCollisionParticles(particles[i], particles[j])) { particles[i].v = 0; particles[j].v = 0; } } particles[i].r += particles[i].v; particles[i].draw();
}
frames++;
}
elId = window.requestAnimationFrame(Draw);
function randomIntFromInterval(mn, mx) { return ~~(Math.random() * (mx - mn + 1) + mn);
}
Circles - Script Codes
Circles - Script Codes
Home Page Home
Developer Pogany
Username giaco
Uploaded November 09, 2022
Rating 3
Size 2,621 Kb
Views 10,120
Do you need developer help for Circles?

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!

Pogany (giaco) Script Codes
Name
Basket
Tiles nr.2
Matrix Falling Code
Out of the blue
Swim Smooth
Mountains
Tiles
Helianthus
Fuzzies
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!