[Sie-announce] SIEコード [1671] SVGColorとSVGPaintの実装

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 2月 20日 (土) 23:35:02 JST


Revision: 1671
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1671
Author:   dhrname
Date:     2010-02-20 23:35:02 +0900 (Sat, 20 Feb 2010)

Log Message:
-----------
SVGColorとSVGPaintの実装

Modified Paths:
--------------
    branches/ufltima/dom/svg.js

Modified: branches/ufltima/dom/svg.js
===================================================================
--- branches/ufltima/dom/svg.js	2010-02-19 14:46:48 UTC (rev 1670)
+++ branches/ufltima/dom/svg.js	2010-02-20 14:35:02 UTC (rev 1671)
@@ -270,9 +270,7 @@
   return this;
 };
 function SVGAnimatedNumber() {
-  /*float*/ this.baseVal = 0;
-                         // raises DOMException on setting
-  /*readonly float*/ this.animVal = 0;
+  /*float*/ this.baseVal = this.animVal = 0;
   return this;
 };
 
@@ -322,7 +320,8 @@
   return this;
 };
 
-function SVGColor() { 
+function SVGColor() {
+  CSSValue.call(this, arguments);
   /*readonly unsigned short*/ this.colorType = SVGColor.SVG_COLORTYPE_UNKNOWN;
   /*readonly css::RGBColor*/ this.rgbColor = new RGBColor();
   /*readonly SVGICCColor*/ this.iccColor;
@@ -338,7 +337,6 @@
 SVGColor.constructor = CSSValue;
 
 /*void*/ SVGColor.prototype.setRGBColor = function(/*DOMString*/ rgbColor ){
-  this.colorType = SVGColor.SVG_COLORTYPE_RGBCOLOR;
   this.cssText = rgbColor;
   var tkr = this.keywords[rgbColor];
   if (tkr !== void 0) {
@@ -354,19 +352,17 @@
     });
   }
   var s = rgbColor.match(/\d+/g);
-  this.rgbColor.r = parseInt(s[0]);
-  this.rgbColor.g = parseInt(s[1]);
-  this.rgbColor.b = parseInt(s[2]);
+  this.rgbColor.r.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(s[0]));
+  this.rgbColor.g.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(s[1]));
+  this.rgbColor.b.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(s[2]));
 };
 
 //                    raises( SVGException );
 /*void*/ SVGColor.prototype.setColor =function(/*unsigned short*/ colorType, /*DOMString*/ rgbColor, /*DOMString*/ iccColor ){
- if (colorType === 1) {
-   this.setRGBColor(rgbColor);
- } else if (colorType === 3) {
-   this.colorType - SVGColor.SVG_COLORTYPE_CURRENTCOLOR;
-   this.setRGBColor(this.style.getPropertyValue("color"));
- }
+  this.colorType = colorType;
+  if (colorType === SVGColor.SVG_COLORTYPE_RGBCOLOR) {
+    this.setRGBColor(rgbColor);
+  }
 }
 //                    raises( SVGException );
 //色キーワード
@@ -534,11 +530,9 @@
 /*getPresentationAttributeメソッド
  *プレゼンテーション属性の値をCSSValueとして得る。これはCSSのスタイルの設定値を定めるときや、内部の動的処理に役立つ
  */
-SVGStylable.prototype = {
-  /*css::CSSValue*/ getPresentationAttribute : function( /*DOMString*/ name ){
-    var s = new CSSValue(), tgn = this.attributes.getNamedItemNS(null, name);
-  }
-}
+/*css::CSSValue*/ SVGElement.prototype.getPresentationAttribute = function( /*DOMString*/ name ){
+  var s = new CSSValue(), tgn = this.attributes.getNamedItemNS(null, name);
+};
 
 /*SVGURIReferenceオブジェクトはURI参照を用いる要素に適用される
  *SIEでは、もっぱらXLink言語の処理を行う
@@ -1638,7 +1632,7 @@
 function SVGPaint() { 
   SVGColor.apply(this, arguments);
   /*readonly unsigned short*/ this.paintType = SVGPaint.SVG_PAINTTYPE_UNKNOWN;
-  /*readonly DOMString*/      this.uri;
+  /*readonly DOMString*/      this.uri = null;
 };
 SVGPaint.constructor = SVGColor;
 SVGPaint.prototype = new SVGColor();
@@ -1654,11 +1648,19 @@
   /*unsigned short*/ SVGPaint.SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR = 106;
   /*unsigned short*/ SVGPaint.SVG_PAINTTYPE_URI                   = 107;
 /*void*/ SVGPaint.prototype.setUri = function(/*DOMString*/ uri ) {
-  
+  this.setPaint(SVGPaint.SVG_PAINTTYPE_URI_NONE, uri, null, null);
 };
 /*void*/ SVGPaint.prototype.setPaint = function(/*unsigned short*/ paintType, /*DOMString*/ uri, /*DOMString*/ rgbColor, /*DOMString*/ iccColor ) {
-  
-}
+  if ((paintType < 101 && uri) || (paintType > 102 && !uri)) {
+    throw new SVGException(SVG_INVALID_VALUE_ERR);
+  }
+  this.uri = uri;
+  this.paintType = paintType;
+  if (paintType === SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR) {
+    paintType = SVGColor.SVG_COLORTYPE_CURRENTCOLOR;
+  }
+  this.setColor(paintType, rgbColor, iccColor); //SVGColorのsetColorメソッドを用いる
+};
 //                    raises( SVGException );
 
 function SVGMarkerElement(){ 




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