Clapperboard

Developer
Size
2,540 Kb
Views
12,144

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 Previews

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)
Clapperboard - Script Codes
Clapperboard - Script Codes
Home Page Home
Developer Anwesh Mishra
Username Anwesh43
Uploaded January 08, 2023
Rating 3
Size 2,540 Kb
Views 12,144
Do you need developer help for Clapperboard?

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!

Anwesh Mishra (Anwesh43) 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!