svnno****@sourc*****
svnno****@sourc*****
2009年 10月 5日 (月) 22:43:16 JST
Revision: 1313 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1313 Author: dhrname Date: 2009-10-05 22:43:16 +0900 (Mon, 05 Oct 2009) Log Message: ----------- SVGRectElementのsetメソッドを実装開始 Modified Paths: -------------- branches/DOM/org/w3c/dom/svg.js Modified: branches/DOM/org/w3c/dom/svg.js =================================================================== --- branches/DOM/org/w3c/dom/svg.js 2009-10-04 12:47:28 UTC (rev 1312) +++ branches/DOM/org/w3c/dom/svg.js 2009-10-05 13:43:16 UTC (rev 1313) @@ -2642,7 +2642,6 @@ SVGPathElement.prototype.read = function(){ this.d = this.getNamedItemNS(null, "d"); }; - SVGPathElement.prototype.set = function( /*float*/ w, /*float*/ h) { var dat = ""; try { @@ -2898,7 +2897,56 @@ }; SVGRectElement.constructor = SVGElement; SVGRectElement.prototype = new SVGElement(); +SVGRectElement.prototype.read = function( /*element*/ rect, /*Matrix*/ matrix, /*float*/ w, h) { + this.tar = rect; + try { + this.x.animVal = newValueSpecified((this.getNamedItem(null, "x") || 0), w); + this.y = new STLength((rect.getAttribute("y") || 0), h); + this.width = new STLength(rect.getAttribute("svgwidth"), w); + this.height = new STLength(rect.getAttribute("svgheight"), h); + var rx = rect.getAttribute("rx"), ry = rect.getAttribute("ry"); + if (rx || ry) { + this.rx = new STLength((rx || ry), w); + this.ry = new STLength((ry || rx), h); + if (this.rx.value > this.width.value / 2) { //rx属性が幅より大きければ、幅の半分を属性に設定 + this.rx.value = this.width.value / 2; + } + if (this.ry.value > this.height.value / 2) { + this.ry.value = this.height.value / 2; + } + } + this.paint = new NAIBU.PaintColor(rect); + this.transformable = NAIBU.transformToCTM(rect,matrix); + w = h = rx = ry = null; + } catch(ee) {stlog.add(ee,545);} + return this; +} +SVGRectElement.prototype.set = function rectset(w,h) { + try { + var x = this.x.value, y = this.y.value, xw = x + this.width.value, yh = y + this.height.value; + var list; + if (this.rx) { + var rx = this.rx.value, ry = this.ry.value; + var rrx = rx * 0.55228, rry = ry * 0.55228; + var a = xw - rx, b = x + rx, c = y + ry, d = yh - ry; + list = ["m",b,y, "l",a,y, "c",a+rrx,y,xw,c-rry,xw,c, "l",xw,d, "c",xw,d+rry,a+rrx,yh,a,yh, "l",b,yh, "c",b-rrx,yh,x,d+rry,x,d, "l",x,c, "c",x,c-rry,b-rrx,y,b,y]; + } else { + list = ["m",x,y, "l",x,yh, xw,yh, xw,y, "x e"]; + } + var ttm = this.getCTM(); + var pl = new PList(list); + var plm = pl.matrixTransform(ttm); + var dat = plm.list.join(" "); + } catch(e) {stlog.add(e,564);} + try { + var ele = this.tar; + ele.path = dat; + ele.coordsize = w + " " + h; + dat = list = pl = plm = ttm = this.transformable = w = h = null; //解放 + } catch(ee) {stlog.add(ee,576);} +} + function SVGCircleElement() { SVGElement.apply(this, arguments); /*readonly SVGAnimatedLength*/ this.cx = new SVGAnimatedLength(0);