Пример #1
0
    public SsInterpolatable GetInterpolated(SsCurveParams curve, float time, SsInterpolatable start, SsInterpolatable end_, int startTime, int endTime)
    {
        var end = (SsColorBlendKeyValue)end_;
        var v   = new SsColorBlendKeyValue(end.Colors.Length);

        return(v.Interpolate(curve, time, start, end, startTime, endTime));
    }
Пример #2
0
    // returns a derived value interpolated from "prev" to "next" at "time".
    static public object    InterpolateKeyValue(SsKeyFrameInterface prevKey, SsKeyFrameInterface nextKey, int time)
    {
        // just returns a start value if prevKey has no curve.
        if (prevKey.Curve.IsNone)
        {
            return(prevKey.ObjectValue);
        }

        // get times at nearest keys away from specified time.
        int startTime = prevKey.Time;
        int endTime   = nextKey.Time;

        float now = 0f;

        if (startTime < endTime)
        {
            now = ((float)(time - startTime)) / (endTime - startTime);
        }

        SsInterpolatable interpolatable = prevKey.ObjectValue as SsInterpolatable;

        if (interpolatable == null)
        {
            return(Interpolate(prevKey.Curve, now, prevKey.ObjectValue, nextKey.ObjectValue, startTime, endTime));
        }
        else
        {
            return((object)interpolatable.GetInterpolated(prevKey.Curve, now, (SsInterpolatable)prevKey.ObjectValue, (SsInterpolatable)nextKey.ObjectValue, startTime, endTime));
        }
    }
Пример #3
0
	public SsInterpolatable Interpolate(SsCurveParams curve, float time, SsInterpolatable start_, SsInterpolatable end_, int startTime, int endTime)
	{
		var start = (SsPoint)start_;
		var end = (SsPoint)end_;
		X = SsInterpolation.Interpolate(curve, time, start.X, end.X, startTime, endTime);
		Y = SsInterpolation.Interpolate(curve, time, start.Y, end.Y, startTime, endTime);
		return this;
	}
Пример #4
0
    public SsInterpolatable Interpolate(SsCurveParams curve, float time, SsInterpolatable start_, SsInterpolatable end_, int startTime, int endTime)
    {
        var start = (SsPoint)start_;
        var end   = (SsPoint)end_;

        X = SsInterpolation.Interpolate(curve, time, start.X, end.X, startTime, endTime);
        Y = SsInterpolation.Interpolate(curve, time, start.Y, end.Y, startTime, endTime);
        return(this);
    }
Пример #5
0
    public SsInterpolatable Interpolate(SsCurveParams curve, float time, SsInterpolatable start_, SsInterpolatable end_, int startTime, int endTime)
    {
        var start = (SsPaletteKeyValue)start_;
        var end   = (SsPaletteKeyValue)end_;

        Use   = SsInterpolation.Interpolate(curve, time, start.Use ? 1f : 0f, end.Use ? 1f : 0f, startTime, endTime) >= 0.5f ? true : false;
        Page  = SsInterpolation.Interpolate(curve, time, start.Page, end.Page, startTime, endTime);
        Block = (byte)SsInterpolation.Interpolate(curve, time, start.Block, end.Block, startTime, endTime);
        return(this);
    }
Пример #6
0
 public SsInterpolatable Interpolate(SsCurveParams curve, float time, SsInterpolatable start_, SsInterpolatable end_, int startTime, int endTime)
 {
     var start = (SsColorRef)start_;
     var end = (SsColorRef)end_;
     R = (byte)SsInterpolation.Interpolate(curve, time, start.R, end.R, startTime, endTime);
     G = (byte)SsInterpolation.Interpolate(curve, time, start.G, end.G, startTime, endTime);
     B = (byte)SsInterpolation.Interpolate(curve, time, start.B, end.B, startTime, endTime);
     A = (byte)SsInterpolation.Interpolate(curve, time, start.A, end.A, startTime, endTime);
     return this;
 }
Пример #7
0
    public SsInterpolatable Interpolate(SsCurveParams curve, float time, SsInterpolatable start_, SsInterpolatable end_, int startTime, int endTime)
    {
        var start = (SsColorRef)start_;
        var end   = (SsColorRef)end_;

        R = (byte)SsInterpolation.Interpolate(curve, time, start.R, end.R, startTime, endTime);
        G = (byte)SsInterpolation.Interpolate(curve, time, start.G, end.G, startTime, endTime);
        B = (byte)SsInterpolation.Interpolate(curve, time, start.B, end.B, startTime, endTime);
        A = (byte)SsInterpolation.Interpolate(curve, time, start.A, end.A, startTime, endTime);
        return(this);
    }
