[Sie-announce] SIEコード [2334] 0. 68betaに対して、アニメーションのバグを修正を取り込んだ

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2011年 1月 26日 (水) 23:14:37 JST


Revision: 2334
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2334
Author:   dhrname
Date:     2011-01-26 23:14:37 +0900 (Wed, 26 Jan 2011)

Log Message:
-----------
0.68betaに対して、アニメーションのバグを修正を取り込んだ

Modified Paths:
--------------
    trunk/sie.js

Property Changed:
----------------
    trunk/sie.js

Modified: trunk/sie.js
===================================================================
--- trunk/sie.js	2011-01-26 13:46:42 UTC (rev 2333)
+++ trunk/sie.js	2011-01-26 14:14:37 UTC (rev 2334)
@@ -6941,7 +6941,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) {
@@ -6983,6 +6983,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]);
       }
@@ -7159,9 +7160,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{*/
@@ -7277,12 +7279,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);
@@ -7291,9 +7287,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;
       }
@@ -7305,6 +7304,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;
@@ -7313,7 +7319,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;
         }
@@ -7329,9 +7335,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;
         }
@@ -7542,13 +7548,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: trunk/sie.js
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/04x/040/sie.js:812-829
/branches/04x/041/sie.js:891-923
/branches/04x/042/sie.js:927-967
/branches/04x/043/sie.js:969-1013
/branches/04x/044/sie.js:1015-1067
/branches/04x/045/sie.js:1069-1078
/branches/04x/046/sie.js:1080-1129
/branches/04x/047/sie.js:1131-1164
/branches/04x/048/sie.js:1166-1180
/branches/04x/sie.js:830-1181
/branches/05x/050/sie.js:1183-1201
/branches/05x/051/sie.js:1207-1323
/branches/05x/052/sie.js:1325-1352
/branches/05x/053/sie.js:1354-1400
/branches/05x/054/sie.js:1403-1422
/branches/05x/055/sie.js:1424-1454
/branches/05x/056/sie.js:1456-1491
/branches/05x/057/sie.js:1496-1523
/branches/05x/058/sie.js:1526-1590
/branches/05x/sie.js:1183-1594
/branches/06x/060/sie.js:1603-1850
/branches/06x/sie.js:1599-2317
   + /branches/04x/040/sie.js:812-829
/branches/04x/041/sie.js:891-923
/branches/04x/042/sie.js:927-967
/branches/04x/043/sie.js:969-1013
/branches/04x/044/sie.js:1015-1067
/branches/04x/045/sie.js:1069-1078
/branches/04x/046/sie.js:1080-1129
/branches/04x/047/sie.js:1131-1164
/branches/04x/048/sie.js:1166-1180
/branches/04x/sie.js:830-1181
/branches/05x/050/sie.js:1183-1201
/branches/05x/051/sie.js:1207-1323
/branches/05x/052/sie.js:1325-1352
/branches/05x/053/sie.js:1354-1400
/branches/05x/054/sie.js:1403-1422
/branches/05x/055/sie.js:1424-1454
/branches/05x/056/sie.js:1456-1491
/branches/05x/057/sie.js:1496-1523
/branches/05x/058/sie.js:1526-1590
/branches/05x/sie.js:1183-1594
/branches/06x/060/sie.js:1603-1850
/branches/06x/sie.js:1599-2333




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