[Sie-announce] SIEコード [2332] アニメーションに関する描画のバグと、さらに、keyTimes属性のバグを修正した

Zurück zum Archiv-Index

svnno****@sourc***** svnno****@sourc*****
2011年 1月 26日 (水) 22:44:39 JST


Revision: 2332
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2332
Author:   dhrname
Date:     2011-01-26 22:44:39 +0900 (Wed, 26 Jan 2011)

Log Message:
-----------
アニメーションに関する描画のバグと、さらに、keyTimes属性のバグを修正した

Modified Paths:
--------------
    branches/06x/org/w3c/dom/svg.js

Property Changed:
----------------
    branches/06x/org/w3c/dom/svg.js

Modified: branches/06x/org/w3c/dom/svg.js
===================================================================
--- branches/06x/org/w3c/dom/svg.js	2011-01-26 13:39:54 UTC (rev 2331)
+++ branches/06x/org/w3c/dom/svg.js	2011-01-26 13:44:39 UTC (rev 2332)
@@ -4558,7 +4558,7 @@
   this._begin = null;
   this._end = null;
   this._from = this._to = this._values = this._by = null;
-  this._keyTimes = [0, 1];
+  this._keyTimes = null;
   this.addEventListener("beginEvent", function(evt) {
     var tar = evt.target;
     if (!tar.isRepeat) {
@@ -4600,6 +4600,7 @@
       tar._by = evt.newValue;
     } else if (name === "keyTimes") {
       var s = evt.newValue.split(";");
+      tar._keyTimes = []; //_keyTimesプロパティを初期化
       for (var i=0;i<s.length;++i) {
         tar._keyTimes[i] = parseFloat(s[i]);
       }
@@ -4776,9 +4777,10 @@
   Max : 7000,
   start : function() {
   if (NAIBU.Clip.length > 0) {
+    screen.updateInterval = 42; //24fpsとして描画処理
     window.onscroll = function () {
       screen.updateInterval = 0;
-      screen.updateInterval = 42; //24fpsとして描画処理
+      screen.updateInterval = 42;
     }
     NAIBU.stop = setInterval( (function() {
 /*      try{*/
@@ -4894,12 +4896,6 @@
         vi = null;
         return;
       }
-      if ((tar._keyTimes[1] === 1) && (tar._valueList.length > 2)) { //keyTimesが設定されていない場合、均等に時間を割り振る
-        for (var i=0,n=0,tvli=tar._valueList.length-1;i<tvli;++i) {
-          n += 1 / tvli;
-          tar._keyTimes[i+1] = n;
-        }
-      }
       evt = tta = vir = vi = null;
     }, false);
   }, false);
@@ -4908,9 +4904,12 @@
     var attrName = tar.getAttributeNS(null, "attributeName"), newAttr = tar.targetElement.attributes.getNamedItemNS(null, attrName);
     var ttr = tar.targetElement, tta = ttr[attrName];
     tar._frame = function() {
-      var d = tar.getSimpleDuration() * 0.8, n = tar._valueList.length - 2, tg = tar.getCurrentTime();
+      var d = tar.getSimpleDuration() * 0.8, n = tar._valueList.length-1, tg = tar.getCurrentTime();
       if ((n !== -1) && (d !== 0) && (tg <= d)) {
         var ii = Math.floor((tg*n) / d);
+        if (ii === n) { //iiが境い目のときは、n-2を適用
+          ii -= 1;
+        }
       } else {
         return;
       }
@@ -4922,6 +4921,13 @@
       */
       var evt = tar.ownerDocument.createEvent("MutationEvents");
       evt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
+      if (tar._keyTimes) {
+        var di = (tar._keyTimes[ii+1] - tar._keyTimes[ii]) * d;
+        var ti = tar._keyTimes[ii];
+      } else {
+        var di = d / n; //keyTimesがなければ均等に時間を配分しておく
+        var ti = ii / n;
+      }
       if (!!tta) {
         var base = tta.baseVal, tanim = tta.animVal;
         var v1 = tar._valueList[ii].value;
@@ -4930,7 +4936,7 @@
          *http://www.w3.org/TR/2005/REC-SMIL2-20050107/animation.html#animationNS-SpecifyingAnimationFunction
          */
         if (!tar._isDiscrete) {
-          var v2 = tar._valueList[ii+1].value, di = (tar._keyTimes[ii+1] - tar._keyTimes[ii]) * d, v = v1 + (v2-v1) * (tg-tar._keyTimes[ii]*d) / di;
+          var v2 = tar._valueList[ii+1].value, v = v1 + (v2-v1) * (tg-ti*d) / di;
         } else {
           var v = v1;
         }
@@ -4946,9 +4952,9 @@
         di = null;
       } else if (!!CSS2Properties[attrName] || attrName.indexOf("-") > -1) { //スタイルシートのプロパティならば
         var base = null;
-        var v1 = tar._valueList[ii].value, v2 = tar._valueList[ii+1].value, di = (tar._keyTimes[ii+1] - tar._keyTimes[ii]) * d;
+        var v1 = tar._valueList[ii].value, v2 = tar._valueList[ii+1].value;
         if (!tar._isDiscrete) {
-          var v = v1 + (v2-v1) * (tg-tar._keyTimes[ii]*d) / di;
+          var v = v1 + (v2-v1) * (tg-ti*d) / di;
         } else {
           var v = v1;
         }
@@ -5159,13 +5165,23 @@
     }
     tar._frame = function() {
       var _tar = tar;
-      var d = _tar.getSimpleDuration() * 0.8, n = _tar._valueList.length - 2, tg = _tar.getCurrentTime();
+      var d = _tar.getSimpleDuration() * 0.8, n = _tar._valueList.length - 1, tg = _tar.getCurrentTime();
       if ((n !== -1) && (d !== 0) && (tg <= d)) {
         var ii = Math.floor((tg*n) / d);
+        if (ii === n) { //iiが境い目のときは、n-2を適用
+          ii -= 1;
+        }
       } else {
         return;
       }
-      var fc = _tar._valueList[ii].rgbColor, tc = _tar._valueList[ii+1].rgbColor, di = (_tar._keyTimes[ii+1] - _tar._keyTimes[ii]) * d, durd = (tg-tar._keyTimes[ii]*d) / di, num = CSSPrimitiveValue.CSS_NUMBER;
+      if (tar._keyTimes) {
+        var di = (tar._keyTimes[ii+1] - tar._keyTimes[ii]) * d;
+        var ti = tar._keyTimes[ii];
+      } else {
+        var di = d / n; //keyTimesがなければ均等に時間を配分しておく
+        var ti = ii / n;
+      }
+      var fc = _tar._valueList[ii].rgbColor, tc = _tar._valueList[ii+1].rgbColor, durd = (tg-ti*d) / di, num = CSSPrimitiveValue.CSS_NUMBER;
       var fr = fc.red.getFloatValue(num), fg = fc.green.getFloatValue(num), fb = fc.blue.getFloatValue(num);
       var r = fr + (tc.red.getFloatValue(num) - fr) * durd;
       var g = fg + (tc.green.getFloatValue(num) - fg) * durd;


Property changes on: branches/06x/org/w3c/dom/svg.js
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/06x/061/org/w3c/dom/svg.js:1864-2067
/branches/06x/062/org/w3c/dom/svg.js:2071-2106
/branches/06x/063/org/w3c/dom/svg.js:2110-2146
/branches/06x/064/org/w3c/dom/svg.js:2149-2177
/branches/06x/065/org/w3c/dom/svg.js:2179-2209
/branches/06x/066/org/w3c/dom/svg.js:2211-2239
/branches/06x/067/org/w3c/dom/svg.js:2257-2282
/branches/06x/068/org/w3c/dom/svg.js:2284-2314
/branches/ufltima/dom/svg.js:1621-1856
   + /branches/06x/061/org/w3c/dom/svg.js:1864-2067
/branches/06x/062/org/w3c/dom/svg.js:2071-2106
/branches/06x/063/org/w3c/dom/svg.js:2110-2146
/branches/06x/064/org/w3c/dom/svg.js:2149-2177
/branches/06x/065/org/w3c/dom/svg.js:2179-2209
/branches/06x/066/org/w3c/dom/svg.js:2211-2239
/branches/06x/067/org/w3c/dom/svg.js:2257-2282
/branches/06x/068/org/w3c/dom/svg.js:2284-2314
/branches/06x/069/org/w3c/dom/svg.js:2329-2331
/branches/ufltima/dom/svg.js:1621-1856




Sie-announce メーリングリストの案内
Zurück zum Archiv-Index