Circles
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 - 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);
}
Developer | Pogany |
Username | giaco |
Uploaded | November 09, 2022 |
Rating | 3 |
Size | 2,621 Kb |
Views | 10,120 |
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 |
Basket | 2,297 Kb |
Tiles nr.2 | 2,030 Kb |
Matrix Falling Code | 52,476 Kb |
Out of the blue | 2,537 Kb |
Swim Smooth | 2,897 Kb |
Mountains | 2,389 Kb |
Tiles | 2,018 Kb |
Helianthus | 1,995 Kb |
Fuzzies | 2,338 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 |
Getting Started | Viblast | 1,500 Kb |
Twitch Live Channels | Inkblotty | 4,956 Kb |
Simple DevTools | Deegill | 2,511 Kb |
FCC - Tribute Page | Cmwebby | 0 Kb |
CSS3 keyframe onload animation. | Samueljseay | 1,706 Kb |
FontAwesome icons with animation | Nicotinell | 2,083 Kb |
Shape Outside - Polygon | Stacy | 3,954 Kb |
Social.svg.min | Larsenwork | 13,849 Kb |
Price Comparison Table | Orrinward | 3,459 Kb |
Popup Modal | Aldlevine | 3,696 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!