Пример #8
0
    public SsInterpolatable Interpolate(SsCurveParams curve, float time, SsInterpolatable start_, SsInterpolatable end_, int startTime, int endTime)
    {
        var start = (SsRect)start_;
        var end   = (SsRect)end_;

        Left   = SsInterpolation.Interpolate(curve, time, start.Left, end.Left, startTime, endTime);
        Top    = SsInterpolation.Interpolate(curve, time, start.Top, end.Top, startTime, endTime);
        Right  = SsInterpolation.Interpolate(curve, time, start.Right, end.Right, startTime, endTime);
        Bottom = SsInterpolation.Interpolate(curve, time, start.Bottom, end.Bottom, startTime, endTime);
        return(this);
    }
Пример #9
0
    public SsInterpolatable Interpolate(SsCurveParams curve, float time, SsInterpolatable start_, SsInterpolatable end_, int startTime, int endTime)
    {
        var start = (SsVertexKeyValue)start_;
        var end   = (SsVertexKeyValue)end_;

        // use curve params as blend ratio between start key and end key.
        float rate = SsInterpolation.Interpolate(curve, time, 0.0f, 1.0f, startTime, endTime);

        // lerp value from start to end.
        SsCurveParams linearCurve = new SsCurveParams();

        linearCurve.Type = SsInterpolationType.Linear;

        for (int i = 0; i < Vertices.Length; ++i)
        {
            Vertices[i].Interpolate(linearCurve, rate, start.Vertices[i], end.Vertices[i], startTime, endTime);
        }
        return(this);
    }
Пример #10
0
	public SsInterpolatable GetInterpolated(SsCurveParams curve, float time, SsInterpolatable start, SsInterpolatable end, int startTime, int endTime)
	{
		var v = new SsPoint();
		return v.Interpolate(curve, time, start, end, startTime, endTime);
	}
Пример #11
0
	public SsInterpolatable Interpolate(SsCurveParams curve, float time, SsInterpolatable start_, SsInterpolatable end_, int startTime, int endTime)
	{
		var start = (SsRect)start_;
		var end = (SsRect)end_;
		Left = SsInterpolation.Interpolate(curve, time, start.Left, end.Left, startTime, endTime);
		Top = SsInterpolation.Interpolate(curve, time, start.Top, end.Top, startTime, endTime);
		Right = SsInterpolation.Interpolate(curve, time, start.Right, end.Right, startTime, endTime);
		Bottom = SsInterpolation.Interpolate(curve, time, start.Bottom, end.Bottom, startTime, endTime);
		return this;
	}
Пример #12
0
    public SsInterpolatable GetInterpolated(SsCurveParams curve, float time, SsInterpolatable start, SsInterpolatable end, int startTime, int endTime)
    {
        var v = new SsVertexKeyValue(((SsVertexKeyValue)end).Vertices.Length);

        return(v.Interpolate(curve, time, start, end, startTime, endTime));
    }
Пример #13
0
    public SsInterpolatable Interpolate(SsCurveParams curve, float time, SsInterpolatable start_, SsInterpolatable end_, int startTime, int endTime)
    {
        var start = (SsColorBlendKeyValue)start_;
        var end   = (SsColorBlendKeyValue)end_;

        if (start.Target == SsColorBlendTarget.None &&
            end.Target == SsColorBlendTarget.None)
        {
#if false // obsolete
            // act as nothing blending when the targets of both keys are none.
            for (int i = 0; i < Colors.Length; ++i)
            {
                Colors[i].R = Colors[i].G = Colors[i].B = Colors[i].A = 0;
            }
            this.Target    = SsColorBlendTarget.None;
            this.Operation = SsColorBlendOperation.Non;
#else
            // not needs to interpolate, just refers to start key.
            Debug.LogError("Must not come here.");
#endif
        }
        else
        {
            for (int i = 0; i < Colors.Length; ++i)
            {
                Colors[i].Interpolate(curve, time, start.Colors[i], end.Colors[i], startTime, endTime);
            }
            bool useStartParam = time < 1 ? true : false;
            if (start.Target == SsColorBlendTarget.None)
            {
                // use the end key colors when the target of start key is none
                for (int i = 0; i < Colors.Length; ++i)
                {
                    Colors[i].R = end.Colors[i].R;
                    Colors[i].G = end.Colors[i].G;
                    Colors[i].B = end.Colors[i].B;
                }
                useStartParam = false;
            }
            else
            if (end.Target == SsColorBlendTarget.None)
            {
                // use the start key colors when the target of end key is none
                for (int i = 0; i < Colors.Length; ++i)
                {
                    Colors[i].R = start.Colors[i].R;
                    Colors[i].G = start.Colors[i].G;
                    Colors[i].B = start.Colors[i].B;
                }
            }
            // inherit target and operation
            if (useStartParam)
            {
                this.Target    = start.Target;
                this.Operation = start.Operation;
            }
            else
            {
                this.Target    = end.Target;
                this.Operation = end.Operation;
            }
        }
        return(this);
    }
Пример #14
0
    public SsInterpolatable GetInterpolated(SsCurveParams curve, float time, SsInterpolatable start, SsInterpolatable end, int startTime, int endTime)
    {
        var v = new SsPaletteKeyValue();

        return(v.Interpolate(curve, time, start, end, startTime, endTime));
    }