Gears
How do I make an gears?
It's a cool animation... My Website. What is a gears? How do you make a gears? This script and codes were developed by Ryan Allred on 12 September 2022, Monday.
Gears - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Gears</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/normalize/5.0.0/normalize.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! */ body { background: #444; text-align: center;
}
#gears { -webkit-filter: drop-shadow(0px 0px 2px black); // future: -moz-filter: drop-shadow(0px 0px 2px black);
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <canvas id="gears"></canvas>
<!--Sorry, it's not retina--> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Gears - Script Codes CSS Codes
body { background: #444; text-align: center;
}
#gears { -webkit-filter: drop-shadow(0px 0px 2px black); // future: -moz-filter: drop-shadow(0px 0px 2px black);
}
Gears - 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(){ $(function(){ gears.setup(); }); var global = {}; var gears = { setup:function(){ this.canvas = $('#gears')[0]; this.canvas.width = 480; this.canvas.height = 480; this.cxt = this.canvas.getContext('2d'); global.whiteGradient = this.cxt.createLinearGradient(0,0,0,this.canvas.height); global.whiteGradient.addColorStop("0","white"); global.whiteGradient.addColorStop("1","rgba(255,255,255,.5)"); global.toHue = Math.round(Math.random()*9)*20; global.hue = global.toHue; global.colorGradient = this.cxt.createLinearGradient(0,0,0,this.canvas.height); global.colorGradient.addColorStop("0","hsla("+global.hue+",100%,30%,1)"); global.colorGradient.addColorStop("0.5","hsla("+global.hue+",100%,50%,1)"); global.colorGradient.addColorStop("1","hsla("+global.hue+",100%,10%,1)"); this.cxt.lineWidth = 16; this.gears = [gear(128,this.canvas), gear(96,this.canvas), gear(64,this.canvas), gear(32,this.canvas)]; this.draw(); window.setTimeout(function changeHue(){ global.toHue = Math.round(Math.random()*9)*20; window.setTimeout(changeHue, Math.round(Math.random()*1000+10000)); }, Math.round(Math.random()*1000+10000)); }, draw:function(){ this.cxt.clearRect(0,0,this.canvas.width,this.canvas.height); this.cxt.lineWidth = 16; for(var i = 0, size = this.gears.length; i<size; ++i) { this.gears[i].draw(this.cxt, this.canvas); } this.adjust2Hue(); window.requestAnimFrame(function(){ gears.draw(); }); }, adjust2Hue:function(){ if (global.hue === global.toHue) return; if (Math.abs(global.hue - global.toHue) > Math.abs(global.hue - global.toHue + 360)) global.toHue += 360 if (Math.abs(global.hue-global.toHue) < 1.) { global.hue = global.toHue; } else { global.hue += (global.toHue-global.hue)/100; global.colorGradient = this.cxt.createLinearGradient(0,0,0,this.canvas.height); global.colorGradient.addColorStop("0","hsla("+global.hue+",100%,30%,1)"); global.colorGradient.addColorStop("0.5","hsla("+global.hue+",100%,50%,.8)"); global.colorGradient.addColorStop("1","hsla("+global.hue+",100%,50%,0)"); } } }; var gear = function(radius,canvas){ return { init:function(){ var cxt = canvas.getContext('2d'); this.radius = radius; this.angle=Math.random() * Math.PI * 2; this.newSpeedValue = 0; this.newSpeed(); this.speed = Math.round(Math.random())==1?-0.1:0.1; this.timerInit = 50; this.timer = this.timerInit; this.last = this.radius == 128; this.bars = []; this.numBars = 1; do { this.numBars++; if (this.numBars > 5) break; } while(Math.round(Math.random()) == 0 || this.numBars < 2); this.newBars = []; this.newBars.length = this.numBars; this.makeNewBars(); for(var i = 0; i < this.numBars-1; i++){ this.bars[i] = this.newBars[i]; } this.hue = this.toHue; if (this.last) { this.newSpeedValue = .01; this.newBars = this.bars = [Math.PI]; } return this; }, draw:function(cxt, canvas){ if (!this.last) { this.timer -=1; if (this.timer == 0) { this.timer = this.timerInit; this.newSpeed(); this.makeNewBars(); } } if (this.last) { this.gradient = global.whiteGradient; this.newSpeedValue = .01; } else { this.gradient = global.colorGradient; } this.adjust(); this.angle+=this.speed; var sum = 0; cxt.save(); for(var i = 0; i < this.numBars; i++) { cxt.beginPath(); cxt.strokeStyle = this.gradient; cxt.arc( canvas.width/2, canvas.height/2, this.radius, this.angle - sum - this.bars[i]*.9, this.angle - sum - this.bars[i]*.1 ); cxt.stroke(); sum += this.bars[i]; } cxt.restore(); }, newSpeed:function(){ var reverse = true; if (!this.last) { reverse = !!Math.round(Math.random()); } this.newSpeedValue = (reverse?-1:1) * Math.random()/10 + .01; }, adjust:function(){ if (Math.abs(this.speed-this.newSpeedValue) < .001) { this.speed = this.newSpeedValue; } else { this.speed += (this.newSpeedValue-this.speed)/10; } for(var i = 0; i < this.numBars; i++) { if (Math.abs(this.bars[i]-this.newBars[i]) < .001) { this.bars[i] = this.newBars[i]; } else { this.bars[i] += (this.newBars[i]-this.bars[i])/100; } } }, makeNewBars:function(){ var remaining = Math.PI*2; for(var i = 0; i < this.numBars-1; i++){ var width = Math.random()*remaining; remaining -= width; this.newBars[i] = width; } this.newBars[this.numBars-1] = remaining; } }.init(); }
})()

Developer | Ryan Allred |
Username | Synvox |
Uploaded | September 12, 2022 |
Rating | 4 |
Size | 3,278 Kb |
Views | 26,299 |
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 |
Categories Overlay | 5,589 Kb |
Shell Chart | 4,472 Kb |
Demonstration purposes | 14,907 Kb |
Radar Chart jQuery Plugin | 3,790 Kb |
Win as much as you can | 11,079 Kb |
Exploring new CSS3 Units | 5,193 Kb |
Window Menu | 5,352 Kb |
Domify Challenge | 2,434 Kb |
Generated Wave | 3,800 Kb |
Proof of Concept | 5,064 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 |
Sample Profile Screen | OurDailyBread | 5,375 Kb |
Table border-collapse property | Maxds | 1,672 Kb |
Sort the Knowlege | Eprouver | 3,915 Kb |
Personal Website Redesign v2.0 | DevItWithDavid | 5,168 Kb |
Price table | Serluk | 5,928 Kb |
Drop Cap | Gsaiki | 1,571 Kb |
BlueBox Fork | Huskynation | 12,675 Kb |
No Vacancy 404 CSS Only | Sethkontny | 0 Kb |
Filtering with shuffle.js | Deyand | 2,712 Kb |
Parallax-ish Sliding Content | Jdsteinbach | 2,748 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!