TumblingPins
How do I make an tumblingpins?
What is a tumblingpins? How do you make a tumblingpins? This script and codes were developed by Anwesh Mishra on 08 January 2023, Sunday.
TumblingPins - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>TumblingPins</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <canvas id="c1" width="1000px" height="600px">
</canvas> <script src="js/index.js"></script>
</body>
</html>
TumblingPins - Script Codes CSS Codes
#c1 { border:1px solid #9E9E9E;
}
TumblingPins - Script Codes JS Codes
var canvas = document.getElementById('c1')
var context = canvas.getContext('2d')
class Pin { constructor(x,size) { this.x = x this.y = canvas.height/2 this.deg = 0 this.dir = 0 this.size = size } stop () { return this.dir == 0 } render() { var size = this.size context.strokeStyle = "#4CAF50" context.save() context.translate(this.x,this.y) context.rotate(this.deg*Math.PI/180) context.beginPath() context.moveTo(0,0) context.lineTo(0,-size) context.stroke() context.fillStyle = "#4CAF50" context.beginPath() context.arc(0,-size-size/18,size/9,0,2*Math.PI) context.fill() context.restore() } startUpdating() { this.dir = 1 } reset() { this.deg = 0 } update() { this.deg+=this.dir*15 if(this.deg == 90) { this.dir = 0 } }
}
var pins = []
var n = 6
var currentIndex = 0
var setDimensions = ()=>{ canvas.width = window.innerWidth/2 canvas.height = window.innerHeight context = canvas.getContext('2d') var gap = (canvas.width)/(n+1),x=gap/2 for(i=0;i<n;i++) { pins.push(new Pin(x,gap)) x+=gap } pins[currentIndex].startUpdating()
}
var reset = ()=> { setTimeout(()=>{ currentIndex = 0 pins.forEach((pin)=>{ pin.reset() }) if(pins.length>0) { pins[currentIndex].startUpdating() } },1000)
}
setDimensions()
setInterval(()=>{ context.clearRect(0,0,canvas.width,canvas.height) context.fillStyle="#FBC02D" context.fillRect(0,0,canvas.width,canvas.height) pins.forEach((pin)=>{ pin.render() pin.update() }) if(pins[currentIndex].stop()) { if(currentIndex < pins.length -1) { currentIndex++ pins[currentIndex].startUpdating() } else { reset() } }
},100)
Developer | Anwesh Mishra |
Username | Anwesh43 |
Uploaded | January 08, 2023 |
Rating | 3 |
Size | 2,187 Kb |
Views | 6,072 |
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 |
Html5CanvasPingPong | 2,033 Kb |
MovingBall | 2,105 Kb |
Jumping Triangles | 2,350 Kb |
Clapperboard | 2,540 Kb |
EllipticalSwitch | 2,077 Kb |
Material Boxes Animation | 2,257 Kb |
SeeSaw | 2,195 Kb |
Fractal Spirograph | 2,501 Kb |
A Pen by Anwesh Mishra | 1,524 Kb |
SettingButton | 2,255 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 |
Expandable Left Side Bar with jQuery animate | Retrofuturistic | 2,483 Kb |
CSS-Flexbox-Demo | Sstiglets | 1,709 Kb |
Border-radius animation | Yukulele | 2,480 Kb |
Canvas Fireworks | Jackrugile | 6,200 Kb |
Form Labels | Bartuc | 2,717 Kb |
Fading gradient button | Insprd | 1,713 Kb |
Video Player Custom Controls | EleftheriaBatsou | 3,665 Kb |
Sort the Knowlege | Eprouver | 3,915 Kb |
Mobile first social buttons with no iframe | Alistairtweedie | 3,158 Kb |
Process Accordion | Devilskitchen | 31,432 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!