svnno****@sourc*****
svnno****@sourc*****
2010年 5月 27日 (木) 23:33:52 JST
Revision: 1848 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1848 Author: dhrname Date: 2010-05-27 23:33:52 +0900 (Thu, 27 May 2010) Log Message: ----------- 1, SVGColorオブジェクトのsetRGBColorメソッドの修正 2, NAIBU.setPaintにおいて、stroke-widthプロパティを、%でも対処できるよう修正した Modified Paths: -------------- branches/ufltima/dom/svg.js Modified: branches/ufltima/dom/svg.js =================================================================== --- branches/ufltima/dom/svg.js 2010-05-27 14:31:33 UTC (rev 1847) +++ branches/ufltima/dom/svg.js 2010-05-27 14:33:52 UTC (rev 1848) @@ -571,9 +571,9 @@ }); } var s = rgbColor.match(/\d+/g); - 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])); + this.rgbColor.red.cssText = s[0]; + this.rgbColor.green.cssText = s[1]; + this.rgbColor.blue.cssText = s[2]; }; // raises( SVGException ); @@ -1844,7 +1844,8 @@ /*以下では、スタイルシートを用いて、fill-とstroke-関連の *処理を行う。SVGPaintインターフェースをも用いる */ - var style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""); + var tod = tar.ownerDocument; + var style = tod.defaultView.getComputedStyle(tar, ""); var el = tar._tar, fill = style.getPropertyCSSValue("fill"), stroke = style.getPropertyCSSValue("stroke"); if (fill.paintType === SVGPaint.SVG_PAINTTYPE_RGBCOLOR || fill.paintType === SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR) { var fillElement = !!tar._fillElement ? tar._fillElement : document.createElement("v:fill"); @@ -1863,9 +1864,9 @@ /*以下では、Gradation関連の要素に、イベントを渡すことで、 *この要素の、グラデーション描画を行う */ - var t = tar.ownerDocument.getElementById(fill.uri); + var t = tod.getElementById(fill.uri); if (t) { - var evtt = tar.ownerDocument.createEvent("MutationEvents"); + var evtt = tod.createEvent("MutationEvents"); evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null); evtt._tar = !!tar._fillElement ? tar._fillElement : document.createElement("v:fill"); evtt._style = style, evtt._ttar = tar; @@ -1881,10 +1882,11 @@ } if (stroke.paintType === SVGPaint.SVG_PAINTTYPE_RGBCOLOR || stroke.paintType === SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR) { var strokeElement = !!tar._strokeElement ? tar._strokeElement : document.createElement("v:stroke"); - var sw = tar.ownerDocument.documentElement.createSVGLength(); - sw.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_NUMBER, parseFloat(style.getPropertyValue("stroke-width"))); - var swx = sw.value * Math.sqrt(Math.abs(matrix._determinant())); + var sgsw = style.getPropertyCSSValue("stroke-width"), w = tod.documentElement.viewport.width, h = tod.documentElement.viewport.height; + sgsw._percent = Math.sqrt((w*w + h*h) / 2); + var swx = sgsw.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) * Math.sqrt(Math.abs(matrix._determinant())); strokeElement.setAttribute("weight", swx + "px"); + sgsw = w = h = null; if (!stroke.uri) { var fc = stroke.rgbColor, num = CSSPrimitiveValue.CSS_NUMBER; strokeElement.setAttribute("color", "rgb(" +fc.red.getFloatValue(num)+ "," +fc.green.getFloatValue(num)+ "," +fc.blue.getFloatValue(num)+ ")"); @@ -1923,7 +1925,7 @@ el.appendChild(strokeElement); tar._strokeElement = strokeElement; } - sw = tsd = null; + tsd = null; } else { el.stroked = "false"; }