Пример #1
0
        public void ColorShouldBeSameAtStartOfAnimation()
        {
            RgbColor newColor = animation.GetColor(StartTime, StartTime);

            Assert.AreEqual(targetColor.ToString(), newColor.ToString());

            Assert.IsTrue(!animation.AnimationFinished);
        }
Пример #2
0
        public void AfterAnimationHasFinishedBeyondTime()
        {
            RgbColor newColor = animation.GetColor(StartTime, StartTime.AddMilliseconds(animation.DurationBlink * 10));

            Assert.AreEqual(RgbColor.Black().ToString(), newColor.ToString());
            Assert.IsTrue(animation.AnimationFinished);
        }
Пример #3
0
        public void TargetColorHalfWaySecondPulse()
        {
            animation.RepeatPulse = 2;
            RgbColor newColor = animation.GetColor(StartTime, StartTime.AddMilliseconds(animation.DurationPulse + animation.DurationPulse / 2));

            Assert.AreEqual(targetColor.ToString(), newColor.ToString());
        }
Пример #4
0
        public void GreenToRed([Range(0, 255)] int time)
        {
            refColor = RgbColor.FromRgb(0, 255, 0);
            RgbColor newColor = animation.GetColor(StartTime, StartTime.AddMilliseconds(time), refColor);

            Assert.AreEqual(RgbColor.FromRgb(time, 255 - time, 0).ToString(), newColor.ToString());
        }
Пример #5
0
        public void BlackColorBeyondTimeAndFinished()
        {
            RgbColor newColor = animation.GetColor(StartTime, StartTime.AddMilliseconds(animation.DurationPulse * 10), RgbColor.Black());

            Assert.AreEqual(RgbColor.Black().ToString(), newColor.ToString());
            Assert.IsTrue(animation.AnimationFinished);
        }
Пример #6
0
        public void RgbaToColorString()
        {
            RgbColor rgba = new RgbColor {
                Red = 255, Green = 205, Blue = 100, Alpha = 0.72d
            };

            Assert.AreEqual("rgba(255,205,100,0.72)", rgba.ToString());
        }
Пример #7
0
        public void Mix4Bit()
        {
            RgbColor rgb  = RgbColor.Parse("#FF00007F");
            RgbColor rgb2 = RgbColor.Parse("#0f08");
            RgbColor mix  = rgb.Mix(rgb2, 0.5);

            Assert.AreEqual("rgba(123,131,0,0.515)", mix.ToString());
        }
Пример #8
0
        public void RgbToColorString2()
        {
            RgbColor rgb = new RgbColor {
                Red = 255, Green = 255, Blue = 255
            };

            Assert.AreEqual("#fff", rgb.ToString());
        }
Пример #9
0
        public void Mix2ColorsWith25()
        {
            RgbColor rgb  = RgbColor.Parse("#f00");
            RgbColor rgb2 = RgbColor.Parse("#00f");
            RgbColor mix  = rgb.Mix(rgb2, 0.25);

            Assert.AreEqual("#3f00bf", mix.ToString());
        }
Пример #10
0
        public void MixRgba()
        {
            RgbColor rgb  = RgbColor.Parse("rgba(255, 0, 0, 0.5)");
            RgbColor rgb2 = RgbColor.Parse("#00f");
            RgbColor mix  = rgb.Mix(rgb2, 0.5);

            Assert.AreEqual("rgba(63,0,191,0.75)", mix.ToString());
        }
Пример #11
0
        public void BlackAtTheEndSecondPulse()
        {
            animation.RepeatPulse = 2;
            RgbColor newColor = animation.GetColor(StartTime, StartTime.AddMilliseconds(animation.DurationPulse * 2));

            Assert.AreEqual(RgbColor.Black().ToString(), newColor.ToString());
            Assert.IsTrue(animation.AnimationFinished);
        }
Пример #12
0
        public void RgbToColorString()
        {
            RgbColor rgb = new RgbColor {
                Red = 255, Green = 205, Blue = 100
            };

            Assert.AreEqual("#ffcd64", rgb.ToString());
        }
        public void ColorShouldBeSameDuringAnimation()
        {
            for (int i = 0; i < animation.DelaySetColor; i++)
            {
                RgbColor newColor = animation.GetColor(StartTime, StartTime.AddMilliseconds(i));

                Assert.AreEqual(targetColor.ToString(), newColor.ToString());
            }
        }
Пример #14
0
        public void TurnOffHalfWayThrough()
        {
            for (int i = animation.DurationBlink / 2; i < animation.DurationBlink; i++)
            {
                RgbColor newColor = animation.GetColor(StartTime, StartTime.AddMilliseconds(i));

                Assert.AreEqual(RgbColor.Black().ToString(), newColor.ToString());
            }
            Assert.IsTrue(!animation.AnimationFinished);
        }
Пример #15
0
        public void RedToBlue([Range(0, 255)] int time)
        {
            refColor        = RgbColor.FromRgb(255, 0, 0);
            targetColor     = RgbColor.FromRgb(0, 0, 255);
            animation.Color = targetColor;

            RgbColor newColor = animation.GetColor(StartTime, StartTime.AddMilliseconds(time), refColor);

            Assert.AreEqual(RgbColor.FromRgb(255 - time, 0, time).ToString(), newColor.ToString());
        }
