SettingButton
How do I make an settingbutton?
What is a settingbutton? How do you make a settingbutton? This script and codes were developed by Anwesh Mishra on 08 January 2023, Sunday.
SettingButton - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>SettingButton</title>
</head>
<body> <canvas id="canv" width ="600px" height="600px">
</canvas> <script src="js/index.js"></script>
</body>
</html>
SettingButton - Script Codes JS Codes
const canvas = document.getElementById('canv')
const context = canvas.getContext('2d')
const backgroundColor = "#FF5722"
const coordScales = [{x:1,y:1},{x:2,y:3},{x:3,y:1}]
var coords = []
var settingButtons = []
class SettingButton { constructor(x,y) { this.x = x this.y = y this.r = canvas.height/10 this.angle = 0 this.dir = 0 } draw() { context.save() context.translate(this.x,this.y) context.rotate(this.angle*Math.PI/180) context.fillStyle="#616161" context.beginPath() context.moveTo(this.r,0) for(var deg=0;deg<360;deg+=2) { if(deg%20 == 0) { var firstPoint = this.getPositionInCircle(deg+5,this.r/2) context.lineTo(firstPoint.x,firstPoint.y) var secondPoint = this.getPositionInCircle(deg+15,this.r/2) context.lineTo(secondPoint.x,secondPoint.y) if(time == 0) { console.log(`${this.x},${this.y}`) } deg+=20 } else { var point = this.getPositionInCircle(deg,0) context.lineTo(point.x,point.y) } } context.fill() context.fillStyle = backgroundColor context.beginPath() context.arc(0,0,this.r/2,0,2*Math.PI) context.fill() context.restore() } getPositionInCircle(deg,gap) { return {x:(this.r+gap)*Math.cos(deg*Math.PI/180),y:(this.r+gap)*Math.sin(deg*Math.PI/180)} } update() { this.angle+=this.dir*15 if(this.angle % 90 == 0) { this.dir = 0 } } handleTap(x,y) { if(x>=this.x-this.r && x<=this.x+this.r && y>=this.y-this.r && y<=this.y+this.r) { this.dir = this.dir == 0?1:this.dir } }
}
const initDimensions = ()=>{ canvas.width = window.innerWidth canvas.height = window.innerHeight coords = coordScales.map((coordScale)=>{ return ({x:coordScale.x*canvas.width/4,y:coordScale.y*canvas.height/4}) }) console.log(coords) settingButtons = coords.map((coord)=>new SettingButton(coord.x,coord.y))
}
initDimensions()
window.onresize = () => { initDimensions()
}
var time = 0
const render = () => { context.clearRect(0,0,canvas.width,canvas.height) context.fillStyle = backgroundColor context.fillRect(0,0,canvas.width,canvas.height) settingButtons.forEach((settingButton)=>{ settingButton.draw() if(time%8 == 0) { settingButton.update() } }) time++ window.requestAnimationFrame(render)
}
canvas.onmousedown = (event) => { settingButtons.forEach((settingButton)=>{ settingButton.handleTap(event.offsetX,event.offsetY) })
}
window.requestAnimationFrame(render)
Developer | Anwesh Mishra |
Username | Anwesh43 |
Uploaded | January 08, 2023 |
Rating | 3 |
Size | 2,255 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 |
SeeSaw | 2,195 Kb |
Fractal Spirograph | 2,501 Kb |
A Pen by Anwesh Mishra | 1,524 Kb |
EllipticalSwitch | 2,077 Kb |
Html5CanvasPingPong | 2,033 Kb |
TumblingPins | 2,187 Kb |
MovingBall | 2,105 Kb |
Clapperboard | 2,540 Kb |
Jumping Triangles | 2,350 Kb |
Material Boxes Animation | 2,257 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 |
SVG Basics | HipsterBrown | 1,852 Kb |
Testimonial Fancy tabs responsive | Amit-webdesigner | 3,056 Kb |
Cars going | Netoguimaraes | 1,699 Kb |
Testing Portfolio Page | Sideshowli | 3,395 Kb |
Calculator - codevember 08 - 2016 | Caiocares | 3,260 Kb |
Simple Weather App | Cmwebby | 0 Kb |
Blog Concept - Single Post | Marionebl | 9,603 Kb |
To Do List with Delete | Mattlbrody | 2,068 Kb |
A Pen by Alex Edwards | Exards | 8,218 Kb |
Header Line Issue | Charlie-volpe | 1,768 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!