svnno****@sourc*****
svnno****@sourc*****
2010年 11月 22日 (月) 23:27:38 JST
Revision: 2167 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2167 Author: dhrname Date: 2010-11-22 23:27:38 +0900 (Mon, 22 Nov 2010) Log Message: ----------- 1, animateColor要素の実装開始 2, animate要素の修正 Modified Paths: -------------- branches/06x/064/org/w3c/dom/svg.js Modified: branches/06x/064/org/w3c/dom/svg.js =================================================================== --- branches/06x/064/org/w3c/dom/svg.js 2010-11-21 14:19:54 UTC (rev 2166) +++ branches/06x/064/org/w3c/dom/svg.js 2010-11-22 14:27:38 UTC (rev 2167) @@ -4874,14 +4874,14 @@ var base = ttr.points; ttr.points = ttr.animatedPoints; ttr.dispatchEvent(evt); - tta.animatedPoints = tta.points; - tta.points = base; + ttr.animatedPoints = ttr.points; + ttr.points = base; } else if ("normalizedPathSegList" in ttr) { var base = ttr.normalizedPathSegList; ttr.normalizedPathSegList = ttr.animatedNormalizedPathSegList; ttr.dispatchEvent(evt); - tta.animatedNormalizedPathSegList = tta.normalizedPathSegList; - tta.normalizedPathSegList = base; + ttr.animatedNormalizedPathSegList = ttr.normalizedPathSegList; + ttr.normalizedPathSegList = base; } evt = v1 = v2 = v = d = n = ii = tg = null; }; @@ -5048,6 +5048,26 @@ function SVGAnimateColorElement() { SVGAnimationElement.apply(this); NAIBU.Clip[NAIBU.Clip.length] = this; + this._valueList = []; + this.addEventListener("DOMNodeInserted", function(evt){ + if (evt.eventPhase === Event.BUBBLING_PHASE) { + return; //強制終了させる + } + var tar = evt.target; + tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){ + var tar = evt.target, attrName = tar.getAttributeNS(null, "attributeName"),ttr = tar.targetElement; + var fstyle = tar.ownerDocument.defaultView.getComputedStyle(ttr, ""); + if (!tar._values[0]) { + tar._values[0] = fstyle.getPropertyValue(attrName); + } + for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) { + var to = new SVGColor(); + to.setRGBColor(tar._values[i]); + tar._valueList[tar._valueList.length] = to; + to = null; + } + }, false); + }, false); this.addEventListener("beginEvent", function(evt) { var tar = evt.target, attrName = tar.getAttributeNS(null, "attributeName"); var style = tar.ownerDocument.getOverrideStyle(tar.targetElement, ""); @@ -5056,30 +5076,20 @@ style.setProperty(attrName, tar._values[0], null); } tar._frame = function() { - var _tar = tar, to = new SVGColor(), from = new SVGColor(); - var d = _tar.getSimpleDuration(); - if (d === 0) { - d = null; + var _tar = tar; + 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); + } else { return; } - var n = _tar._values.length - 1, t = _tar.getCurrentTime(), i = Math.floor((t*n) / d); - to.setRGBColor(_tar._values[i+1]); - from.setRGBColor(_tar._values[i]); - if (!!!_tar._keyTimes) { - var ti = d / n, ki =ti; - if (n === 1) { - ti = 0; - } - } else { - var ti = parseFloat(_tar._keyTimes[i]) * d; - var ki = parseFloat(_tar._keyTimes[i+1])*d - ti; - } - var tc = to.rgbColor, fc = from.rgbColor, num = CSSPrimitiveValue.CSS_NUMBER, di = (t - ti) / ki; - var r = fc.red.getFloatValue(num) + (tc.red.getFloatValue(num) - fc.red.getFloatValue(num)) * di; - var g = fc.green.getFloatValue(num) + (tc.green.getFloatValue(num) - fc.green.getFloatValue(num)) * di; - var b = fc.blue.getFloatValue(num) + (tc.blue.getFloatValue(num) - fc.blue.getFloatValue(num)) * di; + var fc = _tar._valueList[ii], tc = _tar._valueList[ii+1], di = (_tar._keyTimes[ii+1] - _tar._keyTimes[ii]) * d, durd = (tg-tar._keyTimes[ii]*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; + var b = fb + (tc.blue.getFloatValue(num) - fb) * durd; style.setProperty(attrName, "rgb(" +Math.ceil(r)+ "," +Math.ceil(g)+ "," +Math.ceil(b)+ ")", null); - _tar = t = to = from = fc = tc = num = r = g = b = null; + _tar = d = n = tg = fc = tc = fr = fg = fb = num = r = g = b = null; } }, false); this.addEventListener("endEvent", function(evt) {