HTML5 Canvas Progress Bar

Developer
Size
2,827 Kb
Views
95,128

How do I make an html5 canvas progress bar?

Editable HTML5 Canvas progress bar that can be toggled vertically or horizontally. Handles overflowing input and always lines up perfectly.. What is a html5 canvas progress bar? How do you make a html5 canvas progress bar? This script and codes were developed by Ash Blue on 18 July 2022, Monday.

HTML5 Canvas Progress Bar Previews

HTML5 Canvas Progress Bar - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>HTML5 Canvas Progress Bar</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ h1 { font-size: 20px; margin: 5px 5px 10px;
}
input[type="number"], li { display: block; margin-bottom: 10px;
}
form { margin: 5px;
}
canvas { padding: 20px;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <h1>Canvas Progress Bar Test</h1>
<form> <ul> <li> <input type="radio" name="direction" id="vertical" value="vertical" checked /> <label for="vertical">Vertical</label> <input type="radio" name="direction" id="horizontal" value="horizontal" /> <label for="horizontal">Horizontal</label> </li> <li> <label for="width">Width</label> <input type="number" id="width" value="20" /> </li> <li> <label for="height">Height</label> <input id="height" type="number" value="200" /> </li> <li> <label for="max">Max Value</label> <input id="max" type="number" value="100" /> </li> <li> <label for="val">Value</label> <input id="val" type="number" value="20" /> </li> <li> <input id="submit" type="submit" /> </li> </ul>
</form>
<canvas id="canvas" width="500" height="500"><canvas> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

HTML5 Canvas Progress Bar - Script Codes CSS Codes

h1 { font-size: 20px; margin: 5px 5px 10px;
}
input[type="number"], li { display: block; margin-bottom: 10px;
}
form { margin: 5px;
}
canvas { padding: 20px;
}

HTML5 Canvas Progress Bar - Script Codes JS Codes

var canvas = document.getElementById('canvas'), ctx = canvas.getContext('2d');
function drawScrollbar () { var width = parseInt($('#width').val()), height = parseInt($('#height').val()), max = parseInt($('#max').val()), val = Math.min(Math.max(parseInt(parseInt($('#val').val())), 0), max), direction = $('input[name="direction"]:checked').val(); // Draw the background ctx.fillStyle = '#000'; ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.fillRect(0, 0, width, height); // Draw the fill ctx.fillStyle = '#777'; var fillVal = Math.min(Math.max(val / max, 0), 1); if (direction === 'vertical') { ctx.fillRect(0, 0, width, fillVal * height); } else { ctx.fillRect(0, 0, fillVal * width, height); }
}
drawScrollbar();
$('#submit').click(function (e) { e.preventDefault(); drawScrollbar();
});
HTML5 Canvas Progress Bar - Script Codes
HTML5 Canvas Progress Bar - Script Codes
Home Page Home
Developer Ash Blue
Username ashblue
Uploaded July 18, 2022
Rating 3
Size 2,827 Kb
Views 95,128
Do you need developer help for HTML5 Canvas Progress Bar?

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!

Ash Blue (ashblue) Script Codes
Create amazing Facebook ads 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!