Canvas Click Animation Demo

Developer
Size
1,955 Kb
Views
12,144

How do I make an canvas click animation demo?

Inspired by Material Design. What is a canvas click animation demo? How do you make a canvas click animation demo? This script and codes were developed by Danny C on 17 October 2022, Monday.

Canvas Click Animation Demo Previews

Canvas Click Animation Demo - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Canvas Click Animation Demo</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <h1>Canvas Click Animation Demo</h1>
<canvas id="myCanvas" width="960" height="500"> Your web browser does not support canvas!
</canvas> <script src="js/index.js"></script>
</body>
</html>

Canvas Click Animation Demo - Script Codes CSS Codes

body{ text-align:center; background-color:#e2e2e2;
}
canvas{ top:60px; margin:60px auto 0; background:#f2f2f2;
}

Canvas Click Animation Demo - Script Codes JS Codes

var canvas = document.getElementById('myCanvas');
canvas.addEventListener("mousedown", doMouseDown, false);
if(canvas.getContext){ var ctx = canvas.getContext('2d');
}else{ console.log('canvas not supported.');
}
function doMouseDown(event){
ctx.clearRect(0, 0, 960, 500);
//draw a circle centered at location of click
var circleX = event.clientX - canvas.offsetLeft;
var circleY = event.clientY - canvas.offsetTop;
//alert('circleX: '+ circleX + " circleY: "+ circleY);
ctx.beginPath();
ctx.arc(circleX, circleY, 50, 0, Math.PI*2, true);
ctx.fillStyle = "#000000";
ctx.fill();
}
Canvas Click Animation Demo - Script Codes
Canvas Click Animation Demo - Script Codes
Home Page Home
Developer Danny C
Username tychoBlender
Uploaded October 17, 2022
Rating 3
Size 1,955 Kb
Views 12,144
Do you need developer help for Canvas Click Animation Demo?

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!

Danny C (tychoBlender) Script Codes
Create amazing blog posts 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!