Does anyone know how to define an animated arc / circle in SVG, such that the arc starts at 0 degrees and ends at 360 degrees?
相关问题
- Convert svg to geojson fails with ogr2ogr
- How to get coordinates of an svg?
- Changing color of SVG which was embedded using <
- Understanding svg's viewbox attribute
- Convert an inline SVG into a SVG file
相关文章
- Make marker-end same color as path?
- How to display unicode in SVG?
- Keep constant number of visible circles in 3D anim
- Converting svg to png with inkscape command line f
- How to create an SVG Matrix without an SVG element
- Animate opacity on hover (jQuery)
- rect collision detection d3js
- My background image get cut off at the bottom
You can also draw the SVG by hand using a
circle
and the following technique:circle
astroke
.stroke
dashed
with a dash length equal to the circle's circumference.stroke
by a length equal to the circle's circumference.HTML:
CSS:
jsfiddle
source: https://css-tricks.com/svg-line-animation-works/
I was also a bit disapointed to not be able to simply make an circle's arc with a percent, or an angle.
Nowadays, when I need an arc which is not part of a longer path, I use a circle and strokeDasharray trick to show just a part of this circle.
You can see an improved version here which use Sass to make the calculations.
One way is to use a circle, and animate the stroke-dashoffset (you need 'stroke-dasharray' too). An example of such an animation (not with a circle, but the same principle applies) can be seen here.
The other option is to use a path animation, and arc path segments, for animating/morphing between paths see this example.
Thanks for the answers - here is a little more information regarding why I want to animate a circle in SVG:
We have a server-client application. I plan to generate SVG images to represent charts (pie charts / bar charts) on the server and send the SVG to the clients. We have Java and .NET clients. I will write client-side code to parse and render the SVG images received from the server. I plan to use only a subset of the SVG format - not more than what we need to represent our charts, but animation is a requirement.
Long-term it would be nice to have an ajax client - that will run on browsers without java or .NET runtime. That is why I have chosen the SVG format.
For a short term solution I now think I will add my own element to the SVG, defining an arc using start and sweep angles. Then I can easily define the animation I require by animating the sweep angle, and makes my implementation simple.
Long term - if we really get around to imlpementing an AJAX/HTML client - I will have to re-implement and stick to the SVG standard.
you can paint it "by hand" using path's lineto and calculate the position of the arc:
http://jsfiddle.net/k99jy/138/