svnno****@sourc*****
svnno****@sourc*****
2010年 1月 10日 (日) 22:39:36 JST
Revision: 1565 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1565 Author: dhrname Date: 2010-01-10 22:39:36 +0900 (Sun, 10 Jan 2010) Log Message: ----------- NAIBU.PaintColorオブジェクトの整理 Modified Paths: -------------- branches/05x/058/sie.js Modified: branches/05x/058/sie.js =================================================================== --- branches/05x/058/sie.js 2010-01-10 12:56:09 UTC (rev 1564) +++ branches/05x/058/sie.js 2010-01-10 13:39:36 UTC (rev 1565) @@ -1133,10 +1133,12 @@ var element = this.tar; var style = element.style[name]; if (style) { + name = null; return style; } var attribute = element.attributes[name]; var s = attribute ? attribute.nodeValue : null; + name = null; return s; } catch(e) {stlog.add(e,659); return null;} }; @@ -1375,6 +1377,10 @@ } return color; }; +NAIBU._Percent = /%/; +NAIBU.PaintColor.prototype.toNumber = function( /*string*/ coord) { + return parseFloat(coord.replace(NAIBU._Percent, "")); +} //linearGradient、radialGradient要素を処理 NAIBU.PaintColor.prototype.gradient = function( /*element*/ ele, /*string*/ id, /*Matrix*/ matrix) { var grad = document.getElementById(id); @@ -1404,14 +1410,14 @@ // When colors attribute is used, the meanings of opacity and o:opacity2 are reversed. ele.setAttribute("opacity", opacity[length-1]); ele.setAttribute("o:opacity2", opacity[0]); - var type = grad.getAttribute("type"); + var type = grad.getAttribute("type"), toNumber = this.toNumber; if (type === "gradient") { try { var angle; - var x1 = parseFloat((grad.getAttribute("x1") || "0").replace(/%/, "")); - var y1 = parseFloat((grad.getAttribute("y1") || "0").replace(/%/, "")); - var x2 = parseFloat((grad.getAttribute("x2") || "100").replace(/%/, "")); - var y2 = parseFloat((grad.getAttribute("y2") || "0").replace(/%/, "")); + var x1 = toNumber((grad.getAttribute("x1") || "0")); + var y1 = toNumber((grad.getAttribute("y1") || "0")); + var x2 = toNumber((grad.getAttribute("x2") || "100")); + var y2 = toNumber((grad.getAttribute("y2") || "0")); angle = 270 - Math.atan2(y2-y1, x2-x1) * 180 / Math.PI; if (angle >= 360) { angle -= 360; @@ -1426,53 +1432,53 @@ ele.setAttribute("focus", "100%"); ele.setAttribute("focusposition", "0.5 0.5"); if (this.tar.getAttribute("tag") === "rect") { - var cx = parseFloat((grad.getAttribute("cx") || "0.5").replace(/%/, "")); - var cy = parseFloat((grad.getAttribute("cy") || "0.5").replace(/%/, "")); - var r = rx = ry = parseFloat((grad.getAttribute("r") || "0.5").replace(/%/, "")); - var el = this.w, et = this.h, er = 0, eb = 0; - var data = this.tar.path.value; - var units = grad.getAttribute("gradientUnits"); - if (!units || units === "objectBoundingBox") { - //%の場合は小数点に変換(10% -> 0.1) - cx = cx > 1 ? cx/100 : cx; cy = cy > 1 ? cy/100 : cy; r = r > 1 ? r/100 : r; - //要素の境界領域を求める(四隅の座標を求める) - var degis = data.match(/[0-9\-]+/g); - for (var i=0,degisli=degis.length;i<degisli;i+=2) { - var nx = parseInt(degis[i]), ny = parseInt(degis[i+1]); - el = el > nx ? nx : el; - et = et > ny ? ny : et; - er = er > nx ? er : nx; - eb = eb > ny ? eb : ny; nx = ny = null; + var cx = toNumber((grad.getAttribute("cx") || "0.5")); + var cy = toNumber((grad.getAttribute("cy") || "0.5")); + var r = rx = ry = toNumber((grad.getAttribute("r") || "0.5")); + var el = this.w, et = this.h, er = 0, eb = 0; + var data = this.tar.path.value; + var units = grad.getAttribute("gradientUnits"); + if (!units || units === "objectBoundingBox") { + //%の場合は小数点に変換(10% -> 0.1) + cx = cx > 1 ? cx/100 : cx; cy = cy > 1 ? cy/100 : cy; r = r > 1 ? r/100 : r; + //要素の境界領域を求める(四隅の座標を求める) + var degis = data.match(/[0-9\-]+/g); + for (var i=0,degisli=degis.length;i<degisli;i+=2) { + var nx = parseInt(degis[i]), ny = parseInt(degis[i+1]); + el = el > nx ? nx : el; + et = et > ny ? ny : et; + er = er > nx ? er : nx; + eb = eb > ny ? eb : ny; nx = ny = null; + } + degis = null; + cx = cx*(er - el) + el; cy = cy*(eb - et) + et; rx = r*(er - el); ry = r*(eb - et); } - degis = null; - cx = cx*(er - el) + el; cy = cy*(eb - et) + et; rx = r*(er - el); ry = r*(eb - et); - } - var gt = grad.getAttribute("gradientTransform"); - if (gt) { - grad.setAttribute("transform",gt); - matrix = NAIBU.transformToCTM(grad, matrix); - } - el = cx - rx; et = cy - ry; er = cx + rx; eb = cy + ry; - var rrx = rx * 0.55228, rry = ry * 0.55228; - var list = ["m", cx,et, "c", cx-rrx,et, el,cy-rry, el,cy, el,cy+rry, cx-rrx,eb, cx,eb, cx+rrx,eb, er,cy+rry, er,cy, er,cy-rry, cx+rrx,et, cx,et, "x e"]; - var pl = new PList(list); - var plm = pl.matrixTransform(matrix); - var ellipse = plm.list.join(" "); - var outline = document.getElementById("_NAIBU_outline"); - var background = document.createElement("div"), bstyle = background.style; - bstyle.position = "absolute"; - bstyle.textAlign = "left"; bstyle.top = "0px"; bstyle.left = "0px"; bstyle.width = this.w+ "px"; bstyle.height = this.h+ "px"; - outline.appendChild(background); - bstyle.filter = "progid:DXImageTransform.Microsoft.Compositor"; - background.filters.item('DXImageTransform.Microsoft.Compositor').Function = 23; - var circle = '<v:shape style="position:relative; antialias:false; top:0px; left:0px;" coordsize="' +this.w+ ' ' +this.h+ '" path="' +ellipse+ '" stroked="f">' +ele.outerHTML+ '</v:shape>'; - background.innerHTML = '<v:shape style="position:relative; top:0px; left:0px;" coordsize="' +this.w+ ' ' +this.h+ '" path="' +data+ '" stroked="f" fillcolor="' +color[color.length-1]+ '" ></v:shape>'; - background.filters[0].apply(); - background.innerHTML = circle; - background.filters[0].play(); - this.tar.parentNode.insertBefore(background, this.tar); - this.tar.filled = "false"; - ellipse = circle = data = list = pl = plm = gt = cx = cy = r = null; + var gt = grad.getAttribute("gradientTransform"); + if (gt) { + grad.setAttribute("transform",gt); + matrix = NAIBU.transformToCTM(grad, matrix); + } + el = cx - rx; et = cy - ry; er = cx + rx; eb = cy + ry; + var rrx = rx * 0.55228, rry = ry * 0.55228; + var list = ["m", cx,et, "c", cx-rrx,et, el,cy-rry, el,cy, el,cy+rry, cx-rrx,eb, cx,eb, cx+rrx,eb, er,cy+rry, er,cy, er,cy-rry, cx+rrx,et, cx,et, "x e"]; + var pl = new PList(list); + var plm = pl.matrixTransform(matrix); + var ellipse = plm.list.join(" "); + var outline = document.getElementById("_NAIBU_outline"); + var background = document.createElement("div"), bstyle = background.style; + bstyle.position = "absolute"; + bstyle.textAlign = "left"; bstyle.top = "0px"; bstyle.left = "0px"; bstyle.width = this.w+ "px"; bstyle.height = this.h+ "px"; + outline.appendChild(background); + bstyle.filter = "progid:DXImageTransform.Microsoft.Compositor"; + background.filters.item('DXImageTransform.Microsoft.Compositor').Function = 23; + var circle = '<v:shape style="position:relative; antialias:false; top:0px; left:0px;" coordsize="' +this.w+ ' ' +this.h+ '" path="' +ellipse+ '" stroked="f">' +ele.outerHTML+ '</v:shape>'; + background.innerHTML = '<v:shape style="position:relative; top:0px; left:0px;" coordsize="' +this.w+ ' ' +this.h+ '" path="' +data+ '" stroked="f" fillcolor="' +color[color.length-1]+ '" ></v:shape>'; + background.filters[0].apply(); + background.innerHTML = circle; + background.filters[0].play(); + this.tar.parentNode.insertBefore(background, this.tar); + this.tar.filled = "false"; + ellipse = circle = data = list = pl = plm = gt = cx = cy = r = null; } else { return false; }