[Sie-announce] SIEコード [1569] NAIBU. PaintColorオブジェクトの整理

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 1月 12日 (火) 21:43:44 JST


Revision: 1569
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1569
Author:   dhrname
Date:     2010-01-12 21:43:44 +0900 (Tue, 12 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-12 12:21:19 UTC (rev 1568)
+++ branches/05x/058/sie.js	2010-01-12 12:43:44 UTC (rev 1569)
@@ -1153,16 +1153,20 @@
     }
   } catch(e) {stlog.add(e,899); return "";}
 };
-NAIBU.PaintColor.prototype._urlreg = /url\(#([^)]+)/;
+(function(){
+  var _urlreg = /url\(#([^)]+)/,
+    isNone = {
+      none: 1
+    };
 NAIBU.PaintColor.prototype.set = function(/*float*/ w, /*float*/ h, /*Matrix*/ matrix) {
   var el = this.tar;
-  if (this.fill === "none") {
+  if (isNone[this.fill]) {
     el.filled = "false";
   } else {
     var fillElement = document.createElement("v:fill");
     var isRadial = false;
     try {
-    if (this._urlreg.test(this.fill)) { //fill属性の値がurl(#id)ならば、idを設定したグラデーション関連要素を呼び出す
+    if (_urlreg.test(this.fill)) { //fill属性の値がurl(#id)ならば、idを設定したグラデーション関連要素を呼び出す
       this.w = w; this.h = h; //radialGradientで必要
       isRadial = this.gradient(fillElement, RegExp.$1, matrix);
     } else {
@@ -1179,7 +1183,7 @@
     }
     isRadial = fillOpacity = null;
   }
-  if (this.stroke === "none") {
+  if (isNone[this.stroke]) {
     el.stroked = "false";
   } else {
     var strokeElement = document.createElement("v:stroke");
@@ -1187,7 +1191,7 @@
     var sw = new STLength(this.strokewidth, Math.sqrt((w*w + h*h) / 2));
     var swx = sw.value * Math.sqrt(Math.abs(matrix.determinant()));
     strokeElement.setAttribute("weight", swx + "px");
-    if (this.stroke.match(/url\(#([^)]+)/)) {
+    if (_urlreg.test(this.stroke)) {
       this.gradient(strokeElement, RegExp.$1);
     } else {
       strokeElement.setAttribute("color", this.color(this.stroke));
@@ -1208,7 +1212,7 @@
       strokeElement.setAttribute("endcap", this.strokelinecap);
     }
     var tsd = this.strokedasharray;
-    if (tsd !== "none") {
+    if (!isNone[tsd]) {
       if (tsd.indexOf(",") > 0) { //コンマ区切りの文字列の場合
         var strs = tsd.split(",");
         for (var i = 0, sli = strs.length; i < sli; ++i) {
@@ -1231,6 +1235,7 @@
   }
   w = h = null;
 };
+})();
 //色キーワード
 NAIBU.PaintColor.prototype.keywords = {
   aliceblue: "#F0F8FF",




Sie-announce メーリングリストの案内
Back to archive index