2013-03-07 36 views
0

假设我有一个SVG文件,我想将它作为一个Ext.draw.Component,如何让我的SVG stop-opacity转换为Ext.draw.Component项目?将SVG转换为Ext.draw.Component渐变

例如,从SVG文件,我会像这样:

<linearGradient ="linearGradient2920"> 
    <stop 
    id="stop2922" 
    style="stop-color:#000000;stop-opacity:1" 
    offset="0" /> 
    <stop 
    id="stop2924" 
    style="stop-color:#000000;stop-opacity:0" 
    offset="1" /> 
</linearGradient> 

会是什么样子在Ext.draw.Component什么?它会这样翻译吗?

gradients: [{ 
      { 
      id: 'linearGradient2920', 
      angle: 100, 
      stops: { 
       0: { 
        color: '#000000', 
        opacity: 100 //<---Is this even valid?? 
       }, 
       100: { 
        color: '#000000', 
        opactiy: 0 //<---Is this even valid?? 
       } 
      } 
     }] 

回答

0

我刚刚发现这个在Ext.js源代码SVG - http://docs.sencha.com/ext-js/4-1/source/Svg.html

for (i = 0; i < ln; i++) { 
      stop = gradient.stops[i]; 
      stopEl = me.createSvgElement("stop"); 
      stopEl.setAttribute("offset", stop.offset + "%"); 
      stopEl.setAttribute("stop-color", stop.color); 
      stopEl.setAttribute("stop-opacity",stop.opacity); 
      gradientEl.appendChild(stopEl); 
     } 

注意stop.opacity。这似乎表明它应该是有效的,像在原始文章中使用不透明度,但我不确定它是否在1.0或100的比例。

+0

stop-opacity是0..1或0%.. 100%,请参阅规格:http://www.w3.org/TR/SVG11/pservers.html#StopOpacityProperty – 2013-03-07 09:50:01