⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 interpolationaffector.java

📁 Sony Ericsson手机上的Facebook客户端全套代码
💻 JAVA
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   InterpolationAffector.java

package se.southend.drops.integeraffector;

import se.southend.drops.math.IntMath;
import se.southend.drops.screen.ScreenEngine;

// Referenced classes of package se.southend.drops.integeraffector:
//            Affector

public abstract class InterpolationAffector extends Affector
{

    public InterpolationAffector(int startValue, int endValue, int duration, int interpolation)
    {
        this(startValue, endValue, duration, 0, interpolation);
    }

    public InterpolationAffector(int startValues[], int endValues[], int duration, int interpolation)
    {
        this(startValues, endValues, duration, 0, interpolation);
    }

    public InterpolationAffector(int startValue, int endValue, int duration, int delay, int interpolation)
    {
        int startValues[] = {
            startValue
        };
        int endValues[] = {
            endValue
        };
        init(startValues, endValues, duration, delay, interpolation);
    }

    public InterpolationAffector(int startValues[], int endValues[], int duration, int delay, int interpolation)
    {
        init(startValues, endValues, duration, delay, interpolation);
    }

    private void init(int startValues[], int endValues[], int duration, int delay, int interpolation)
    {
        this.interpolation = interpolation;
        this.startValues = startValues;
        this.endValues = endValues;
        values = new int[startValues.length];
        lastValues = new int[startValues.length];
        System.arraycopy(startValues, 0, values, 0, startValues.length);
        System.arraycopy(startValues, 0, lastValues, 0, startValues.length);
        startTime = ScreenEngine.getInstance().getTime() + (long)delay;
        endTime = startTime + (long)duration;
    }

    public void update(long time)
    {
        if(time >= endTime)
        {
            for(int i = 0; i < values.length; i++)
            {
                lastValues[i] = values[i];
                values[i] = endValues[i];
            }

            isFinished = true;
        } else
        {
            for(int i = 0; i < values.length; i++)
            {
                lastValues[i] = values[i];
                int t = (int)((time - startTime << 12) / (endTime - startTime));
                values[i] = interpolate(interpolation, startValues[i], endValues[i], t);
            }

        }
    }

    private static final int interpolate(int type, int a, int b, int t)
    {
        if((type & 0xf0) == 16)
            t = t * t >> 12;
        else
        if((type & 0xf0) == 48)
            t = (t * t >> 12) * (t * t >> 12) >> 12;
        else
        if((type & 0xf0) == 32)
        {
            int tInv = 4096 - t;
            t = 0x1000000 - tInv * tInv >> 12;
        }
        if((type & 0xf) == 1)
        {
            long f = 0x10000 - IntMath.cos(t * 512 >> 12) >> 1;
            return (int)(((long)a * (0x10000L - f) + (long)b * f << 1) + 0x10000L >> 17);
        } else
        {
            return a + ((t * (b - a) >> 11) + 1 >> 1);
        }
    }

    public static final int LINEAR = 0;
    public static final int COSINE = 1;
    public static final int CONSTANT = 0;
    public static final int ACCELERATING = 16;
    public static final int DECELERATING = 32;
    public static final int ACCELERATING_X2 = 48;
    protected int interpolation;
    protected int startValues[];
    protected int endValues[];
    protected long endTime;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -