A Perfect Orbit

Size
3,411 Kb
Views
4,048

How do I make an a perfect orbit?

What is a a perfect orbit? How do you make a a perfect orbit? This script and codes were developed by Darryl Huffman on 07 January 2023, Saturday.

A Perfect Orbit Previews

A Perfect Orbit - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>A Perfect Orbit</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body>
<canvas id="canvas"></canvas>
<div id="earth"></div> <script src="js/index.js"></script>
</body>
</html>

A Perfect Orbit - Script Codes CSS Codes

#earth{ background-image: url(https://i.imgur.com/yrGdFy7.jpg); background-size: cover; width: 110px; height: 110px; position: absolute; top: 50%; margin-left: -50px; left: 50%; margin-top: -50px; z-index:-999; -webkit-animation-name: spin; -webkit-animation-duration: 90000ms; -webkit-animation-iteration-count: infinite; -webkit-animation-timing-function: linear; -moz-animation-name: spin; -moz-animation-duration: 90000ms; -moz-animation-iteration-count: infinite; -moz-animation-timing-function: linear; -ms-animation-name: spin; -ms-animation-duration:90000ms; -ms-animation-iteration-count: infinite; -ms-animation-timing-function: linear; animation-name: spin; animation-duration: 90000ms; animation-iteration-count: infinite; animation-timing-function: linear;
}
@-ms-keyframes spin { from { -ms-transform: rotate(360deg); } to { -ms-transform: rotate(0deg); }
}
@-moz-keyframes spin { from { -moz-transform: rotate(360deg); } to { -moz-transform: rotate(0deg); }
}
@-webkit-keyframes spin { from { -webkit-transform: rotate(360deg); } to { -webkit-transform: rotate(0deg); }
}
@keyframes spin { from { transform:rotate(360deg); } to { transform:rotate(0deg); }
}
body,html{ margin: 0; padding: 0; overflow-x: hidden; background: #000; min-height: 100%; width: 100%;
}
body:before { z-index:-999; content: '';	position: fixed;	top: 0;	right: 0;	bottom: 0;	left: 0;	background-color:#000;	opacity: .6;
}
canvas#canvas{ z-index:-998; position: relative; height: 90%; width: 90%; top: 5%; left: 5%;
}
*{ position: relative; z-index: 2;
}

A Perfect Orbit - Script Codes JS Codes

