2013-03-07 48 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