Clapperboard
How do I make an clapperboard?
What is a clapperboard? How do you make a clapperboard? This script and codes were developed by Anwesh Mishra on 08 January 2023, Sunday.
Clapperboard - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Clapperboard</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <canvas id="clapperboard-canvas" width="400px" height="400px">
</canvas> <script src="js/index.js"></script>
</body>
</html>
Clapperboard - Script Codes CSS Codes
#clapperboard-canvas{ border:2px solid black;
}
Clapperboard - Script Codes JS Codes
var canvas = document.getElementById('clapperboard-canvas')
var maxDeg = 20,speed = maxDeg/5,bH = 30
var context = canvas.getContext('2d')
//webgl
var setDimensions = ()=>{ canvas.width = window.innerWidth canvas.height = window.innerHeight
}
setDimensions()
var x = canvas.width/2-100,y = canvas.height/2-100
window.onresize = () => { setDimensions() changeDimensionsOfObject()
}
class BigRectangle { draw() { context.fillStyle = "black" context.fillRect(x,y+2*bH,200,200-2*bH) }
}
class Stripe { constructor(x1,y1,x2,y2,x3,y3,x4,y4) { this.x1 = x1 this.x2 = x2 this.x3 = x3 this.x4 = x4 this.y1 = y1 this.y2 = y2 this.y3 = y3 this.y4 = y4 } draw() { context.fillStyle="white" context.beginPath() context.moveTo(this.x1,this.y1) context.lineTo(this.x2,this.y2) context.lineTo(this.x4,this.y4) context.lineTo(this.x3,this.y3) context.fill() }
}
class Bar { constructor(y,isFixed) { this.y = y this.isFixed = isFixed this.stripes = [] if(!isFixed) { this.deg = 0 this.dir = 1 } var n = 4 var x = 0,y=-bH for(var i=0;i<n;i++) { this.stripes.push(new Stripe(x,y,x+bH,y,x+bH,y+bH,x+2*bH,y+bH)) x+=(3*bH/2+bH/20); } } draw() { context.save() context.translate(x,this.y+bH) if(!this.isFixed) { context.rotate(this.deg*Math.PI/180) } context.fillRect(0,-bH,200,bH) this.stripes.forEach((stripe)=>{ stripe.draw() }) context.restore() if(!this.isFixed) { this.update() } } update() { this.deg-=speed*this.dir if(this.deg<=-maxDeg || this.deg>=0) { this.dir*=-1 } }
}
class Patch { constructor(x,y,size) { this.x = x this.y = y this.size = size console.log("intialized"+this.x) } draw() { context.fillStyle="#212121" context.beginPath() context.moveTo(this.x,this.y) context.lineTo(this.x+this.size/2,this.y) context.lineTo(this.x+this.size,this.y+this.size) context.lineTo(this.x,this.y+this.size) context.fill() console.log("drawn patch"+this.x+","+this.y) context.fillStyle="white" context.beginPath() context.arc(this.x+this.size/10,this.y+this.size/10,this.size/20,0,2*Math.PI) context.fill() context.beginPath() context.arc(this.x+9*this.size/10,this.y+9*this.size/10,this.size/20,0,2*Math.PI) context.fill() context.beginPath() context.arc(this.x+this.size/10,this.y+9*this.size/10,this.size/20,0,2*Math.PI) context.fill() }
}
var bigRectangle = new BigRectangle()
var movableBar = new Bar(y,false)
var fixedBar = new Bar(y+bH,true)
var patch = new Patch(x,y,2*bH)
var changeDimensionsOfObject = ()=>{ x = canvas.width/2-100 y = canvas.height/2-100 movableBar = new Bar(y,false) fixedBar = new Bar(y+bH,true) patch = new Patch(x,y,2*bH)
}
var draw = ()=>{ context.clearRect(0,0,canvas.width,canvas.height) context.fillStyle='#E91E63' context.fillRect(0,0,canvas.width,canvas.height) bigRectangle.draw() movableBar.draw() fixedBar.draw() patch.draw()
}
setInterval(draw,100)
Developer | Anwesh Mishra |
Username | Anwesh43 |
Uploaded | January 08, 2023 |
Rating | 3 |
Size | 2,540 Kb |
Views | 12,144 |
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 |
MovingBall | 2,105 Kb |
Html5CanvasPingPong | 2,033 Kb |
EllipticalSwitch | 2,077 Kb |
SettingButton | 2,255 Kb |
TumblingPins | 2,187 Kb |
Jumping Triangles | 2,350 Kb |
Fractal Spirograph | 2,501 Kb |
Material Boxes Animation | 2,257 Kb |
SeeSaw | 2,195 Kb |
A Pen by Anwesh Mishra | 1,524 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 |
Awesome textarea | Ayoungh | 1,977 Kb |
Spilled Paint | Darrylhuffman | 3,894 Kb |
Wikipedia viewer | Chpecson | 2,865 Kb |
GLSL Hills | Ykob | 6,991 Kb |
Knob rotation | Alemesre | 2,122 Kb |
Content Changer | Cliffpyles | 4,538 Kb |
Ipad Mini Showcase | Hornebom | 10,479 Kb |
Mobile Nav Menu | AliKlein | 4,745 Kb |
A Pen by Jonas Bjork | Jonasbjork | 3,115 Kb |
Loading animation with css | Icebob | 2,947 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!