svnno****@sourc*****
svnno****@sourc*****
2011年 4月 21日 (木) 23:07:26 JST
Revision: 2616 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2616 Author: dhrname Date: 2011-04-21 23:07:26 +0900 (Thu, 21 Apr 2011) Log Message: ----------- SVGColorのprototypeを整理 Modified Paths: -------------- branches/07x/076/org/w3c/dom/svg.js Modified: branches/07x/076/org/w3c/dom/svg.js =================================================================== --- branches/07x/076/org/w3c/dom/svg.js 2011-04-19 12:06:26 UTC (rev 2615) +++ branches/07x/076/org/w3c/dom/svg.js 2011-04-21 14:07:26 UTC (rev 2616) @@ -708,19 +708,22 @@ SVGColor.prototype = new CSSValue(); //ノードのプロトタイプチェーンを作って、継承 SVGColor.constructor = CSSValue; -/*readonly unsigned short*/ SVGColor.prototype.colorType = /*SVGColor.SVG_COLORTYPE_UNKNOWN*/ 0; -/*readonly SVGICCColor*/ SVGColor.prototype.iccColor = null; -/*void*/ SVGColor.prototype.setRGBColor = function(/*DOMString*/ rgbColor ){ +(function(){ + /*readonly unsigned short*/ this.colorType = /*SVGColor.SVG_COLORTYPE_UNKNOWN*/ 0; + /*readonly SVGICCColor*/ this.iccColor = null; + this._regD = /\d+/g; + this._regDP = /[\d.]+%/g; + /*void*/ this.setRGBColor = function(/*DOMString*/ rgbColor ){ var s, _parseInt, r, g, b, c; rgbColor = this._keywords[rgbColor] || rgbColor; if (rgbColor.indexOf("%", 5) > 0) { // %を含むrgb形式の場合 - rgbColor = rgbColor.replace(/[\d.]+%/g, function(s) { + rgbColor = rgbColor.replace(this._regDP, function(s) { return Math.round((2.55 * parseFloat(s))); }); - s = rgbColor.match(/\d+/g); + s = rgbColor.match(this._regD); } else if (rgbColor.indexOf("#") === 0) { //#を含む場合 s = []; _parseInt = parseInt; @@ -737,7 +740,7 @@ s[2] = _parseInt(rgbColor.charAt(5)+rgbColor.charAt(6), 16)+ ""; r = g = b = null; } else { - s = rgbColor.match(/\d+/g); + s = rgbColor.match(this._regD); if (!!!s) { //数値が含まれていなければ強制的に終了 rgbColor = null; return; @@ -750,7 +753,7 @@ }; // raises( SVGException ); -/*void*/ SVGColor.prototype.setColor =function(/*unsigned short*/ colorType, /*DOMString*/ rgbColor, /*DOMString*/ iccColor ){ +/*void*/ this.setColor =function(/*unsigned short*/ colorType, /*DOMString*/ rgbColor, /*DOMString*/ iccColor ){ this.colorType = colorType; if ((colorType === /*SVGColor.SVG_COLORTYPE_RGBCOLOR*/ 1) || (colorType === /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3)) { this.setRGBColor(rgbColor); @@ -759,7 +762,7 @@ } // raises( SVGException ); //色キーワード -SVGColor.prototype._keywords = { +this._keywords = { aliceblue: "rgb(240, 248, 255)", antiquewhite: "rgb(250, 235, 215)", aqua: "rgb( 0, 255, 255)", @@ -908,6 +911,7 @@ yellow: "rgb(255, 255, 0)", yellowgreen: "rgb(154, 205, 50)" }; +}).apply(SVGColor.prototype); function SVGRect() { /*float*/ this.x = 0;