Sphere
How do I make an sphere?
What is a sphere? How do you make a sphere? This script and codes were developed by Dmitriy Karpov on 27 August 2022, Saturday.
Sphere - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>sphere</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <canvas></canvas> <script src="js/index.js"></script>
</body>
</html>
Sphere - Script Codes CSS Codes
body, html {height: 100%; width: 100%;}
body {margin: 0;}
canvas {display: block;}
body { background-color: #111; background-image: -webkit-radial-gradient(circle cover, #222, #000); background-image: -moz-radial-gradient(circle cover, #222, #000); background-image: radial-gradient(circle cover, #222, #000);
}
Sphere - Script Codes JS Codes
var D = { data: new Array(15), points: 200, radius: 80, speed: 0.05, circle: 65, Fill: function(x, y) { D.ctx.fillStyle = 'rgba(255,255,255,0.2)'; D.ctx.fillRect(D.canvas.width / 2 + x, D.canvas.height / 2 - y, 1, 1); }, Factor: function(i) { return (i - D.data.length / 2) * 2 * D.radius / D.data.length; }, Increase: function(i) { D.data[i] += D.speed; if (D.data[i] > D.data.length) { D.data[i] = 0; } }, Add: function(i, e) { var a1 = i * Math.PI / D.points - Math.PI / 2; var x1 = Math.cos(a1) * e.x; var y1 = Math.sin(a1) * D.radius; var a2 = i * Math.PI / D.points; var x2 = Math.cos(a2) * D.radius; var y2 = Math.sin(a2) * e.y; D.Fill(x1, y1); D.Fill(x2, y2); }, Sphere: function() { for (var i = 0; i < D.data.length; i++) { var factor = { x: D.Factor(D.data[i]), y: D.Factor(i) }; for (var j = 0; j < D.points; j++) { D.Add(j, factor); } D.Increase(i); } }, Clear: function() { D.ctx.clearRect(0, 0, D.canvas.width, D.canvas.height); }, Circle: function() { D.ctx.beginPath(); D.ctx.arc(D.canvas.width / 2, D.canvas.height / 2, D.circle, 0, 2 * Math.PI, false); D.ctx.fillStyle = D.gradient; D.ctx.fill(); }, Stroke: function() { D.ctx.beginPath(); D.ctx.arc(D.canvas.width / 2, D.canvas.height / 2, D.radius, 0, 2 * Math.PI, false); D.ctx.strokeStyle = 'rgba(255,255,255,0.4)'; D.ctx.stroke(); }, Update: function() { D.Clear(); D.Stroke(); D.Circle(); D.Sphere(); }, Draw: function() { D.Update(); requestAnimationFrame(D.Draw, D.canvas); }, Gradient: function() { var x1 = D.canvas.width / 2 - D.circle / 2; var y1 = D.canvas.height / 2 + D.circle / 2; var x2 = D.canvas.width / 2 + D.circle / 2; var y2 = D.canvas.height/2 - D.circle / 2; D.gradient = D.ctx.createLinearGradient(x1, y1, x2, y2); D.gradient.addColorStop(0,'rgba(200,200,200,1)'); D.gradient.addColorStop(1,'rgba(70,70,70,1)'); }, Set: function() { for (var i = 0; i < D.data.length; i++) { D.data[i] = i; } D.Gradient(); }, Size: function() { D.canvas.width = window.innerWidth; D.canvas.height = window.innerHeight; }, Run: function() { D.canvas = document.querySelector('canvas'); D.ctx = D.canvas.getContext('2d'); window.addEventListener('resize', D.Size, false); D.Size(); }, Init: function() { D.Run(); D.Set(); D.Draw(); }
};
D.Init();
Developer | Dmitriy Karpov |
Username | karpovsystems |
Uploaded | August 27, 2022 |
Rating | 4.5 |
Size | 2,432 Kb |
Views | 54,648 |
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 |
Curve Bezier | 3,261 Kb |
CSS 3D Panorama | 3,478 Kb |
Gradients | 2,394 Kb |
Icosahedron | 4,053 Kb |
Spin | 4,269 Kb |
Javascript Pagination | 6,333 Kb |
Metro style icons | 3,691 Kb |
CSS3 text transitions | 2,569 Kb |
Larvaes | 2,686 Kb |
Eye of Sauron | 3,085 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 |
Drop Cap | Gsaiki | 1,571 Kb |
Freecodecamp - Tribute Page | Samoht513 | 3,583 Kb |
Pattern lab logo | TimPietrusky | 3,666 Kb |
Mapbox Directions with geolocation tracking | Pollardld | 5,827 Kb |
Social.svg.min | Larsenwork | 13,849 Kb |
Drag n Drop | Martin42 | 2,594 Kb |
Hello People | Danburrows | 2,365 Kb |
Flexbox Test | Icutpeople | 2,486 Kb |
Main page display | BarryKe | 4,562 Kb |
C.Rowe Button | Brownerd | 2,473 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!