{"id":831,"date":"2016-07-15T18:26:14","date_gmt":"2016-07-15T10:26:14","guid":{"rendered":"http:\/\/www.bluesdream.com\/blog\/?p=831"},"modified":"2016-10-28T11:08:41","modified_gmt":"2016-10-28T03:08:41","slug":"step-by-step-to-understand-svg","status":"publish","type":"post","link":"https:\/\/www.bluesdream.com\/blog\/step-by-step-to-understand-svg.html","title":{"rendered":"Step by Step \u4e00\u6b65\u6b65\u4e86\u89e3SVG"},"content":{"rendered":"<p>\u6700\u8fd1\u770b\u5230\u7bc7\u6587\u7ae0\u5f88\u6709\u540c\u611f\uff0c\u5f88\u591a\u65f6\u5019\u60f3\u5b66\u4e60\u4e00\u4e9b\u4e1c\u897f\uff0c\u4f1a\u88ab\u4e00\u5806\u5806\u7684\u4ee3\u7801\u6240\u56f0\u6270\uff0c\u5f88\u96be\u53bb\u8bfb\u61c2\u548c\u7406\u89e3\u3002\u800c\u7528\u4e00\u4e2a\u4e2a\u5c0fDemo\u7684\u5f62\u5f0f\u4e86\u89e3\u8d77\u6765\u5c31\u66f4\u4e3a\u76f4\u89c2\uff0c\u4ea7\u751f\u5174\u8da3\u4e4b\u540e\u5b66\u8d77\u4e1c\u897f\u5c31\u81ea\u7136\u76f8\u5bf9\u8f7b\u677e\u3002<\/p>\n<h2>Demo1\uff1a\u521b\u5efa\u57fa\u672c\u5f62\u72b6<\/h2>\n<p>SVG \u9884\u5b9a\u4e49\u4e867\u4e2a\u57fa\u672c\u5143\u7d20\uff1a<code>circle \u521b\u5efa\u5706\u5f62<\/code>\u3001<code>rect \u521b\u5efa\u77e9\u5f62<\/code>\u3001<code>ellipse \u521b\u5efa\u692d\u5706<\/code>\u3001<code>line \u521b\u5efa\u7ebf\u6761<\/code>\u3001<code>polyline \u521b\u5efa\u6298\u7ebf<\/code>\u3001<code>polygon \u521b\u5efa\u591a\u8fb9\u5f62<\/code>\u3001<code>path \u521b\u5efa\u8def\u5f84<\/code>\u3002<br \/>\n\u5176\u4e2d path \u53ef\u8fdb\u884c\u586b\u5145\u3001\u52fe\u5212\uff08\u6cbf\u7740\u8def\u5f84\u7ed8\u5236\u76f4\u7ebf\uff09\uff0c\u4e5f\u53ef\u7528\u4f5c\u526a\u5207\u8def\u5f84\uff08\u5176\u4ed6\u5f62\u72b6\u7684\u56fe\u6837\uff09\uff0c\u662f\u6240\u6709\u7ed8\u56fe\u5143\u7d20\u4e2d\u6700\u590d\u6742\u7684\u3002<br \/>\n<!--more--><br \/>\n<a class=\"dlBtn\" title=\"Demo1\" href=\"http:\/\/www.bluesdream.com\/case\/html\/step-by-step-to-understand-svg\/index.html#demo1\" target=\"_blank\">Demo1<\/a><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;!-- \u5706\u5f62 Circle --&gt;\n&lt;svg width=&quot;200&quot; height=&quot;200&quot;&gt;\n  &lt;circle cx=&quot;100&quot; cy=&quot;100&quot; r=&quot;50&quot; fill=&quot;#29ABe2&quot; \/&gt;\n&lt;!-- \u77e9\u5f62 Rectangle --&gt;\n&lt;\/svg&gt;\n&lt;svg width=&quot;200&quot; height=&quot;200&quot;&gt;\n  &lt;rect x=&quot;50&quot; y=&quot;50&quot; width=&quot;100&quot; height=&quot;100&quot; = fill=&quot;#29ABe2&quot; \/&gt;\n&lt;!-- \u692d\u5706 Ellipse --&gt;\n&lt;\/svg&gt;\n&lt;svg width=&quot;200&quot; height=&quot;200&quot;&gt;\n  &lt;ellipse cx=&quot;100&quot; cy=&quot;100&quot; rx=&quot;50&quot; ry=&quot;25&quot; fill=&quot;#29ABe2&quot; \/&gt;\n&lt;!-- \u7ebf\u6761 Line --&gt;\n&lt;\/svg&gt;\n&lt;svg width=&quot;200&quot; height=&quot;200&quot;&gt;\n  &lt;line x1=&quot;50&quot; y1=&quot;50&quot; x2=&quot;150&quot; y2=&quot;150&quot; stroke=&quot;#29ABe2&quot; stroke-width=&quot;8&quot; \/&gt;\n&lt;!-- \u6298\u7ebf Polyline --&gt;\n&lt;\/svg&gt;\n&lt;svg width=&quot;200&quot; height=&quot;200&quot;&gt;\n  &lt;polyline points=&quot;30,50 70,50 70,90 110,90 110,130 150,130 150,170&quot; fill=&quot;white&quot; stroke=&quot;#29ABe2&quot; stroke-width=&quot;6&quot; \/&gt;\n&lt;!-- \u591a\u8fb9\u5f62 Polygon --&gt;\n&lt;\/svg&gt;\n&lt;svg width=&quot;200&quot; height=&quot;200&quot;&gt;\n  &lt;polygon points=&quot;100 50,65 150,150 90,50 90,135 150&quot; fill=&quot;#29ABe2&quot; \/&gt;\n&lt;!-- \u8def\u5f84 Path --&gt;\n&lt;\/svg&gt;\n&lt;svg width=&quot;200&quot; height=&quot;200&quot;&gt;\n  &lt;path d=&quot;M20,100 Q40,50 100,100 T180,100&quot; fill=&quot;none&quot; stroke=&quot;#29ABe2&quot; stroke-width=&quot;4&quot; \/&gt;\n&lt;\/svg&gt;\n<\/pre>\n<ol>\n<li>\u5c5e\u6027\u8bf4\u660e\uff1a<br \/>\nfill \u5c5e\u6027\uff1a\u8868\u793a\u586b\u5145\u989c\u8272<br \/>\nfill-opacity \u5c5e\u6027\uff1a\u586b\u5145\u989c\u8272\u900f\u660e\u5ea6\uff08\u5408\u6cd5\u7684\u8303\u56f4\u662f\uff1a0 - 1\uff09<br \/>\nstroke \u5c5e\u6027\uff1a\u8868\u793a\u63cf\u8fb9\u989c\u8272\uff08\u662f SVG \u4e2d\u6709\u4e2a\u6bd4\u8f83\u91cd\u8981\u7684\u5c5e\u6027\u5206\u652f\uff0c\u4e0b\u6587\u4e2d\u4f1a\u6709\u8be6\u7ec6\u8bf4\u660e\uff09<br \/>\nstroke-width \u5c5e\u6027\uff1a\u8868\u793a\u63cf\u8fb9\u7684\u7c97\u7ec6<br \/>\nstroke-opacity \u5c5e\u6027\uff1a\u8868\u793a\u63cf\u8fb9\u900f\u660e\u5ea6\uff08\u5408\u6cd5\u7684\u8303\u56f4\u662f\uff1a0 - 1\uff09<\/p>\n<\/li>\n<li>\n<p><code>&lt;circle&gt;<\/code>\u6807\u7b7e\uff1a<br \/>\ncx \u5c5e\u6027\uff1a\u5706\u70b9\u7684 x \u5750\u6807<br \/>\ncy \u5c5e\u6027\uff1a\u5706\u70b9\u7684 y \u5750\u6807\uff08\u5982\u679c\u7701\u7565 cx \u548c cy\uff0c\u5706\u7684\u4e2d\u5fc3\u4f1a\u88ab\u8bbe\u7f6e\u4e3a (0, 0)\uff09<br \/>\nr \u5c5e\u6027\uff1a\u5706\u7684\u534a\u5f84<\/p>\n<p><code>&lt;rect&gt;<\/code>\u6807\u7b7e\uff1a<br \/>\nx \u5c5e\u6027\uff1a\u77e9\u5f62\u7684\u5de6\u4fa7\u4f4d\u7f6e\uff08\u4f8b\u5982\uff0cx=\"0\" \u8868\u793a\u77e9\u5f62\u5230\u6d4f\u89c8\u5668\u7a97\u53e3\u5de6\u4fa7\u7684\u8ddd\u79bb\u662f 0px\uff09<br \/>\ny \u5c5e\u6027\uff1a\u77e9\u5f62\u7684\u9876\u7aef\u4f4d\u7f6e\uff08\u4f8b\u5982\uff0cy=\"0\" \u8868\u793a\u77e9\u5f62\u5230\u6d4f\u89c8\u5668\u7a97\u53e3\u9876\u7aef\u7684\u8ddd\u79bb\u662f 0px\uff09<\/p>\n<p><code>&lt;ellipse&gt;<\/code>\u6807\u7b7e\uff1a<br \/>\ncx \u5c5e\u6027\uff1a\u8868\u793a\u5706\u70b9\u7684 x \u5750\u6807<br \/>\ncy \u5c5e\u6027\uff1a\u8868\u793a\u5706\u70b9\u7684 y \u5750\u6807<br \/>\nrx \u5c5e\u6027\uff1a\u8868\u793a\u6c34\u5e73\u534a\u5f84<br \/>\nry \u5c5e\u6027\uff1a\u8868\u793a\u5782\u76f4\u534a\u5f84<\/p>\n<p><code>&lt;line&gt;<\/code>\u6807\u7b7e\uff1a<br \/>\nx1 \u5c5e\u6027\uff1ax \u8f74\u5f00\u59cb\u5750\u6807<br \/>\ny1 \u5c5e\u6027\uff1ay \u8f74\u5f00\u59cb\u5750\u6807<br \/>\nx2 \u5c5e\u6027\uff1ax \u8f74\u7ed3\u675f\u5750\u6807<br \/>\ny2 \u5c5e\u6027\uff1ay \u8f74\u7ed3\u675f\u5750\u6807<\/p>\n<p><code>&lt;polyline&gt;<\/code>\u6807\u7b7e\uff1a<br \/>\npoints \u5c5e\u6027\uff1a\u5b9a\u4e49\u591a\u8fb9\u5f62\u6bcf\u4e2a\u89d2\u7684 x \u548c y \u5750\u6807<\/p>\n<p><code>&lt;polygon&gt;<\/code>\u6807\u7b7e\uff1a<br \/>\n\u540c <code>&lt;polyline&gt;<\/code> \u6807\u7b7e<\/p>\n<p><code>&lt;path&gt;<\/code>\u6807\u7b7e\uff1a<br \/>\nM = \u79fb\u52a8\u5230\uff1bmoveto(M X,Y) (\u79fb\u52a8\u5230)<br \/>\nL = \u8fde\u7ebf\u5230\uff1blineto(L X,Y)<br \/>\nH = \u6c34\u5e73\u94fe\u63a5\u5230\uff1bhorizontal lineto(H X)<br \/>\nV = \u5782\u76f4\u94fe\u63a5\u5230\uff1bvertical lineto(V Y)<br \/>\nC = \u4f7f\u7528\u66f2\u7ebf\u8fde\u63a5\u5230\uff1bcurveto(C X1,Y1,X2,Y2,ENDX,ENDY)<br \/>\nS = \u4f7f\u7528\u5e73\u6ed1\u66f2\u7ebf\u8fde\u63a5\u5230\uff1bsmooth curveto(S X2,Y2,ENDX,ENDY)<br \/>\nQ = \u4f7f\u7528\u4e8c\u6b21\u8d1d\u585e\u5c14\u66f2\u7ebf\u8fde\u63a5\u5230\uff1bquadratic Belzier curve(Q X,Y,ENDX,ENDY)<br \/>\nT = \u4f7f\u7528\u5e73\u6ed1\u7684\u4e8c\u6b21\u8d1d\u585e\u5c14\u66f2\u7ebf\u8fde\u63a5\u5230\uff1bsmooth quadratic Belzier curveto(T ENDX,ENDY)<br \/>\nA = \u4f7f\u7528\u692d\u5706\u66f2\u7ebf\u8fde\u63a5\u5230\uff1belliptical Arc(A RX,RY,XROTATION,FLAG1,FLAG2,X,Y)<br \/>\nZ = \u5c06\u8def\u5f84\u5c01\u95ed\u5230\uff1bclosepath()<\/p>\n<\/li>\n<\/ol>\n<h2>Demo2\uff1a\u5b9e\u73b0\u4e00\u4e2a\u7b80\u5355\u7684\u52a8\u753b\u6548\u679c<\/h2>\n<p>\u5728\u5bf9\u57fa\u672c\u5143\u7d20\u6709\u4e86\u4e00\u4e9b\u4e86\u89e3\u540e\uff0c\u6211\u4eec\u9996\u5148\u5df2\u5706\u5f62\u4e3a\u4f8b\uff0c\u7ed9\u5143\u7d20\u6dfb\u52a0\u52a8\u753b\u6548\u679c\u3002SVG\u52a8\u753b\u57fa\u4e8e<code>SMIL\uff08Synchronized Multimedia Integration Language - \u540c\u6b65\u591a\u5a92\u4f53\u96c6\u6210\u8bed\u8a00\uff09<\/code>\u6765\u5b9e\u73b0\u3002<\/p>\n<p><a class=\"dlBtn\" title=\"Demo2\" href=\"http:\/\/www.bluesdream.com\/case\/html\/step-by-step-to-understand-svg\/index.html#demo2\" target=\"_blank\">Demo2<\/a><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;svg width=&quot;400&quot; height=&quot;400&quot;&gt;\n  &lt;circle cx=&quot;200&quot; cy=&quot;200&quot; r=&quot;50&quot; fill=&quot;#29ABe2&quot; &gt;\n    &lt;animate attributeName=&quot;r&quot; attributeType=&quot;XML&quot; from=&quot;50&quot; to=&quot;80&quot; begin=&quot;0s&quot; dur=&quot;2s&quot;\/&gt;\n  &lt;\/circle&gt;\n&lt;\/svg&gt;\n<\/pre>\n<ol>\n<li>\u6839\u636eSMIL\u52a8\u753b\u89c4\u8303\uff0c\u6709\u4ee5\u4e0b4\u4e2a\u57fa\u672c\u7684\u52a8\u753b\u5143\u7d20\uff1a<br \/>\n<code>&lt;animate&gt;<\/code>\uff1a\u5b9a\u4e49\u52a8\u753b\u7684\u5b9e\u65f6\u5c5e\u6027\uff08\u4f8b\u5982\uff1a\u6301\u7eed\u65f6\u95f4\u3001\u5c5e\u6027\u548c\u5c5e\u6027\u503c\uff09<br \/>\n<code>&lt;set&gt;<\/code>\uff1a\u5728\u6307\u5b9a\u7684\u65f6\u95f4\u4e4b\u540e\u6267\u884c\u53e6\u5916\u7684\u52a8\u753b\u6548\u679c\uff0c\u901a\u5e38\u7528\u6765\u4fee\u6539\u975e\u6570\u5b57\u7c7b\u578b\u5c5e\u6027\u6240\u4ea7\u751f\u7684\u52a8\u753b<br \/>\n<code>&lt;animateMotion&gt;<\/code>\uff1a\u8ba9\u5143\u7d20\u6cbf\u7740\u7279\u5b9a\u7684\u8def\u5f84\u8fd0\u52a8<br \/>\n<code>&lt;animateColor&gt;<\/code>\uff1a\u5728\u6307\u5b9a\u7684\u65f6\u95f4\u5185\u4fee\u6539\u5143\u7d20\u7684\u989c\u8272\uff08SVG 2.0 \u4e2d\u5df2\u88ab\u79fb\u9664\uff0c\u4f7f\u7528 <code>&lt;animate&gt;<\/code> \u4e5f\u80fd\u5b9e\u73b0\u76f8\u540c\u6548\u679c\uff09<\/p>\n<\/li>\n<li>\n<p>attributeName \u5c5e\u6027\uff1a<br \/>\n\u52a8\u753b\u5c5e\u6027\u7684\u540d\u79f0\u3002\u53ef\u4ee5\u662f\u5143\u7d20\u76f4\u63a5\u66b4\u9732\u7684\u5c5e\u6027\uff0c\u53ef\u4ee5\u662fCSS\u5c5e\u6027\u3002<\/p>\n<\/li>\n<li>\n<p>attributeType \u5c5e\u6027\uff1a<br \/>\n\u52a8\u753b\u5c5e\u6027\u7684\u7c7b\u522b\u3002\u53d6\u503c\uff1a\"auto\" | \"XML\" | \"CSS\"\u3002<br \/>\nauto\uff1a\u9ed8\u8ba4\u503c\uff0c\u81ea\u52a8\u8bc6\u522b\uff08\u4ed6\u4f1a\u4f18\u5148\u5f53\u6210 CSS \u5904\u7406\uff0c\u5982\u679c\u65e0\u6cd5\u8bc6\u522b\uff0c\u5219\u76f4\u63a5\u5f53\u6210 XML \u7c7b\u522b\u5904\u7406\u3002\u5982\u679c\u4e0d\u80fd\u786e\u5b9a\uff0c\u5efa\u8bae\u4e0d\u8bbe\u7f6e attributeType \u503c\uff09<br \/>\n\u9009\u62e9 XML \u548c CSS \u8fd9\u4e24\u4e2a\u503c\uff0c\u53d6\u51b3\u4e8e\u5c5e\u6027\u5728 XML \u91cc\u8fd8\u662f\u5728 style \u91cc\uff08x, y \u4ee5\u53ca transform \u5c31\u5c5e\u4e8e XML\uff0copacity \u5c31\u5c5e\u4e8e CSS\uff09<\/p>\n<\/li>\n<li>\n<p>from, to, by, values \u5c5e\u6027\uff1a<br \/>\nfrom\uff1a\u52a8\u753b\u7684\u8d77\u59cb\u503c\uff08\u53ef\u9009\uff0c\u5f53\u4e0d\u5199\u7684\u65f6\u5019\u4f1a\u53d6\u9ed8\u8ba4\u503c\uff09<br \/>\nto\uff1a\u6307\u5b9a\u52a8\u753b\u7684\u7ed3\u675f\u503c<br \/>\nby\uff1a\u52a8\u753b\u7684\u76f8\u5bf9\u53d8\u5316\u503c<br \/>\nvalues\uff1a\u53ef\u4ee5\u662f\u5206\u53f7\u5206\u9694\u7684\u4e00\u4e2a\u6216\u591a\u4e2a\u503c\uff08\u5373\uff1a\u4e00\u7ec4\u6570\u503c\u3002\u4f46\u53ea\u6709\u4e00\u4e2a\u503c\u65f6\uff0c\u65e0\u6cd5\u4f53\u73b0\u52a8\u753b\u6548\u679c\uff09<\/p>\n<\/li>\n<li>\n<p>begin, end \u5c5e\u6027\uff1a<br \/>\n\u6307\u52a8\u753b\u5f00\u59cb\u7684\u65f6\u95f4\u3002\u5982\u679c\u628a beigin \u503c\u8bbe\u7f6e\u4e3a 1s \u5c31\u8868\u793a\u5ef6\u8fdf1\u79d2\u540e\u5f00\u59cb\u52a8\u753b\uff0c\u53ea\u662f\u6700\u7b80\u5355\u7684\u4f7f\u7528\u65b9\u6cd5\u3002<br \/>\n\u8fd8\u53ef\u4ee5\u5b9a\u4e49\u7528\u5206\u53f7\u5206\u9694\u7684\u4e00\u7ec4\u503c\uff0c\u4f8b beigin=\"1s;3s\" \u8868\u793a 1s \u65f6\u6267\u884c\u4e00\u6b21\uff0c3s \u518d\u6267\u884c\u4e00\u6b21\uff08\u5982\u679c\u4e4b\u524d\u52a8\u753b\u6ca1\u7ed3\u675f\uff0c\u4f1a\u7acb\u5373\u505c\u6b62\u540e\u7eed\u6548\u679c\uff0c\u4ece\u5934\u5f00\u59cb\uff09\u3002<br \/>\n\u6240\u4ee5\uff0c\u5982\u679c\u52a8\u753b\u7684\u6301\u7eed\u65f6\u95f4\u4e3a dur=\"2s\"\uff0c\u540c\u65f6\u6ca1\u6709 repeatCount \u5c5e\u6027\u65f6\u5019\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u52a8\u753b\u4f3c\u4e4e\u8fde\u7eed\u6267\u884c\u4e862\u6b21\u3002\uff08\u65f6\u95f4\u5355\u4f4d\uff1a \"h\" | \"min\" | \"s\" | \"ms\"\uff09<\/p>\n<\/li>\n<li>\n<p>dur \u5c5e\u6027\uff1a<br \/>\n\u52a8\u753b\u7684\u6301\u7eed\u65f6\u95f4\u3002<\/p>\n<\/li>\n<\/ol>\n<h2>Demo3\uff1a\u8ba9\u52a8\u753b\u505c\u7559\u5728\u6700\u540e\u4e00\u5e27<\/h2>\n<p>\u6839\u636e\u4e0a\u9762\u7684Demo\uff0c\u6211\u4eec\u5df2\u7ecf\u5b9e\u73b0\u4e86\u4e00\u4e2a\u7b80\u5355\u7684 SVG \u52a8\u753b\u3002<br \/>\n\u6b64\u65f6\u7684 <code>attributeName=\"r\"\uff0c\u5373\u4ee3\u8868\u63a7\u5236 circle \u6807\u7b7e\u7684 r \u5c5e\u6027<\/code>\u3002<code>from=\"50\" \u4ee3\u8868\u52a8\u753b\u5f00\u59cb\u5706\u5f62\u7684 50<\/code>\uff0c<code>to=\"80\" \u52a8\u753b\u7ed3\u675f\u5706\u5f62\u534a\u5f84\u8fc7\u5ea6\u5230 80\u3002<br \/>\n\u4f46\u53ef\u4ee5\u53d1\u73b0\uff0c\u52a8\u753b\u5728\u7ed3\u675f\u540e\u53c8\u8fd4\u56de\u5230\u4e86\u8d77\u59cb\u5e27\uff08\u5373\uff1a\u52a8\u753b\u5f00\u59cb\u65f6\u7684\u72b6\u6001\uff09\uff0c\u90a3\u9700\u8981\u8ba9\u4ed6\u505c\u7559\u5728\u7ed3\u675f\u5e27\uff08\u5373\uff1a\u52a8\u753b\u7ed3\u675f\u65f6\u7684\u72b6\u6001\uff09\uff0c\u5c31\u8981\u7ed9<\/code><animate>` \u6807\u7b7e\u6dfb\u52a0 fill \u5c5e\u6027\u3002<\/p>\n<p><a class=\"dlBtn\" title=\"Demo3\" href=\"http:\/\/www.bluesdream.com\/case\/html\/step-by-step-to-understand-svg\/index.html#demo3\" target=\"_blank\">Demo3<\/a><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;svg width=&quot;400&quot; height=&quot;400&quot;&gt;\n  &lt;circle cx=&quot;200&quot; cy=&quot;200&quot; r=&quot;50&quot; fill=&quot;#29ABe2&quot; &gt;\n    &lt;animate attributeName=&quot;r&quot; attributeType=&quot;XML&quot; from=&quot;50&quot; to=&quot;80&quot; begin=&quot;0s&quot; dur=&quot;2s&quot; fill=&quot;freeze&quot;\/&gt;\n  &lt;\/circle&gt;\n&lt;\/svg&gt;\n<\/pre>\n<ol>\n<li>fill \u5c5e\u6027\uff1a<br \/>\n\u8868\u793a\u52a8\u753b\u95f4\u9699\u7684\u586b\u5145\u65b9\u5f0f\u3002\u53d6\u503c\uff1a\"remove\" | \"freeze\"\u3002<br \/>\nremove\uff1a\u9ed8\u8ba4\u503c\u3002\u8868\u793a\u52a8\u753b\u7ed3\u675f\u540e\u76f4\u63a5\u56de\u5230\u52a8\u753b\u5f00\u59cb\u72b6\u6001\u3002<br \/>\nfreeze\uff1a\u51bb\u7ed3\u7684\u610f\u601d\u3002\u8868\u793a\u52a8\u753b\u7ed3\u675f\u540e\u4fdd\u6301\u52a8\u753b\u7ed3\u675f\u65f6\u7684\u72b6\u6001\u3002<\/p>\n<\/li>\n<li>\n<p>\u4e3b\u8981\u6ce8\u610f\u4e00\u70b9\uff1a<br \/>\nSVG fill \u5c5e\u6027\u548c animate fill \u5c5e\u6027\u662f\u4e24\u4e2a\u72ec\u7acb\u7684\u5c5e\u6027\u3002<\/p>\n<\/li>\n<\/ol>\n<h2>Demo4\uff1a\u52a8\u753b\u65e0\u9650\u5faa\u73af<\/h2>\n<p>\u6548\u679c\u53ea\u6267\u884c\u4e00\u6b21\u662f\u4e0d\u591f\u7684\uff0c\u5f88\u591a\u65f6\u5019\u4e00\u4e9b\u5143\u7d20\u52a8\u753b\u9700\u8981\u91cd\u590d\u5faa\u73af\u3002\u6211\u4eec\u7ee7\u7eed\u5728 animate \u6807\u7b7e\u4e2d\u6dfb\u52a0\u4e00\u4e2a repeatCount \u5c5e\u6027\u3002<\/p>\n<p><a class=\"dlBtn\" title=\"Demo4\" href=\"http:\/\/www.bluesdream.com\/case\/html\/step-by-step-to-understand-svg\/index.html#demo4\" target=\"_blank\">Demo4<\/a><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;svg width=&quot;400&quot; height=&quot;400&quot;&gt;\n  &lt;circle cx=&quot;200&quot; cy=&quot;200&quot; r=&quot;50&quot; fill=&quot;#29ABe2&quot; &gt;\n    &lt;animate attributeName=&quot;r&quot; attributeType=&quot;XML&quot; from=&quot;50&quot; to=&quot;80&quot; begin=&quot;0s&quot; dur=&quot;2s&quot; fill=&quot;freeze&quot; repeatCount=&quot;indefinite&quot;\/&gt;\n  &lt;\/circle&gt;\n&lt;\/svg&gt;\n<\/pre>\n<ol>\n<li>repeatCount \u5c5e\u6027\uff1a<br \/>\n\u8868\u793a\u52a8\u753b\u6267\u884c\u6b21\u6570\u3002\u53ef\u4ee5\u662f\u4e00\u4e2a\u6570\u5b57\uff0c\u4e5f\u53ef\u4ee5\u662f \"indefinite\" \u65e0\u9650\u5faa\u73af\u3002<br \/>\n\u53e6\u5916\u8fd8\u6709\u4e00\u4e2a repeatDur \u5c5e\u6027\uff1a\u8868\u793a\u52a8\u753b\u91cd\u590d\u7684\u603b\u65f6\u95f4\u3002\u5373\uff1arepeatDur = \"1s\" \u90a3\u4e48\u52a8\u753b\u6267\u884c\u5230\u4e00\u534a\u65f6\u5c31\u4f1a\u6682\u505c\u3002<\/li>\n<\/ol>\n<h2>Demo5\uff1a\u5b9e\u73b0\u547c\u5438\u6548\u679c<\/h2>\n<p>\u65e0\u9650\u5faa\u73af\u73b0\u5f97\u4ee5\u5b9e\u73b0\uff0c\u53ef\u6d41\u7545\u5ea6\u8fd8\u8fdc\u8fdc\u4e0d\u591f\u3002\u8d77\u59cb\u5e27\u548c\u7ed3\u675f\u5e27\u4e4b\u95f4\u5b58\u5728\u4e00\u4e2a\u751f\u786c\u7684\u8df3\u8f6c\uff0c\u6ca1\u6709\u5f88\u597d\u7684\u8854\u63a5\u3002\u6211\u4eec\u6539\u53d8\u4e00\u4e0b values \u5c5e\u6027\u7684\u6570\u503c\uff0c\u5236\u4f5c\u51fa\u6211\u4eec\u60f3\u8981\u7684\u547c\u5438\u6548\u679c\u3002<\/p>\n<p><a class=\"dlBtn\" title=\"Demo5\" href=\"http:\/\/www.bluesdream.com\/case\/html\/step-by-step-to-understand-svg\/index.html#demo5\" target=\"_blank\">Demo5<\/a><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;svg width=&quot;400&quot; height=&quot;400&quot;&gt;\n  &lt;circle cx=&quot;200&quot; cy=&quot;200&quot; r=&quot;50&quot; fill=&quot;#29ABe2&quot; &gt;\n    &lt;animate attributeName=&quot;r&quot; attributeType=&quot;XML&quot; values=&quot;50;80;50&quot; begin=&quot;0s&quot; dur=&quot;2s&quot; fill=&quot;freeze&quot; repeatCount=&quot;indefinite&quot;\/&gt;\n  &lt;\/circle&gt;\n&lt;\/svg&gt;\n<\/pre>\n<ol>\n<li>from, to, by, values \u76f8\u4e92\u4e4b\u95f4\u5b58\u5728\u5236\u7ea6\u5173\u7cfb\uff0c\u6709\u4ee5\u4e0b\u4e00\u4e9b\u89c4\u5219\uff1a<br \/>\n\u5982\u679c\u52a8\u753b\u7684\u8d77\u59cb\u503c\u4e0e\u5143\u7d20\u7684\u9ed8\u8ba4\u503c\u662f\u4e00\u6837\u7684\uff0cfrom \u53c2\u6570\u53ef\u4ee5\u7701\u7565\u3002<br \/>\n\u4e0d\u8003\u8651values\u7684\u524d\u63d0\u4e0b\uff0cto, by \u4e24\u4e2a\u53c2\u6570\u81f3\u5c11\u9700\u8981\u6709\u4e00\u4e2a\u51fa\u73b0\uff0c\u5426\u5219\u52a8\u753b\u6548\u679c\u6ca1\u6709\u3002to \u8868\u793a\u7edd\u5bf9\u503c\uff0cby \u8868\u793a\u76f8\u5bf9\u503c\u3002\u62ff\u4f4d\u79fb\u8ddd\u79bb\uff0c\u5982\u679c from \u662f 0\uff0cto \u503c\u4e3a 100 \u5219\u8868\u793a\u5143\u7d20\u4ece 0 \u79fb\u52a8\u5230 100 \u8fd9\u4e2a\u4f4d\u7f6e\u3002\u4f46\u662f\uff0c\u5982\u679c by \u503c\u662f200\uff0c\u5219\u8868\u793a\u79fb\u52a8\u5230 100+200=300 \u8fd9\u4e2a\u4f4d\u7f6e\u3002<br \/>\n\u5982\u679c to, by \u540c\u65f6\u51fa\u73b0\uff0c\u53ea\u8bc6\u522bto\u3002<br \/>\n\u5982\u679c to, by, values \u90fd\u6ca1\u8bbe\u7f6e\uff0c\u81ea\u7136\u6ca1\u52a8\u753b\u6548\u679c\u3002\u5982\u679c\u4efb\u610f\uff08\u5305\u62ecfrom\uff09\u4e00\u4e2a\u5c5e\u6027\u7684\u503c\u4e0d\u5408\u6cd5\uff0c\u89c4\u8303\u4e0a\u8bf4\u662f\u6ca1\u6709\u52a8\u753b\u6548\u679c\u3002\u4f46\u662f\uff0c\u636e\u6211\u6d4b\u8bd5\uff0cFireFox \u6d4f\u89c8\u5668\u786e\u5b9e\u5982\u6b64\uff0c\u4f46\u662f Chrome \u7279\u610f\u505a\u4e86\u5199\u5bb9\u9519\u5904\u7406\u3002\u4f8b\u5982\uff0c\u672c\u6765\u662f\u6570\u503c\u7684\u5c5e\u6027\uff0c\u5199\u4e86\u4e2a\u8bf8\u5982a\u8fd9\u4e2a\u4e0d\u5408\u6cd5\u7684\u503c\uff0c\u5176\u4f1a\u5f53\u4f5c 0 \u6765\u5904\u7406\uff0c\u52a8\u753b\u6548\u679c\u4f9d\u7136\u5b58\u5728\u3002<br \/>\n\u5f53 values \u503c\u8bbe\u7f6e\u5e76\u80fd\u8bc6\u522b\u65f6\u5019 from\uff0cto, by \u7684\u503c\u90fd\u4f1a\u88ab\u5ffd\u7565\u3002\u90a3 values \u5c5e\u6027\u662f\u5e72\u4ec0\u4e48\u7684\u5462\uff1f\u522b\u770b\u540d\u5b57\u633a\u5927\u4f17\u7684\uff0c\u5176\u8fd8\u662f\u6709\u4e9b\u529f\u529b\u7684\u3002\u6211\u4eec\u5b9e\u73b0\u52a8\u753b\uff0c\u4e0d\u53ef\u80fd\u5c31\u662f\u5355\u7eaf\u7684\u4ecea\u4f4d\u7f6e\u5230b\u4f4d\u7f6e\uff0c\u6709\u65f6\u5019\uff0c\u9700\u8981\u53bbc\u4f4d\u7f6e\u8fc7\u6e21\u4e0b\u3002\u6b64\u65f6\uff0c\u5b9e\u9645\u4e0a\u67093\u4e2a\u52a8\u753b\u5173\u952e\u70b9\uff0c\u800c from, to, by \u53ea\u80fd\u9a7e\u9a6d\u4e24\u4e2a\u3002<\/li>\n<\/ol>\n<h2>Demo6\uff1a\u591a\u4e2a\u52a8\u753b\u6548\u679c\u540c\u65f6\u6267\u884c<\/h2>\n<p>\u770b\u5230\u8fd9\uff0c\u60f3\u5fc5\u4f60\u5df2\u5bf9 SVG \u6709\u4e86\u4e00\u4e2a\u521d\u6b65\u8ba4\u77e5\u3002\u73b0\u5728\u6211\u4eec\u6539\u8fdb\u4e00\u4e0b\u4ee3\u7801\uff0c\u518d\u589e\u52a0\u4e00\u4e2a <code>&lt;animate&gt;<\/code> \u6807\u7b7e\uff0c\u4ece\u800c\u8ba9\u5143\u7d20\u80fd\u591f\u540c\u65f6\u5b9e\u73b02\u4e2a\u6548\u679c\u3002<\/p>\n<p><a class=\"dlBtn\" title=\"Demo6\" href=\"http:\/\/www.bluesdream.com\/case\/html\/step-by-step-to-understand-svg\/index.html#demo6\" target=\"_blank\">Demo6<\/a><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;svg width=&quot;400&quot; height=&quot;400&quot;&gt;\n  &lt;circle cx=&quot;200&quot; cy=&quot;200&quot; r=&quot;50&quot; fill=&quot;#29ABe2&quot; &gt;\n    &lt;animate attributeName=&quot;r&quot; attributeType=&quot;CSS&quot; values=&quot;50;80;50&quot; begin=&quot;0s&quot; dur=&quot;2s&quot; fill=&quot;freeze&quot; repeatCount=&quot;indefinite&quot;\/&gt;\n    &lt;animate attributeName=&quot;fill-opacity&quot; attributeType=&quot;CSS&quot; values=&quot;1;0.5;1&quot; begin=&quot;0s&quot; dur=&quot;2s&quot; fill=&quot;freeze&quot; repeatCount=&quot;indefinite&quot;\/&gt;\n  &lt;\/circle&gt;\n&lt;\/svg&gt;\n<\/pre>\n<ol>\n<li>attributeName=\"fill-opacity\" \u5b9a\u4e49\u586b\u5145\u989c\u8272\u900f\u660e\u5ea6\u3002<\/p>\n<\/li>\n<li>\n<p>\u66f4\u591a\u7684 SVG \u5c5e\u6027\uff0c\u53ef\u4ee5\u67e5\u770b SVG \u5c5e\u6027\u53c2\u8003\u5217\u8868\uff1a\/\/ https:\/\/developer.mozilla.org\/zh-CN\/docs\/Web\/SVG\/Attribute<\/p>\n<\/li>\n<\/ol>\n<h2>Demo7\uff1aSVG \u52a8\u753b\u961f\u5217<\/h2>\n<p>\u591a\u4e2a\u6548\u679c\u7684\u540c\u65f6\u5b9e\u73b0\u662f\u4e0d\u662f\u6ca1\u60f3\u8c61\u4e2d\u7684\u90a3\u4e48\u590d\u6742\uff1f\u90a3\u6211\u4eec\u518d\u6765\u5b9e\u73b0\u4e00\u4e2a SVG \u7684\u52a8\u753b\u961f\u5217\uff0c\u539f\u7406\u4e5f\u5341\u5206\u7b80\u5355\u3002<br \/>\n\u4e3a\u6bcf\u4e2a <code>&lt;animate&gt;<\/code> \u6807\u7b7e\u6dfb <code>id<\/code>\uff0c\u7136\u540e<code>\u4e0b\u4e00\u4e2a\u52a8\u753b\u7684 begin \u503c\u4e3a\u4e0a\u4e00\u4e2a\u7684 id.end<\/code>\u3002<\/p>\n<p><a class=\"dlBtn\" title=\"Demo7\" href=\"http:\/\/www.bluesdream.com\/case\/html\/step-by-step-to-understand-svg\/index.html#demo7\" target=\"_blank\">Demo7<\/a><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;svg width=&quot;400&quot; height=&quot;400&quot;&gt;\n  &lt;circle cx=&quot;50&quot; cy=&quot;25&quot; r=&quot;25&quot; fill=&quot;#29ABe2&quot; &gt;\n    &lt;animate id=&quot;r1&quot; attributeName=&quot;cy&quot; attributeType=&quot;XML&quot; from=&quot;25&quot; to=&quot;375&quot; begin=&quot;0s&quot; dur=&quot;.2s&quot; fill=&quot;freeze&quot;\/&gt;\n  &lt;\/circle&gt;\n  &lt;circle cx=&quot;110&quot; cy=&quot;25&quot; r=&quot;25&quot; fill=&quot;#29ABe2&quot; &gt;\n    &lt;animate id=&quot;r2&quot; attributeName=&quot;cy&quot; attributeType=&quot;XML&quot; from=&quot;25&quot; to=&quot;375&quot; begin=&quot;r1.end + .5s&quot; dur=&quot;.2s&quot; fill=&quot;freeze&quot;\/&gt;\n  &lt;\/circle&gt;\n  &lt;circle cx=&quot;170&quot; cy=&quot;25&quot; r=&quot;25&quot; fill=&quot;#29ABe2&quot; &gt;\n    &lt;animate id=&quot;r3&quot; attributeName=&quot;cy&quot; attributeType=&quot;XML&quot; from=&quot;25&quot; to=&quot;375&quot; begin=&quot;r2.end + .5s&quot; dur=&quot;.2s&quot; fill=&quot;freeze&quot;\/&gt;\n  &lt;\/circle&gt;\n  &lt;circle cx=&quot;230&quot; cy=&quot;25&quot; r=&quot;25&quot; fill=&quot;#29ABe2&quot; &gt;\n    &lt;animate id=&quot;r4&quot; attributeName=&quot;cy&quot; attributeType=&quot;XML&quot; from=&quot;25&quot; to=&quot;375&quot; begin=&quot;r3.end + .5s&quot; dur=&quot;.2s&quot; fill=&quot;freeze&quot;\/&gt;\n  &lt;\/circle&gt;\n  &lt;circle cx=&quot;290&quot; cy=&quot;25&quot; r=&quot;25&quot; fill=&quot;#29ABe2&quot; &gt;\n    &lt;animate id=&quot;r5&quot; attributeName=&quot;cy&quot; attributeType=&quot;XML&quot; from=&quot;25&quot; to=&quot;375&quot; begin=&quot;r4.end + .5s&quot; dur=&quot;.2s&quot; fill=&quot;freeze&quot;\/&gt;\n  &lt;\/circle&gt;\n  &lt;circle cx=&quot;350&quot; cy=&quot;25&quot; r=&quot;25&quot; fill=&quot;#29ABe2&quot; &gt;\n    &lt;animate id=&quot;r6&quot; attributeName=&quot;cy&quot; attributeType=&quot;XML&quot; from=&quot;25&quot; to=&quot;375&quot; begin=&quot;r5.end + .5s&quot; dur=&quot;.2s&quot; fill=&quot;freeze&quot;\/&gt;\n  &lt;\/circle&gt;\n&lt;\/svg&gt;\n<\/pre>\n<ol>\n<li>begin \u7684\u503c\u53ef\u4ee5\u662f\u8868\u8fbe\u5f0f\uff1abegin = [\u5143\u7d20\u7684id].[\u4e8b\u4ef6\u7c7b\u578b] +\/- \u65f6\u95f4\u503c\u3002\u4f8b\u5982\uff1abegin=\"r1.end + .5s\" \uff08\u5373\u4e0a\u4e00\u4e2a\u52a8\u753b\u5b8c\u6210\u540e\uff0c\u5ef6\u8fdf 0.5s \u518d\u5f00\u59cb\uff09<\/p>\n<\/li>\n<li>\n<p>\u540c\u65f6\u4e3a\u4e86\u66f4\u597d\u7684\u7406\u89e3 attributeName \u5c5e\u6027\uff0c\u6211\u4eec\u628a\u53c2\u6570\u521a\u6539\u4e3acy\u3002<\/p>\n<\/li>\n<\/ol>\n<h2>Demo8\uff1a\u52a8\u753b\u65cb\u8f6c<\/h2>\n<p>\u63a5\u7740\uff0c\u4e3a\u4e86\u5f15\u51fa\u540e\u9762\u7684\u5185\u5bb9\uff0c\u9996\u5148 SVG \u5143\u7d20\u65cb\u8f6c\u8d77\u6765\u3002\u4e3a\u4e86\u66f4\u597d\u7684\u770b\u51fa\u6548\u679c\uff0c\u628a\u6211\u4eec\u4e4b\u524d\u6240\u753b\u7684\u5706\u5f62\u56fe\u6848\uff0c\u6539\u6210\u4e3a\u77e9\u5f62\u3002<br \/>\n\u5e76\u4f7f\u7528 line \u6807\u7b7e\uff0c\u4e3a SVG \u753b\u5e03\u6dfb\u52a0\u4e24\u6761\u201c\u8f85\u52a9\u7ebf\u201d\uff0c\u4fbf\u4e8e\u66f4\u597d\u7684\u7406\u89e3\u5176\u4e2d\u53c2\u6570\u3002<\/p>\n<p><a class=\"dlBtn\" title=\"Demo8\" href=\"http:\/\/www.bluesdream.com\/case\/html\/step-by-step-to-understand-svg\/index.html#demo8\" target=\"_blank\">Demo8<\/a><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;svg width=&quot;400&quot; height=&quot;400&quot;&gt;\n  &lt;rect width=&quot;100&quot; height=&quot;100&quot; x=&quot;100&quot; y=&quot;100&quot; fill=&quot;#29ABe2&quot; &gt;\n    &lt;animateTransform attributeName=&quot;transform&quot; attributeType=&quot;XML&quot; type=&quot;rotate&quot; from=&quot;0 200 200&quot; to=&quot;360 200 200&quot; begin=&quot;0s&quot; dur=&quot;5s&quot; repeatCount=&quot;indefinite&quot;\/&gt;\n  &lt;\/rect&gt;\n  &lt;line x1=&quot;400&quot; y1=&quot;200&quot; x2=&quot;0&quot; y2=&quot;200&quot; stroke=&quot;black&quot; \/&gt;\n  &lt;line x1=&quot;200&quot; y1=&quot;400&quot; x2=&quot;200&quot; y2=&quot;0&quot; stroke=&quot;black&quot; \/&gt;\n&lt;\/svg&gt;\n&lt;svg width=&quot;400&quot; height=&quot;400&quot;&gt;\n  &lt;rect width=&quot;100&quot; height=&quot;100&quot; x=&quot;150&quot; y=&quot;150&quot; fill=&quot;#29ABe2&quot; &gt;\n    &lt;animateTransform attributeName=&quot;transform&quot; attributeType=&quot;XML&quot; type=&quot;rotate&quot; from=&quot;0 200 200&quot; to=&quot;360 200 200&quot; begin=&quot;0s&quot; dur=&quot;5s&quot; repeatCount=&quot;indefinite&quot;\/&gt;\n  &lt;\/rect&gt;\n  &lt;line x1=&quot;400&quot; y1=&quot;200&quot; x2=&quot;0&quot; y2=&quot;200&quot; stroke=&quot;black&quot; \/&gt;\n  &lt;line x1=&quot;200&quot; y1=&quot;400&quot; x2=&quot;200&quot; y2=&quot;0&quot; stroke=&quot;black&quot; \/&gt;\n&lt;\/svg&gt;\n<\/pre>\n<ol>\n<li>\u9664\u4e86SMIL\u89c4\u8303\u4e2d4\u4e2a\u57fa\u672c\u7684\u52a8\u753b\u5143\u7d20\uff0c\u8fd8\u5f15\u5165\u4e86\u5176\u4ed6\u4e00\u4e9b\u6269\u5c55\u52a8\u753b\uff1a<br \/>\n<code>&lt;animateTransform&gt;<\/code>\uff1a\u4fee\u6539 SVG \u7684 transformation \u5c5e\u6027\uff08\u4f8b\u5982\uff1atransform\u5c5e\u6027\uff0ctransform \u7684 type \u53ef\u4ee5\u5305\u62ec\uff1atranslate\u3001scale\u3001skew\u7b49\uff0c\u4e0eCSS3\u76f8\u901a\uff09<br \/>\n<code>&lt;mpath&gt;<\/code>\uff1a\u5141\u8bb8 <code>&lt;animateMotion&gt;<\/code> \u5f15\u7528\u4e00\u4e2a\u5916\u90e8\u5b9a\u4e49\u7684 <code>&lt;path&gt;<\/code>\uff0c\u8ba9\u5143\u7d20\u6309\u8fd9\u4e2a <code>&lt;path&gt;<\/code> \u6765\u8fd0\u52a8<br \/>\npath \u5c5e\u6027\uff1a\u4f5c\u4e3a <code>&lt;animateMotion&gt;<\/code> \u7684\u5c5e\u6027\uff0c\u6765\u6307\u5b9a\u52a8\u753b\u8def\u5f84<br \/>\nkeyPoints \u5c5e\u6027\uff1a\u4f5c\u4e3a <code>&lt;animateMotion&gt;<\/code> \u7684\u5c5e\u6027\uff0c\u6765\u63a7\u5236\u8def\u5f84\u52a8\u753b\u7684\u901f\u5ea6<br \/>\nrotate \u5c5e\u6027\uff1a\u4f5c\u4e3a <code>&lt;animateMotion&gt;<\/code> \u7684\u5c5e\u6027\uff0c\u6765\u63a7\u56fe\u5f62\u6839\u636e\u8fd0\u52a8\u8def\u5f84\u7684\u89d2\u5ea6\uff08\u5207\u7ebf\u65b9\u5411\uff09\u6765\u6539\u53d8\u81ea\u8eab\u89d2\u5ea6<\/p>\n<\/li>\n<li>\n<p>from \u548c to\u90fd\u662f\u4e09\u4e2a\u503c\uff1a\u89d2\u5ea6\uff08\u5373\uff1a\u4ece0\u5230360\u5ea6\u7684\u65cb\u8f6c\uff09\u3001\u5750\u6807\uff08\u5373\uff1a\u8fd9\u4e2a\u5750\u6807\u51b3\u5b9a\u4e86svg\u56f4\u7ed5\u54ea\u4e2a\u70b9\u6765\u8fdb\u884c\u65cb\u8f6c\uff09<\/p>\n<\/li>\n<\/ol>\n<h2>Demo9\uff1a\u8def\u5f84\u52a8\u753b\uff0c\u8ba9\u56fe\u5f62\u6cbf\u7740\u8def\u5f84\u8fd0\u52a8<\/h2>\n<p>CSS\u4e2d\u65e0\u6cd5\u5b9e\u73b0\u7684\u8def\u5f84\u52a8\u753b\uff0c\u5728 SVG \u4e2d\u53ef\u4ee5\u8f7b\u677e\u5b9e\u73b0\u3002\u9996\u5148\u4f7f\u7528 path \u5143\u7d20\u753b\u4e00\u6761\u8def\u5f84\uff0c\u7136\u540e\u901a\u8fc7 stroke \u5c5e\u6027\u8bbe\u7f6e\u8f85\u52a9\u7ebf\u7684\u5bbd\u5ea6\u3002<\/p>\n<p><a class=\"dlBtn\" title=\"Demo9\" href=\"http:\/\/www.bluesdream.com\/case\/html\/step-by-step-to-understand-svg\/index.html#demo9\" target=\"_blank\">Demo9<\/a><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;svg width=&quot;400&quot; height=&quot;400&quot;&gt;\n  &lt;path d=&quot;M100 100, A100 100, -45 0 1, 300 300 A100 100, -45 0 1, 100 100&quot; stroke=&quot;#ccc&quot; stroke-width=&quot;2&quot; fill=&quot;none&quot;\/&gt;\n  &lt;rect width=&quot;100&quot; height=&quot;100&quot; fill=&quot;#29ABe2&quot; &gt;\n    &lt;animateMotion dur=&quot;6s&quot; repeatCount=&quot;indefinite&quot; path=&quot;M0 0, A100 100, -45 0 1, 300 300 A100 100, -45 0 1, 0 0&quot;\/&gt;\n  &lt;\/rect&gt;\n  &lt;line x1=&quot;400&quot; y1=&quot;200&quot; x2=&quot;0&quot; y2=&quot;200&quot; stroke=&quot;black&quot; \/&gt;\n  &lt;line x1=&quot;200&quot; y1=&quot;400&quot; x2=&quot;200&quot; y2=&quot;0&quot; stroke=&quot;black&quot; \/&gt;\n&lt;\/svg&gt;\n<\/pre>\n<ol>\n<li>\u5173\u4e8e SVG ARC \u8def\u5f84\uff0c\u53ef\u4ee5\u901a\u8fc7\u8be5\u6a21\u62df\u5668\u4e86\u89e3\uff1a<a href=\"http:\/\/users.ecs.soton.ac.uk\/rfp07r\/interactive-svg-examples\/\">http:\/\/users.ecs.soton.ac.uk\/rfp07r\/interactive-svg-examples\/<\/a><\/li>\n<\/ol>\n<h2>Demo10\uff1a\u8def\u5f84\u52a8\u753b\uff0c\u8ba9\u56fe\u5f62\u968f\u7740\u4f60\u7684\u8def\u5f84\u81ea\u52a8\u505a\u89d2\u5ea6\u7684\u8c03\u6574<\/h2>\n<p>\u6837\u5b50\u662f\u5b9e\u73b0\u4e86\uff0c\u4f46\u89d2\u5ea6\u65b9\u9762\u6709\u4e9b\u50f5\u786c\uff0c\u4e0d\u80fd\u968f\u7740 SVG \u8def\u5f84\u505a\u8c03\u6574\u3002\u52a0\u5165 <code>rotate=\"auto\"<\/code> \u8fd9\u4e2a\u5c5e\u6027\u4fbf\u4f1a\u8ba9\u4f60\u7684\u56fe\u5f62\u968f\u7740\u4f60\u7684\u8def\u5f84\u81ea\u52a8\u505a\u89d2\u5ea6\u7684\u8c03\u6574<\/p>\n<p><a class=\"dlBtn\" title=\"Demo10\" href=\"http:\/\/www.bluesdream.com\/case\/html\/step-by-step-to-understand-svg\/index.html#demo10\" target=\"_blank\">Demo10<\/a><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;svg width=&quot;400&quot; height=&quot;400&quot;&gt;\n  &lt;path d=&quot;M100 100, A100 100, -45 0 1, 300 300 A100 100, -45 0 1, 100 100&quot; stroke=&quot;#ccc&quot; stroke-width=&quot;2&quot; fill=&quot;none&quot;\/&gt;\n  &lt;rect width=&quot;100&quot; height=&quot;100&quot; fill=&quot;#29ABe2&quot; &gt;\n    &lt;animateMotion dur=&quot;6s&quot; repeatCount=&quot;indefinite&quot; path=&quot;M100 100, A100 100, -45 0 1, 300 300 A100 100, -45 0 1, 100 100&quot; rotate=&quot;auto&quot;\/&gt;\n  &lt;\/rect&gt;\n  &lt;line x1=&quot;400&quot; y1=&quot;200&quot; x2=&quot;0&quot; y2=&quot;200&quot; stroke=&quot;black&quot; \/&gt;\n  &lt;line x1=&quot;200&quot; y1=&quot;400&quot; x2=&quot;200&quot; y2=&quot;0&quot; stroke=&quot;black&quot; \/&gt;\n&lt;\/svg&gt;\n<\/pre>\n<ol>\n<li>rotate \u5c5e\u6027\uff1a<br \/>\n\u53d6\u503c\uff1a\"auto\" | \"auto-reverse\" | \"\u56fa\u5b9a\u6570\u503c\"<br \/>\nauto\uff1a\u6839\u636e\u8fd0\u52a8\u8def\u5f84\u7684\u89d2\u5ea6\uff08\u5207\u7ebf\u65b9\u5411\uff09\u6765\u6539\u53d8\u81ea\u8eab\u89d2\u5ea6<br \/>\nauto-reverse\uff1a\u6839\u636e auto \u505a\u4e00\u4e2a\u53cd\u8f6c\u955c\u50cf<br \/>\n\u56fa\u5b9a\u6570\u503c\uff1a \u683c\u5f0f rotate=(angle) \u548c rotate=(angle, cx, cy)\uff0c\u5176\u4e2d angle \u8868\u793a\u65cb\u8f6c\u89d2\u5ea6\uff1bcx, cy\u8868\u793a\u65cb\u8f6c\u7684\u4e2d\u5fc3\u70b9<\/li>\n<\/ol>\n<h2>Demo11\uff1a\u624b\u52a8\u64ad\u653e\u52a8\u753b<\/h2>\n<p>\u6211\u4eec\u901a\u8fc7 SMIL \u5185\u7f6e\u7684 API\uff0c\u5c31\u53ef\u4ee5\u5b9e\u73b0\u9f20\u6807\u4e8b\u4ef6\u54cd\u5e94\u3002\u9996\u5148\u6211\u4eec\u7ed9 SVG \u6dfb\u52a0\u4e00\u4e2a <code>id<\/code> \u547d\u540d\u4e3a <code>startRotation<\/code>\uff0c\u7136\u540e\u628a begin \u5c5e\u6027\u6539\u4e3a <code>begin=\"startRotation.click\"<\/code><\/p>\n<p><a class=\"dlBtn\" title=\"Demo11\" href=\"http:\/\/www.bluesdream.com\/case\/html\/step-by-step-to-understand-svg\/index.html#demo11\" target=\"_blank\">Demo11<\/a><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;svg width=&quot;400&quot; height=&quot;400&quot; id=&quot;startRotation&quot;&gt;\n  &lt;path d=&quot;M100 100, A100 100, -45 0 1, 300 300 A100 100, -45 0 1, 100 100&quot; stroke=&quot;#ccc&quot; stroke-width=&quot;2&quot; fill=&quot;none&quot;\/&gt;\n  &lt;rect width=&quot;100&quot; height=&quot;100&quot; fill=&quot;#29ABe2&quot; &gt;\n    &lt;animateMotion dur=&quot;6s&quot; repeatCount=&quot;indefinite&quot; path=&quot;M80 80, A100 100, -45 0 1, 320 320 A100 100, -45 0 1, 80 80&quot; rotate=&quot;auto&quot; begin=&quot;startRotation.click&quot;\/&gt;\n  &lt;\/rect&gt;\n  &lt;line x1=&quot;400&quot; y1=&quot;200&quot; x2=&quot;0&quot; y2=&quot;200&quot; stroke=&quot;black&quot; \/&gt;\n  &lt;line x1=&quot;200&quot; y1=&quot;400&quot; x2=&quot;200&quot; y2=&quot;0&quot; stroke=&quot;black&quot; \/&gt;\n&lt;\/svg&gt;\n<\/pre>\n<ol>\n<li>SVG\u9f20\u6807\u4e8b\u4ef6\u54cd\u5e94\u6709\u56db\u79cd\u5199\u6cd5\uff1aSMIL\u65b9\u5f0f\u3001Attributes\u65b9\u5f0f\u3001JS+SMIL\u65b9\u5f0f\u3001EventListener\u65b9\u5f0f<\/li>\n<\/ol>\n<h2>Demo12\uff1a\u5236\u4f5cLoading\u52a8\u753b<\/h2>\n<p>\u6839\u636e\u4e0a\u9762\u6240\u5b66\u4e60\u5230\u7684\u5185\u5bb9\uff0c\u505a\u4e2a\u7b80\u5355\u7684 SVG Loading \u52a8\u753b<\/p>\n<p><a class=\"dlBtn\" title=\"Demo12\" href=\"http:\/\/www.bluesdream.com\/case\/html\/step-by-step-to-understand-svg\/index.html#demo12\" target=\"_blank\">Demo12<\/a><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;svg width=&quot;400&quot; height=&quot;400&quot;&gt;\n  &lt;circle fill=&quot;none&quot; stroke=&quot;#29ABe2&quot; stroke-width=&quot;4&quot; stroke-miterlimit=&quot;10&quot; cx=&quot;200&quot; cy=&quot;200&quot; r=&quot;100&quot;&gt;&lt;\/circle&gt;\n  &lt;line fill=&quot;none&quot; stroke-linecap=&quot;round&quot; stroke=&quot;#29ABe2&quot; stroke-width=&quot;4&quot; stroke-miterlimit=&quot;10&quot; x1=&quot;200&quot; y1=&quot;200&quot; x2=&quot;280&quot; y2=&quot;200&quot;&gt;\n    &lt;animateTransform attributeName=&quot;transform&quot; dur=&quot;2s&quot; type=&quot;rotate&quot; from=&quot;0 200 200&quot; to=&quot;360 200 200&quot; repeatCount=&quot;indefinite&quot;&gt;&lt;\/animateTransform&gt;\n  &lt;\/line&gt;\n  &lt;line fill=&quot;none&quot; stroke-linecap=&quot;round&quot; stroke=&quot;#29ABe2&quot; stroke-width=&quot;4&quot; stroke-miterlimit=&quot;10&quot; x1=&quot;200&quot; y1=&quot;200&quot; x2=&quot;199.5&quot; y2=&quot;260&quot;&gt;\n    &lt;animateTransform attributeName=&quot;transform&quot; dur=&quot;15s&quot; type=&quot;rotate&quot; from=&quot;0 200 200&quot; to=&quot;360 200 200&quot; repeatCount=&quot;indefinite&quot;&gt;&lt;\/animateTransform&gt;\n  &lt;\/line&gt;\n&lt;\/svg&gt;\n<\/pre>\n<ol>\n<li>stroke \u662f SVG \u4e2d\u6709\u4e2a\u6bd4\u8f83\u91cd\u8981\u7684\u5c5e\u6027\u5206\u652f\uff0c\u7528\u6765\u5b9a\u4e49\u7ebf\u6761\u3001\u6587\u672c\u6216\u5143\u7d20\u8f6e\u5ed3\u989c\u8272\uff08\u4e5f\u53ef\u4ee5\u901a\u4fd7\u7684\u7406\u89e3\u4e3a\u201c\u63cf\u8fb9\u201d\uff09<br \/>\nstroke\uff1a       \u8868\u793a\u63cf\u8fb9\u989c\u8272\u3002<br \/>\nstroke-width\uff1a    \u8868\u793a\u63cf\u8fb9\u7684\u7c97\u7ec6\u3002<br \/>\nstroke-linecap\uff1a   \u8868\u793a\u63cf\u8fb9\u7aef\u70b9\u8868\u73b0\u65b9\u5f0f\u3002\u53ef\u7528\u503c\u6709\uff1abutt, round, square, inherit<br \/>\nstroke-linejoin\uff1a   \u8868\u793a\u63cf\u8fb9\u8f6c\u89d2\u7684\u8868\u73b0\u65b9\u5f0f\u3002\u53ef\u7528\u503c\u6709\uff1amiter, round, bevel, inherit<br \/>\nstroke-miterlimit\uff1a \u8868\u793a\u63cf\u8fb9\u76f8\u4ea4\uff08\u9510\u89d2\uff09\u7684\u8868\u73b0\u65b9\u5f0f\u3002\u9ed8\u8ba4\u5927\u5c0f\u662f4\u3002\u5b9a\u4e49\u4e86\u4e24\u6761\u76f8\u4ea4\u6210\u4e00\u5b9a\u89d2\u7684\u7ebf\u5728\u8fde\u63a5\u5904\u7684\u5706\u6ed1\u7a0b\u5ea6\u3002<br \/>\nstroke-dasharray\uff1a  \u8868\u793a\u865a\u7ebf\u63cf\u8fb9\u3002\u53ef\u9009\u503c\u4e3a\uff1anone, <code>&lt;dasharray&gt;<\/code>, inherit.<br \/>\n        none\uff1a\u8868\u793a\u4e0d\u662f\u865a\u7ebf\uff1b<br \/>\n        <dasharray>\uff1a\u4e3a\u4e00\u4e2a\u9017\u53f7\u6216\u7a7a\u683c\u5206\u9694\u7684\u6570\u503c\u5217\u8868\u3002\u8868\u793a\u5404\u4e2a\u865a\u7ebf\u7aef\u7684\u957f\u5ea6\u3002\u53ef\u4ee5\u662f\u56fa\u5b9a\u7684\u957f\u5ea6\u503c\uff0c\u4e5f\u53ef\u4ee5\u662f\u767e\u5206\u6bd4\u503c\uff1b<br \/>\n        inherit\uff1a\u8868\u7ee7\u627f\u3002<br \/>\nstroke-dashoffset\uff1a  \u8868\u793a\u865a\u7ebf\u7684\u8d77\u59cb\u504f\u79fb\u3002\u53ef\u9009\u503c\u4e3a\uff1a<code>&lt;percentage&gt;<\/code>, <code>&lt;length&gt;<\/code>, inherit. \u767e\u5206\u6bd4\u503c\uff0c\u957f\u5ea6\u503c\uff0c\u7ee7\u627f\u3002<br \/>\nstroke-opacity\uff1a   \u8868\u793a\u63cf\u8fb9\u900f\u660e\u5ea6\u3002\u9ed8\u8ba4\u662f1\uff08\u5408\u6cd5\u7684\u8303\u56f4\u662f\uff1a0 - 1\uff09<\/li>\n<\/ol>\n<h2>Demo13\uff1a\u52a8\u753b\u7684\u6682\u505c\u4e0e\u64ad\u653e<\/h2>\n<p>\u4e4b\u524d\u6211\u4eec\u53ea\u662f\u5355\u7eaf\u7684\u5b9e\u73b0\u4e86\u52a8\u753b\u7684\u64ad\u653e\uff0c\u90a3\u600e\u4e48\u5b9e\u73b0\u52a8\u753b\u7684\u6682\u505c\u548c\u64ad\u653e\uff1f\u6b64\u65f6\u5c31\u9700\u8981\u914d\u5408JS\u6765\u8fbe\u5230\u6211\u4eec\u6240\u60f3\u8981\u7684\u6548\u679c<\/p>\n<p><a class=\"dlBtn\" title=\"Demo13\" href=\"http:\/\/www.bluesdream.com\/case\/html\/step-by-step-to-understand-svg\/index.html#demo13\" target=\"_blank\">Demo13<\/a><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;svg width=&quot;400&quot; height=&quot;400&quot; onclick=&quot;if (this.paused != true) { this.pauseAnimations(); this.paused = true; } else  { this.unpauseAnimations(); this.paused = false; }&quot;&gt;\n  &lt;circle fill=&quot;none&quot; stroke=&quot;#29ABe2&quot; stroke-width=&quot;4&quot; stroke-miterlimit=&quot;10&quot; cx=&quot;200&quot; cy=&quot;200&quot; r=&quot;100&quot;&gt;&lt;\/circle&gt;\n  &lt;line fill=&quot;none&quot; stroke-linecap=&quot;round&quot; stroke=&quot;#29ABe2&quot; stroke-width=&quot;4&quot; stroke-miterlimit=&quot;10&quot; x1=&quot;200&quot; y1=&quot;200&quot; x2=&quot;280&quot; y2=&quot;200&quot;&gt;\n    &lt;animateTransform attributeName=&quot;transform&quot; dur=&quot;2s&quot; type=&quot;rotate&quot; from=&quot;0 200 200&quot; to=&quot;360 200 200&quot; repeatCount=&quot;indefinite&quot;&gt;&lt;\/animateTransform&gt;\n  &lt;\/line&gt;\n  &lt;line fill=&quot;none&quot; stroke-linecap=&quot;round&quot; stroke=&quot;#29ABe2&quot; stroke-width=&quot;4&quot; stroke-miterlimit=&quot;10&quot; x1=&quot;200&quot; y1=&quot;200&quot; x2=&quot;199.5&quot; y2=&quot;260&quot;&gt;\n    &lt;animateTransform attributeName=&quot;transform&quot; dur=&quot;15s&quot; type=&quot;rotate&quot; from=&quot;0 200 200&quot; to=&quot;360 200 200&quot; repeatCount=&quot;indefinite&quot;&gt;&lt;\/animateTransform&gt;\n  &lt;\/line&gt;\n&lt;\/svg&gt;\n<\/pre>\n<ol>\n<li>\u6682\u505c\uff1asvg.pauseAnimations(); \u64ad\u653e\uff1asvg.unpauseAnimations(); \u8fd9\u91cc\u7684 svg \u6307\u7684\u662f\u5f53\u524d\u7684 SVG DOM \u5143\u7d20\u3002<\/li>\n<\/ol>\n<blockquote><p>\n  \u4e0a\u9762\u7684\u52a8\u753b\u6548\u679c\u90fd\u662f\u4f7f\u7528 SVG Animations(SMIL) \u6765\u5b9e\u73b0\u7684\u3002<br \/>\n  \u4e0d\u8fc7\u7ec6\u5fc3\u7684\u4f60\u53ef\u80fd\u5df2\u7ecf\u53d1\u73b0\u5728 Chrome \u4e0b\u8fd0\u884c\uff0c\u63a7\u5236\u53f0\u4f1a\u63d0\u793a\u9519\u8bef\u4fe1\u606f<code>\uff08SVG's SMIL animations (&lt;\\animate&gt;, &lt;\\set&gt;, etc.) are deprecated and will be removed. Please use CSS animations or Web animations instead.\uff09<\/code>\u3002\u8fd9\u662f\u7531\u4e8e\u81ea <code>Chrome 45 \u548c Opera 32 \u7248\u672c\u5f00\u59cb\uff0c\u5c31\u51c6\u5907\u5c06 SVG SMIL \u52a8\u753b\u5f03\u7528<\/code>\uff0c\u4ece\u800c\u4f7f\u7528 <code>CSS animations<\/code> \u548c <code>Web Animations API<\/code> \u6765\u66ff\u4ee3\u3002\u4e0d\u8fc7\u5c31\u76ee\u524d\u6765\u770b Web Animations API \u7684\u517c\u5bb9\u6027\u8fd8\u4e0d\u592a\u7406\u60f3\uff0c\u4f46\u4e5f\u8bf4\u660e\u4e86\u8fd9\u662f\u672a\u6765\u7684\u4e00\u4e2a\u5fc5\u7136\u8d8b\u52bf\u3002\u5bf9\u8fd9\u65b9\u4fbf\u5185\u5bb9\u6709\u7684\u5174\u8da3\u7684\u8bdd\uff0c\u53ef\u4ee5\u81ea\u5df1\u591a\u4e86\u89e3\u4e00\u4e9b\u3002\n<\/p><\/blockquote>\n<p>\u53c2\u8003\u8d44\u6599\uff1a<br \/>\n<a href=\"https:\/\/www.chengrang.com\/svg-animate.html\">https:\/\/www.chengrang.com\/svg-animate.html<\/a><br \/>\n<a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/2014\/08\/so-powerful-svg-smil-animation\/\">http:\/\/www.zhangxinxu.com\/wordpress\/2014\/08\/so-powerful-svg-smil-animation\/<\/a><br \/>\n<a href=\"https:\/\/www.ibm.com\/developerworks\/cn\/web\/wa-scalable\/\">https:\/\/www.ibm.com\/developerworks\/cn\/web\/wa-scalable\/<\/a><br \/>\n<a href=\"http:\/\/editor.method.ac\/\">http:\/\/editor.method.ac\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u770b\u5230\u7bc7\u6587\u7ae0\u5f88\u6709\u540c\u611f\uff0c\u5f88\u591a\u65f6\u5019\u60f3\u5b66\u4e60\u4e00\u4e9b\u4e1c\u897f\uff0c\u4f1a\u88ab\u4e00\u5806\u5806\u7684\u4ee3\u7801\u6240\u56f0\u6270\uff0c\u5f88\u96be\u53bb\u8bfb\u61c2\u548c\u7406\u89e3\u3002\u800c\u7528\u4e00\u4e2a\u4e2a\u5c0fDemo\u7684\u5f62\u5f0f\u4e86\u89e3\u8d77\u6765\u5c31\u66f4\u4e3a\u76f4\u89c2\uff0c\u4ea7\u751f\u5174\u8da3\u4e4b\u540e\u5b66\u8d77\u4e1c\u897f\u5c31\u81ea\u7136\u76f8\u5bf9\u8f7b\u677e\u3002 Demo1\uff1a\u521b\u5efa\u57fa\u672c\u5f62\u72b6 SVG \u9884\u5b9a\u4e49\u4e867\u4e2a\u57fa\u672c\u5143\u7d20\uff1acircle \u521b\u5efa\u5706\u5f62\u3001rect \u521b\u5efa\u77e9\u5f62\u3001ellipse \u521b\u5efa\u692d\u5706\u3001line \u521b\u5efa\u7ebf\u6761\u3001polyline \u521b\u5efa\u6298\u7ebf\u3001polygon \u521b\u5efa\u591a\u8fb9\u5f62\u3001path \u521b\u5efa\u8def\u5f84\u3002 \u5176\u4e2d path \u53ef\u8fdb\u884c\u586b\u5145\u3001\u52fe\u5212\uff08\u6cbf\u7740\u8def\u5f84\u7ed8\u5236\u76f4\u7ebf\uff09\uff0c\u4e5f\u53ef\u7528\u4f5c\u526a\u5207\u8def\u5f84\uff08\u5176\u4ed6\u5f62\u72b6\u7684\u56fe\u6837\uff09\uff0c\u662f\u6240\u6709\u7ed8\u56fe\u5143\u7d20\u4e2d\u6700\u590d\u6742\u7684\u3002<\/p>\n","protected":false},"author":1,"featured_media":833,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[75],"tags":[153,154,155],"class_list":["post-831","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-front-end","tag-svg","tag-svg-animations","tag-svg-smil"],"_links":{"self":[{"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/posts\/831"}],"collection":[{"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/comments?post=831"}],"version-history":[{"count":0,"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/posts\/831\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/media\/833"}],"wp:attachment":[{"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/media?parent=831"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/categories?post=831"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/tags?post=831"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}