Beispiel #1
0
        protected Record2D(Record2D other)
        {
            _Commands.Set(other._Commands);
            _GlobalStyle = other._GlobalStyle?.Clone();

            // whenever the original or the clone changes,
            // this will be refreshed, so it's safe to share.
            _ImmutableKey = other._ImmutableKey;
        }
Beispiel #2
0
        public static Record2D CreateDefaultScene2D()
        {
            var scene = new Record2D();

            scene.DrawLine((2, 2), (25, 25), 1, COLOR.Green);
            scene.DrawCircle((10, 10), 5, COLOR.Blue);

            var charPath = System.IO.Path.Combine(AssetsDir, "Tiles.jpg");
            var cell     = new ImageSource(charPath, (0, 0), (64, 64), (32, 32));

            scene.DrawImage(Matrix3x2.CreateTranslation(2, 2), cell);

            return(scene);
        }
Beispiel #3
0
        public void CreateModel2D()
        {
            var mdl = new Record2D();

            mdl.DrawLine((1, 2), (3, 4), 5, COLOR.Red);
            mdl.DrawCircle((4, 5), 6, COLOR.Blue);
            mdl.DrawPolygon(COLOR.Gray, (1, 1), (2, 2), (3, 3));
            mdl.DrawAsset(System.Numerics.Matrix3x2.Identity, "Hello");

            var lines = mdl.ToLog().ToArray();

            mdl.AttachToCurrentTest("result.svg");
            mdl.AttachToCurrentTest("result.png");
        }
Beispiel #4
0
        public static void AttachToCurrentTest(this Record2D batch, string filePath)
        {
            var ainfo = NUnit.Framework.AttachmentInfo.From(filePath);

            if (filePath.ToLower().EndsWith(".svg"))
            {
                ainfo.WriteObject(f => SVGSceneDrawing2D.SaveToSVG(f, batch));
                return;
            }

            if (filePath.ToLower().EndsWith(".png") || filePath.ToLower().EndsWith(".jpg") || filePath.ToLower().EndsWith(".gif"))
            {
                ainfo.WriteObject(f => Canvas2DFactory.SaveToBitmap(f, 1024, 1024, null, batch));
                return;
            }
        }
Beispiel #5
0
        public void TestAsset2D()
        {
            var model = SceneFactory.CreateDefaultScene2D();

            var r = model.BoundingRect;
            // var c = model.CircleBounds;

            var scene = new Record2D();

            scene.DrawAsset(Matrix3x2.CreateRotation(1) * Matrix3x2.CreateTranslation(50, 50), model);

            // scene.RectBounds.DrawTo(scene, (COLOR.Red, 0.1f));
            // scene.CircleBounds.DrawTo(scene, (COLOR.Red, 0.1f));

            scene.AttachToCurrentTest("document.svg");
            scene.AttachToCurrentTest("document.png");
            // scene.AttachToCurrentTestAsPlot("plot.pdf");
        }