ttm*_*tmt 10 css svg css-shapes
我这里有一个jsfiddle - http://jsfiddle.net/apbuc773/
我想用svg创建一个明星.
我想打动明星的外面.在我的例子中,笔划在每条线上,解剖内部形状.
也可以半满星形.
我想用它来获得星级评分,但我需要一半,也许四分之一的填充.
<svg height="210" width="500">
<polygon points="100,10 40,198 190,78 10,78 160,198" style="fill:red;stroke:blue;"/>
</svg>
Run Code Online (Sandbox Code Playgroud)
这是一个例子:http://jsfiddle.net/apbuc773/11/
渐变可以像这样使用:
<svg height="210" width="500">
<defs>
<linearGradient id="half">
<stop offset="0%" stop-color="red" />
<stop offset="50%" stop-color="red" />
<stop offset="50%" stop-color="white" />
<stop offset="100%" stop-color="white" />
</linearGradient>
</defs>
<g fill="url(#half)" stroke="blue" stroke-width="2">
Run Code Online (Sandbox Code Playgroud)
如果您不想更改多边形点,只需应用此多边形两次:一次使用笔划,一次不使用.
您也可以使用过滤器执行此操作.这是一个动画填充:
<svg height="210" width="500">
<defs>
<filter id="fillpartial" primitiveUnits="objectBoundingBox" x="0%" y="0%" width="100%" height="100%">
<feFlood x="0%" y="0%" width="100%" height="100%" flood-color="red" />
<feOffset dy="0.5">
<animate attributeName="dy" from="1" to=".5" dur="3s" />
</feOffset>
<feComposite operator="in" in2="SourceGraphic" />
<feComposite operator="over" in2="SourceGraphic" />
</filter>
</defs>
<polygon filter="url(#fillpartial)" points="165.000, 185.000, 188.511, 197.361, 184.021, 171.180,
203.042, 152.639,
176.756, 148.820,
165.000, 125.000,
153.244, 148.820,
126.958, 152.639,
145.979, 171.180,
141.489, 197.361,
165.000, 185.000" style="fill:white;stroke:red;" />
</svg>Run Code Online (Sandbox Code Playgroud)