Radial Progress with SVG
How do I make an radial progress with svg?
An svg-based radial progress bar. One benefit of this approach: the center is transparent. This renders only the bar and the track.. What is a radial progress with svg? How do you make a radial progress with svg? This script and codes were developed by Jon Beebe on 23 January 2023, Monday.
Radial Progress with SVG - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Radial Progress with SVG</title> <script src="https://s.codepen.io/assets/libs/modernizr.js" type="text/javascript"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.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! */ html, body { background: #333; background-image: url("https://dl.dropboxusercontent.com/u/14898/Photos/NSTexturedFullScreenBackgroundColor.png"); width: 100%; height: 100%;
}
.progress-radial { position: relative; display: block; margin-left: 50%; transform: translate(-50%, 50%);
}
.progress-radial-track { fill: #247fd8;
}
.progress-radial-bar { fill: white;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <svg class="progress-radial" width="100px" height="100px" viewBox="0 0 100 100" shape-rendering="geometricPrecision"> <defs> <!-- In production make sure the mask id is discrete if you plan on using multiple instances on one page --> <mask id="circle_mask" x="0" y="0" width="100" height="100" maskUnits="userSpaceOnUse"> <!-- The outer shape hides everything outside of the circle This is necessary because the path used to create the bar does not perfectly match the shape of a circle. We render the path larger than needed and mask it's edges to create a perfect circle. --> <circle cx="50" cy="50" r="51" stroke-width="0" fill="black" opacity="1"/> <!-- The middle shape defines the visible area --> <circle cx="50" cy="50" r="50" stroke-width="0" fill="white" opacity="1"/> <!-- The inner shape creates the hole in the center. The value `r` defines the radius of the hole. --> <circle class="progress-radial-mask-inner" cx="50" cy="50" r="40" stroke-width="0" fill="black" opacity="1"/> </mask> </defs> <g mask="url(#circle_mask)"> <circle class="progress-radial-track" cx="50" cy="50" r="50" stroke-width="0" opacity="1"/> <path class="progress-radial-bar" transform="translate(50, 50)" d="M 0 0"> </path> </g>
</svg> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Radial Progress with SVG - Script Codes CSS Codes
html, body { background: #333; background-image: url("https://dl.dropboxusercontent.com/u/14898/Photos/NSTexturedFullScreenBackgroundColor.png"); width: 100%; height: 100%;
}
.progress-radial { position: relative; display: block; margin-left: 50%; transform: translate(-50%, 50%);
}
.progress-radial-track { fill: #247fd8;
}
.progress-radial-bar { fill: white;
}
Radial Progress with SVG - Script Codes JS Codes
var clamp = function (n, min, max) { return Math.max(min, Math.min(max, n));
};
var drawProgress = function(percent){ if(isNaN(percent)) { return; } percent = clamp(parseFloat(percent), 0, 1); // 360 loops back to 0, so keep it within 0 to < 360 var angle = clamp(percent * 360, 0, 359.99999); var paddedRadius = 50 + 1; var radians = (angle * Math.PI / 180); var x = Math.sin(radians) * paddedRadius; var y = Math.cos(radians) * - paddedRadius; var mid = (angle > 180) ? 1 : 0; var pathData = 'M 0 0 v -%@ A %@ %@ 1 '.replace(/%@/gi, paddedRadius) + mid + ' 1 ' + x + ' ' + y + ' z'; var bar = document.getElementsByClassName ('progress-radial-bar')[0]; bar.setAttribute( 'd', pathData );
};
var max = 0.9;
var progress = 0.0;
drawProgress(progress);
var interval = window.setInterval(function () { progress = progress + 0.01; if(progress >= max) { window.clearInterval(interval); } drawProgress(progress);
}, 10);
Developer | Jon Beebe |
Username | somethingkindawierd |
Uploaded | January 23, 2023 |
Rating | 3.5 |
Size | 3,581 Kb |
Views | 8,096 |
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 |
Pixelate image into html table | 0 Kb |
MarionetteJS Stack View Controller | 6,647 Kb |
Emberjs Boilerplate | 1,893 Kb |
Emberjs Bootstrap Modal Carousel | 4,233 Kb |
Turning off Marionette wrapper div | 2,381 Kb |
Emberjs Nested Components | 2,252 Kb |
Backbone Resizeable View | 2,513 Kb |
IOS inspired Definition List | 2,972 Kb |
Emberjs Simple Calendar Component | 5,660 Kb |
Calendar Widget | 2,974 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 |
Planet Awesome | Bartuc | 3,554 Kb |
A bit of elegance | Hackthevoid | 9,095 Kb |
Twitch Live Channels | Inkblotty | 4,956 Kb |
CSS Tooltips | Darylldoyle | 2,599 Kb |
A Bouncy Menu Toggle | Billyysea | 4,563 Kb |
Image Hover | Johnheiner | 3,409 Kb |
SVG Circle Progress | JMChristensen | 3,368 Kb |
React JS Movie Info App | MTushar | 4,870 Kb |
A Pen by Mohomed Anees | Mohomedanees | 12,597 Kb |
Table border-collapse property | Maxds | 1,672 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!