Beispiel #1
0
        public void Test_Text_Rotation()
        {
            var plt = new ScottPlot.Plot(400, 300);

            // start with default settings
            var txt = new ScottPlot.Plottable.Text()
            {
                Label = "hello"
            };

            plt.Add(txt);
            var    bmp1  = TestTools.GetLowQualityBitmap(plt);
            string hash1 = ScottPlot.Tools.BitmapHash(bmp1);

            // change the plottable
            txt.Rotation = 45;
            var    bmp2  = TestTools.GetLowQualityBitmap(plt);
            string hash2 = ScottPlot.Tools.BitmapHash(bmp2);

            // measure what changed
            //TestTools.SaveFig(bmp1, "1");
            //TestTools.SaveFig(bmp2, "2");
            Console.WriteLine($"Before: {hash1}");
            Console.WriteLine($"After: {hash2}");

            Assert.AreNotEqual(hash1, hash2);
        }
Beispiel #2
0
        public void Test_Text_FontSize()
        {
            var plt = new ScottPlot.Plot(400, 300);

            // start with default settings
            var txt = new ScottPlot.Plottable.Text()
            {
                Label = "hello", FontSize = 12
            };

            plt.Add(txt);
            var bmp1 = TestTools.GetLowQualityBitmap(plt);

            // change the plottable
            txt.FontSize = 36;
            var bmp2 = TestTools.GetLowQualityBitmap(plt);

            // measure what changed
            //TestTools.SaveFig(bmp1, "1");
            //TestTools.SaveFig(bmp2, "2");
            var before = new MeanPixel(bmp1);
            var after  = new MeanPixel(bmp2);

            Console.WriteLine($"Before: {before}");
            Console.WriteLine($"After: {after}");

            Assert.That(after.IsDarkerThan(before));
        }
Beispiel #3
0
        public void Test_Text_FontBold()
        {
            // bold fonts are supported on all operating systems so only test on windows
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) == false)
            {
                return;
            }

            var plt = new ScottPlot.Plot(400, 300);

            // start with default settings
            var txt = new ScottPlot.Plottable.Text()
            {
                Label = "hello", FontSize = 12
            };

            plt.Add(txt);
            var bmp1 = TestTools.GetLowQualityBitmap(plt);

            // change the plottable
            txt.FontBold = true;
            var bmp2 = TestTools.GetLowQualityBitmap(plt);

            // measure what changed
            //TestTools.SaveFig(bmp1, "1");
            //TestTools.SaveFig(bmp2, "2");
            var before = new MeanPixel(bmp1);
            var after  = new MeanPixel(bmp2);

            Console.WriteLine($"Before: {before}");
            Console.WriteLine($"After: {after}");

            Assert.That(after.IsDarkerThan(before));
        }
Beispiel #4
0
        public void Test_Text_FontColor()
        {
            var plt = new ScottPlot.Plot(400, 300);

            // start with default settings
            var txt = new ScottPlot.Plottable.Text()
            {
                Label = "hello", Color = System.Drawing.Color.Gray
            };

            plt.Add(txt);
            var bmp1 = TestTools.GetLowQualityBitmap(plt);

            // change the plottable
            txt.Color = System.Drawing.Color.Blue;
            var bmp2 = TestTools.GetLowQualityBitmap(plt);

            // measure what changed
            //TestTools.SaveFig(bmp1, "1");
            //TestTools.SaveFig(bmp2, "2");
            var before = new MeanPixel(bmp1);
            var after  = new MeanPixel(bmp2);

            Console.WriteLine($"Before: {before}");
            Console.WriteLine($"After: {after}");

            Assert.That(before.IsGray());
            Assert.That(after.IsNotGray());
            Assert.That(after.IsMoreBlueThan(before));
        }