private void updateParameters(int pass, int textureWidth, int textureHeight) { float sigma = 0; bool horizontal = pass < mBlurX; float pixelSize = 0; if (horizontal) { sigma = AsMath.min(1.0f, mBlurX - pass) * MAX_SIGMA; pixelSize = 1.0f / textureWidth; } else { sigma = AsMath.min(1.0f, mBlurY - (pass - AsMath.ceil(mBlurX))) * MAX_SIGMA; pixelSize = 1.0f / textureHeight; } float twoSigmaSq = 2 * sigma * sigma; float multiplier = 1.0f / AsMath.sqrt(twoSigmaSq * AsMath.PI); int i = 0; for (; i < 4; ++i) { sTmpWeights[i] = multiplier * AsMath.exp(-i * i / twoSigmaSq); } mWeights[0] = sTmpWeights[0]; mWeights[1] = sTmpWeights[1] + sTmpWeights[2]; mWeights[2] = sTmpWeights[3] + sTmpWeights[4]; float weightSum = mWeights[0] + 2 * mWeights[1] + 2 * mWeights[2]; float invWeightSum = 1.0f / weightSum; mWeights[0] = mWeights[0] * invWeightSum; mWeights[1] = mWeights[1] * invWeightSum; mWeights[2] = mWeights[2] * invWeightSum; float offset1 = (pixelSize * sTmpWeights[1] + 2 * pixelSize * sTmpWeights[2]) / mWeights[1]; float offset2 = (3 * pixelSize * sTmpWeights[3] + 4 * pixelSize * sTmpWeights[4]) / mWeights[2]; if (horizontal) { mOffsets[0] = offset1; mOffsets[1] = 0; mOffsets[2] = offset2; mOffsets[3] = 0; } else { mOffsets[0] = 0; mOffsets[1] = offset1; mOffsets[2] = 0; mOffsets[3] = offset2; } }
public virtual void advanceTime(float time) { float previousTime = mCurrentTime; mCurrentTime = AsMath.min(mTotalTime, mCurrentTime + time); if (previousTime < mTotalTime && mCurrentTime >= mTotalTime) { mCall(); if (mRepeatCount == 0 || mRepeatCount > 1) { if (mRepeatCount > 0) { mRepeatCount = mRepeatCount - 1; } mCurrentTime = 0; advanceTime((previousTime + time) - mTotalTime); } else { dispatchEventWith(AsEvent.REMOVE_FROM_JUGGLER); } } }
public virtual void advanceTime(float time) { if (time == 0 || (mRepeatCount == 1 && mCurrentTime == mTotalTime)) { return; } int i = 0; float previousTime = mCurrentTime; float restTime = mTotalTime - mCurrentTime; float carryOverTime = time > restTime ? time - restTime : 0.0f; mCurrentTime = AsMath.min(mTotalTime, mCurrentTime + time); if (mCurrentTime <= 0) { return; } if (mCurrentCycle < 0 && previousTime <= 0 && mCurrentTime > 0) { mCurrentCycle++; if (mOnStart != null) { mOnStart((float)(mOnStartArgs[0])); } } float ratio = mCurrentTime / mTotalTime; bool reversed = mReverse && (mCurrentCycle % 2 == 1); int numProperties = (int)(mStartValues.getLength()); for (i = 0; i < numProperties; ++i) { if (AsGlobal.isNaN(mStartValues[i])) { mStartValues[i] = ((AsObject)(mTarget)).getOwnProperty(mProperties[i]) as float; } float startValue = mStartValues[i]; float endValue = mEndValues[i]; float delta = endValue - startValue; float transitionValue = reversed ? mTransitionFunc(1.0f - ratio) : mTransitionFunc(ratio); float currentValue = startValue + transitionValue * delta; if (mRoundToInt) { currentValue = AsMath.round(currentValue); } ((AsObject)(mTarget)).setOwnProperty(mProperties[i], currentValue); } if (mOnUpdate != null) { mOnUpdate((float)(mOnUpdateArgs[0])); } if (previousTime < mTotalTime && mCurrentTime >= mTotalTime) { if (mRepeatCount == 0 || mRepeatCount > 1) { mCurrentTime = -mRepeatDelay; mCurrentCycle++; if (mRepeatCount > 1) { mRepeatCount--; } if (mOnRepeat != null) { mOnRepeat((float)(mOnRepeatArgs[0])); } } else { AsTransitionCallback onComplete = mOnComplete; AsArray onCompleteArgs = mOnCompleteArgs; dispatchEventWith(AsEvent.REMOVE_FROM_JUGGLER); if (onComplete != null) { onComplete((float)(onCompleteArgs[0])); } } } if (carryOverTime != 0) { advanceTime(carryOverTime); } }