标签:svg
demo:http://codepen.io/tianzi77/pen/jPXRKo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<svg width="440" height="440">
<circle cx="220" cy="220" r="170" stroke-width="50" stroke="#f5f89a" fill="none"></circle>
<circle cx="220" cy="220" r="170" stroke-width="50" stroke="#abcdef" fill="none" transform="matrix(0,-1,1,0,0,440)" stroke-dasharray="0 1069"></circle>
<p>拖我:
<input id="range" type="range" min="0" max="100" value="0" style="width:300px;">
</p>
</svg>
<script>
var range = document.querySelector(‘#range‘),
circle = document.querySelectorAll(‘circle‘)[1];
range.addEventListener(‘change‘, function () {
var percent = this.value / 100,
perimeter = Math.PI * 2 * 170;
circle.setAttribute(‘stroke-dasharray‘, perimeter * percent + " " + perimeter * (1 - percent));
})
</script>
</body>
</html>
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:svg
原文地址:http://blog.csdn.net/u011263845/article/details/47271685