Exemple #1
0
        public void OptimizedCanvas_Renders_Like_Canvas()
        {
            var canvas = new Canvas(100, 100, "");

            canvas.Add(new RectangleShape(0, 0, 20, 20, "white"));
            canvas.Add(new CircleShape(10, 10, 10, "red"));

            canvas.Add(new RectangleShape(80, 80, 20, 20, "white"));
            canvas.Add(new CircleShape(90, 90, 10, "brown"));

            canvas.Layers.Add(new SecondsLayer()
            {
                Offset = new Vertex(50, 50)
            });
            canvas.Add(new RectangleShape(-1, -30, 2, 32, "blue"));
            canvas.Layers.Add(new Layer());

            canvas.Add(new RectangleShape(0, 80, 20, 20, "white"));
            canvas.Add(new CircleShape(10, 90, 10, "green"));

            canvas.Add(new RectangleShape(80, 0, 20, 20, "white"));
            canvas.Add(new CircleShape(90, 10, 10, "purple"));

            var clockCanvas     = new ClockCanvas(new TestTimer(Instant.FromDateTimeOffset(DateTime.Today.AddHours(3).AddMinutes(30).AddSeconds(45))), canvas);
            var optimizedCanvas = clockCanvas.OptimizeFor(1);

            clockCanvas.Update();
            optimizedCanvas.Update();
            var bmp = optimizedCanvas.Render();

            AssertBitmapsAreEqual(clockCanvas.Render(), bmp);
        }
Exemple #2
0
        public void OptimizedCanvas_Renders_Like_Canvas_When_Holes()
        {
            var canvas = new Canvas(100, 100, "");

            canvas.Add(new RectangleShape(0, 0, 20, 20, "black"));
            canvas.Add(new CircleShape(10, 10, 10, "brown"));

            canvas.Add(new RectangleShape(80, 80, 20, 20, "pink"));
            canvas.Add(new CircleShape(90, 90, 10, "red"));

            canvas.Layers.Add(new SecondsLayer()
            {
                Offset = new Vertex(50, 50)
            });
            canvas.Add(new RectangleShape(-1, -30, 2, 32, "blue"));
            canvas.Layers.Add(new Layer());

            canvas.Add(new RectangleShape(0, 80, 20, 20, "yellow"));
            canvas.Add(new CircleShape(10, 90, 10, "purple"));

            canvas.Add(new RectangleShape(80, 0, 20, 20, "white"));
            canvas.Add(new CircleShape(90, 10, 10, "green"));

            canvas.Layers.Add(new CachedLayer());
            canvas.Add(new CircleShape(50, 50, 50, "orange"));
            canvas.Add(new DeleteCircleShape {
                Position = new Vertex(50, 50), Radius = 45
            });

            var clockCanvas     = new ClockCanvas(new TestTimer(Instant.FromDateTimeOffset(DateTime.Today.AddHours(3).AddMinutes(30).AddSeconds(45))), canvas);
            var optimizedCanvas = clockCanvas.OptimizeFor(1);

            clockCanvas.Update();
            optimizedCanvas.Update();
            var bmp = optimizedCanvas.Render();

            AssertBitmapsAreEqual(clockCanvas.Render(), bmp, PixelCompareMode.RGBASimilar);
        }
Exemple #3
0
        public void OptimizedCanvas_Renders_Like_Canvas_When_Bitmap()
        {
            var canvas = new Canvas(273, 273, "");

            canvas.Add(new RectangleShape(0, 0, 20, 20, "white"));
            canvas.Add(new BitmapShape(new FileReader(TestPath("")))
            {
                Left   = 0,
                Top    = 0,
                Width  = 273,
                Height = 273,
                Path   = TestPath(@"default_Test.png")
            });

            var clockCanvas     = new ClockCanvas(new TestTimer(Instant.FromDateTimeOffset(DateTime.Today.AddHours(3).AddMinutes(30).AddSeconds(45))), canvas);
            var optimizedCanvas = clockCanvas.OptimizeFor(1);

            clockCanvas.Update();
            optimizedCanvas.Update();
            var bmp = optimizedCanvas.Render();

            AssertBitmapsAreEqual(clockCanvas.Render(), bmp);
        }