window.requestAnimFrame = (function () { return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback) { window.setTimeout(callback, 1000 / 60); };
})();
function Scene() { this.animation = undefined; this.canvas = undefined; this.height = 0; this.width = 0; this.context = undefined; this.paused = false;
}
Scene.prototype = { constructor: Scene, setup: function (canvas, animation, width, height) { this.canvas = canvas; this.animation = animation; this.height = this.canvas.height = height; this.width = this.canvas.width = width; this.context = this.canvas.getContext('2d'); }, animate: function () { if (!this.paused) { requestAnimFrame(this.animate.bind(this)); } this.animation(this); }
};
var scene = new Scene(), particles = [], len = 15000, //15000 height = document.body.offsetHeight, width = document.body.offsetWidth;
function Particle(orbit) { this.x = 0; this.y = 0; this.size = 0; this.depth = 0; this.vy = 0; this.height = 0.05; this.width = 0.05; this.velocity = Math.floor((Math.random() * 24200) + 18500) ; var rands = []; rands.push(Math.random() * 100 + 1); rands.push(Math.random() * 10 + 241); var choice2 = Math.random() * 4; var rands2 = []; rands2.push(Math.random() * 100 + 1); rands2.push(Math.random() * 180 + 211); this.orbit = Math.random() * 5 + 1; this.distance = (rands.reduce(function(p, c) { return p + c; }, 0) / rands.length); this.distance2 = (rands2.reduce(function(p, c) { return p + c; }, 0) / rands2.length); this.increase = Math.PI * 2 / this.width; this.distancefix = this.distance; this.distance2fix = this.distance2; this.increase = Math.PI * 2 / this.width; this.distancefix = this.distance; this.distance2fix = this.distance2; this.bx = Math.random() * 20 + 1; this.by = Math.random() * 20 + 1;
}
Particle.prototype = { constructor: Particle, update: function (width, height) { //////////////////////// loop if (this.y > height) { this.y = 1 - this.size; } if (this.orbit >= 4) { this.x = this.bx + this.distance * Math.cos(this.angle / this.velocity) + window.innerWidth / 2; this.y = this.by + this.distance * Math.sin(this.angle / this.velocity) + window.innerHeight / 2; this.alpha = 93; } else { this.x = this.bx + this.distance2 * Math.cos(this.angle / this.velocity) + window.innerWidth / 2; this.y = this.by + this.distance2 * Math.sin(this.angle / this.velocity) + window.innerHeight / 2; this.alpha = 42; } this.angle += this.increase; }
};
for (var i = 0; i < len; i++) { var particle = new Particle(); particle.x = 0; particle.y = 0; particle.depth = 0.05; particle.size = 0.005; particle.vy = (particle.depth * .25) + 1 / Math.random(); particle.height = 0.05; particle.width = 0.05; particle.orbit = 3; particle.angle = (Math.PI * 2 / particle.width) * Math.floor((Math.random() * window.innerWidth*4) + 10); var choice = Math.random() * 5; var rands = []; rands.push(Math.random() * 100 + 1); rands.push(Math.random() * 10 + 241); var choice2 = Math.random() * 4; var rands2 = []; rands2.push(Math.random() * 100 + 1); rands2.push(Math.random() * 180 + 211); particle.orbit = Math.random() * 5 + 1; particle.distance = (rands.reduce(function(p, c) { return p + c; }, 0) / rands.length); particle.distance2 = (rands2.reduce(function(p, c) { return p + c; }, 0) / rands2.length); particle.increase = Math.PI * 2 / particle.width; particle.distancefix = particle.distance; particle.distance2fix = particle.distance2;
if(particle.orbit <= 2){ particle.velocity = Math.floor((Math.random() * 32200) + 24500) * particle.orbit; } else if(particle.orbit <= 4){ particle.velocity = Math.floor((Math.random() * 32200) + 24500) * (particle.orbit / 2); } else{ particle.velocity = Math.floor((Math.random() * 32200) + 24500); } particles.push(particle);
}
function falling_particles() { var idata = this.context.createImageData(this.width, this.height); for (var i = 0, l = particles.length; i < l; i++) { // thanks Loktar ;) var particle = particles[i]; for (var w = 0; w < particle.size; w++) { for (var h = 0; h < particle.size; h++) { var pData = (~~(particle.x + w) + (~~(particle.y + h) * this.width)) * 4; idata.data[pData] = 255; idata.data[pData + 1] = 255; idata.data[pData + 2] = 255; idata.data[pData + 3] = particle.alpha; } } particle.update(this.width, this.height); } this.context.putImageData(idata, 0, 0);
}
scene.setup(document.getElementById('canvas'), falling_particles, width, height, !0);
scene.animate();
window.onresize = function () { height = scene.height = scene.canvas.height = window.innerHeight; width = scene.width = scene.canvas.width = window.innerWidth;
};
window.onload = function () { height = scene.height = scene.canvas.height = window.innerHeight; width = scene.width = scene.canvas.width = window.innerWidth;
};
A Perfect Orbit - Script Codes
A Perfect Orbit - Script Codes
Home Page Home
Developer Darryl Huffman
Username darrylhuffman
Uploaded January 07, 2023
Rating 4
Size 3,411 Kb
Views 4,048
Do you need developer help for A Perfect Orbit?

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!

Darryl Huffman (darrylhuffman) Script Codes
Create amazing marketing copy 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!