svnno****@sourc*****
svnno****@sourc*****
2010年 3月 21日 (日) 23:12:50 JST
Revision: 1744 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1744 Author: dhrname Date: 2010-03-21 23:12:50 +0900 (Sun, 21 Mar 2010) Log Message: ----------- Modified Paths: -------------- branches/ufltima/dom/svg.js Modified: branches/ufltima/dom/svg.js =================================================================== --- branches/ufltima/dom/svg.js 2010-03-20 11:45:26 UTC (rev 1743) +++ branches/ufltima/dom/svg.js 2010-03-21 14:12:50 UTC (rev 1744) @@ -530,9 +530,9 @@ }); } var s = rgbColor.match(/\d+/g); - this.rgbColor.r.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(s[0])); - this.rgbColor.g.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(s[1])); - this.rgbColor.b.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(s[2])); + this.rgbColor.red.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(s[0])); + this.rgbColor.green.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(s[1])); + this.rgbColor.blue.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(s[2])); }; // raises( SVGException ); @@ -1975,6 +1975,81 @@ var w = vi.width, h = vi.hight; tar._tar.path = dat + " e"; tar._tar.coordsize = w + " " + h; + var style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""); + var _urlreg = /url\(#([^)]+)/, isNone = { + none: 1 + }; + var el = tar._tar, fill = style.getPropertyCSSValue("fill"), stroke = style.getPropertyCSSValue("stroke"); + if (isNone[fill.cssText]) { + el.filled = "false"; + } else { + var fillElement = document.createElement("v:fill"); + var isRadial = false; + try { + if (_urlreg.test(fill.cssText)) { //fill属性の値がurl(#id)ならば、idを設定したグラデーション関連要素を呼び出す + } else { + fill.setColor(SVGColor.SVG_COLORTYPE_RGBCOLOR, fill.cssText, null); + var fc = fill.rgbColor; + fillElement.setAttribute("color", "rgb(" +fc.red.getFloatValue()+ "," +fc.green.getFloatValue()+ "," +fc.blue.getFloatValue()+ ")"); + var fillOpacity = parseFloat(style.getProperty("fill-opacity")) * parseFloat(style.getProperty("opacity")); //opacityを掛け合わせる + if (fillOpacity < 1) { + fillElement.setAttribute("opacity", fillOpacity+""); + } + } + } catch(e) {stlog.add(e,682); fillElement.on = "true"; + fillElement.color = "black";} + if (!isRadial) { + el.appendChild(fillElement); + } + isRadial = fillOpacity = null; + } + if (isNone[stroke]) { + el.stroked = "false"; + } else { + var strokeElement = document.createElement("v:stroke"); + var sw = tar.ownerDocument.documentElement.createSVGLength(parseFloat(style.getProperty("stroke-width")));//, Math.sqrt((w*w + h*h) / 2)); + var swx = sw.value * Math.sqrt(Math.abs(matrix.determinant())); + strokeElement.setAttribute("weight", swx + "px"); + if (!_urlreg.test(stroke.cssText)) { + strokeElement.setAttribute("color", style.color(style.stroke)); + var strokeOpacity = style.strokeopacity * style.opacity; //opacityを掛け合わせる + if (swx < 1) { + strokeOpacity *= swx; //太さが1px未満なら色を薄くする + } + if (strokeOpacity < 1) { + strokeElement.setAttribute("opacity", strokeOpacity); + } + strokeOpacity = null; + } + strokeElement.setAttribute("miterlimit", style.strokemiterlimit); + strokeElement.setAttribute("joinstyle", style.strokelinejoin); + if (style.strokelinecap === "butt") { + strokeElement.setAttribute("endcap", "flat"); + } else { + strokeElement.setAttribute("endcap", style.strokelinecap); + } + var tsd = style.getPropertyValue("stroke-dasharray"); + if (!isNone[tsd]) { + if (tsd.indexOf(",") > 0) { //コンマ区切りの文字列の場合 + var strs = tsd.split(","); + for (var i = 0, sli = strs.length; i < sli; ++i) { + strs[i] = Math.ceil(parseFloat(strs[i]) / parseFloat(style.strokewidth)); //精密ではないので注意 + } + style.strokedasharray = strs.join(" "); + if (strs.length % 2 === 1) { + style.strokedasharray += " " + style.strokedasharray; + } + } + strokeElement.setAttribute("dashstyle", style.strokedasharray); + tsd = strs = null; + } + el.appendChild(strokeElement); + sw = tsd = null; + } + if (style.cursor !== "default") { + el.style.cursor = style.cursor; + } + w = h = null; matrix = dat = x = y = null; }, false); }, false);