Пример #16
0
        public void BlueToGreen([Range(0, 255)] int time)
        {
            refColor        = RgbColor.FromRgb(0, 0, 255);
            targetColor     = RgbColor.FromRgb(0, 255, 0);
            animation.Color = targetColor;
            RgbColor newColor = animation.GetColor(StartTime, StartTime.AddMilliseconds(time), refColor);

            Assert.AreEqual(RgbColor.FromRgb(0, time, 255 - time).ToString(), newColor.ToString());
            Assert.IsTrue(!animation.AnimationFinished);
        }
Пример #17
0
        public void TurnOnFirstHalf()
        {
            for (int i = 0; i < animation.DurationBlink / 2; i++)
            {
                RgbColor newColor = animation.GetColor(StartTime, StartTime.AddMilliseconds(i));

                Assert.AreEqual(targetColor.ToString(), newColor.ToString());
            }
            Assert.IsTrue(!animation.AnimationFinished);
        }
Пример #18
0
        /// <summary>
        /// Convert a color to a string
        /// </summary>
        /// <param name="color">the windows forms color</param>
        /// <returns>the color in a string</returns>
        private static string ConvertColor(System.Drawing.Color color)
        {
            int i = color.ToArgb();
            byte r = (byte)((i >> 16) & 255);
            byte g = (byte)((i >> 8) & 255);
            byte b = (byte)(i & 255);

            RgbColor rgbColor = new RgbColor(r, g, b);
            return rgbColor.ToString();
        }
Пример #19
0
        public void TurnOnSecondBlink()
        {
            animation.RepeatBlink = 2;
            for (int i = animation.DurationBlink; i < animation.DurationBlink * 2 - animation.DurationBlink / 2; i++)
            {
                RgbColor newColor = animation.GetColor(StartTime, StartTime.AddMilliseconds(i));

                Assert.AreEqual(targetColor.ToString(), newColor.ToString());
            }
            Assert.IsTrue(!animation.AnimationFinished);
        }
Пример #20
0
    /// <summary>
    /// Tints using alpha channel
    /// </summary>
    private static void TintUsingAlpha(RgbColor color)
    {
        using (var bitmap = new Bitmap("../../../../_Input/Chicago.jpg"))
        {
            using (var result = new Aurigma.GraphicsMill.Bitmap(bitmap.Width, bitmap.Height, PixelFormat.Format24bppRgb, color))
            {
                bitmap.ColorManagement.Convert(PixelFormat.Format8bppGrayscale);
                bitmap.Transforms.Invert();

                result.Channels.SetAlpha(bitmap);
                result.Channels.RemoveAlpha(RgbColor.White);

                result.Save("../../../../_Output/TintUsingAlpha_" + color.ToString() + ".jpg");
            }
        }
    }
Пример #21
0
        public void OpacifyHsla()
        {
            RgbColor rgb = RgbColor.Parse("hsla(0, 0%, 100%, .3)").Opacify(0.5);

            Assert.AreEqual("rgba(255,255,255,0.8)", rgb.ToString());
        }
Пример #22
0
        public void OpacifyRgba01()
        {
            RgbColor rgb = RgbColor.Parse("rgba(101, 100, 205, 0.7)").Opacify(0.1);

            Assert.AreEqual("rgba(101,100,205,0.8)", rgb.ToString());
        }
Пример #23
0
        public void OpacifyNotBelow0()
        {
            RgbColor rgb = RgbColor.Parse("rgba(255, 0, 0, .2)").Opacify(-0.5);

            Assert.AreEqual("rgba(255,0,0,0)", rgb.ToString());
        }
Пример #24
0
        public void OpacifyHsl()
        {
            RgbColor rgb = RgbColor.Parse("hsl(0, 0%, 100%)").Opacify(0.2);

            Assert.AreEqual("#fff", rgb.ToString());
        }
Пример #25
0
        public void Hex()
        {
            RgbColor rgb = RgbColor.Parse("#00f").Shade(0.25);

            Assert.AreEqual("#0000bf", rgb.ToString());
        }
Пример #26
0
 protected internal static string GetName(RgbColor rgbColor)
 {
     return(rgbColor?.ToString());
 }
Пример #27
0
        public void Hex4Bit()
        {
            RgbColor rgb = RgbColor.Parse("#0f08").Shade(0.25);

            Assert.AreEqual("rgba(0,132,0,0.8825000000000001)", rgb.ToString());
        }
Пример #28
0
        public void Hex8Bit()
        {
            RgbColor rgb = RgbColor.Parse("#000fffcc").Shade(0.25);

            Assert.AreEqual("rgba(0,10,170,0.95)", rgb.ToString());
        }
        public void ColorShouldBeSameInTheMiddleOfAnimation()
        {
            RgbColor newColor = animation.GetColor(StartTime, StartTime.AddMilliseconds(animation.DelaySetColor / 2));

            Assert.AreEqual(targetColor.ToString(), newColor.ToString());
        }
Пример #30
0
        public void OpacifyNotOver1()
        {
            RgbColor rgb = RgbColor.Parse("rgba(255, 0, 0, .8)").Opacify(0.5);

            Assert.AreEqual("#f00", rgb.ToString());
        }
Пример #31
0
        public void OpacifyFff()
        {
            RgbColor rgb = RgbColor.Parse("#fff").Opacify(0.1);

            Assert.AreEqual("#fff", rgb.ToString());
        }