Esempio n. 1
0
        private TLBaseKeyFrame AddKeyFrame(double Time, RGBAColor Color)
        {
            //called via configpinchanged and gui-doubleclick
            float           sliceheight = FPin.Height / FPin.SliceCount;
            float           slicetop    = FPin.Top + FSliceIndex * sliceheight;
            TLColorKeyFrame k           = new TLColorKeyFrame(FPin.Transformer, Time, Color, slicetop, sliceheight);

            FKeyFrames.Add(k);

            return(k);
        }
Esempio n. 2
0
        public override void SaveKeyFrames()
        {
            FKeyTime.SliceCount  = FKeyFrames.Count;
            FKeyColor.SliceCount = FKeyFrames.Count;

            FKeyFrames.Sort(delegate(TLBaseKeyFrame k0, TLBaseKeyFrame k1) { return(k0.Time.CompareTo(k1.Time)); });

            for (int i = 0; i < FKeyFrames.Count; i++)
            {
                FKeyTime.SetValue(i, FKeyFrames[i].Time);
                TLColorKeyFrame kfc = (FKeyFrames[i] as TLColorKeyFrame);
                FKeyColor.SetColor(i, kfc.RGBAColor);
            }
        }
Esempio n. 3
0
        public override void Evaluate(double CurrentTime)
        {
            base.Evaluate(CurrentTime);

            if (FKeyFrames.Count == 0)
            {
                FOutput = VColor.Black;
            }
            else
            {
                TLColorKeyFrame from = (TLColorKeyFrame)FKeyFrames.FindLast(delegate(TLBaseKeyFrame k) { return(k.Time <= CurrentTime); });
                TLColorKeyFrame to   = (TLColorKeyFrame)FKeyFrames.Find(delegate(TLBaseKeyFrame k) { return(k.Time > CurrentTime); });

                if (from == null)
                {
                    from = to;
                }
                if (to == null)
                {
                    to = from;
                }

                /*
                 *
                 * int a1, r1, g1, b1, a2, r2, g2, b2;
                 * a1 = from.Color.A;
                 * a2 = to.Color.A;
                 * r1 = from.Color.R;
                 * r2 = to.Color.R;
                 * g1 = from.Color.G;
                 * g2 = to.Color.G;
                 * b1 = from.Color.B;
                 * b2 = to.Color.B;
                 *
                 * double tSpan, f, tCurrent;
                 * tSpan = to.Time - from.Time;
                 * tCurrent = CurrentTime - from.Time;
                 *
                 * if (tSpan == 0)
                 *      f = 0;
                 * else
                 *      f = tCurrent / tSpan;
                 *
                 * ;
                 *
                 * int a, r, g, b;
                 *
                 * a = (int) Math.Round(a2 * f + a1 * (1-f));
                 * r = (int) Math.Round(r2 * f + r1 * (1-f));
                 * g = (int) Math.Round(g2 * f + g1 * (1-f));
                 * b = (int) Math.Round(b2 * f + b1 * (1-f));
                 */

                double tSpan, f, tCurrent;
                tSpan    = to.Time - from.Time;
                tCurrent = CurrentTime - from.Time;

                if (tSpan == 0)
                {
                    f = 0;
                }
                else
                {
                    f = tCurrent / tSpan;
                }
                FOutput = VColor.LerpRGBA(from.RGBAColor, to.RGBAColor, f);
            }

            double h, s, v, a;

            VColor.RGBtoHSV(FOutput.R, FOutput.G, FOutput.B, out h, out s, out v);
            a = FOutput.A;

            OutputAsString = "H: " + h.ToString("f2") + " S: " + s.ToString("f2") + " V: " + v.ToString("f2") + " A: " + a.ToString("f2");
        }