public void ConvertCodeToGridToRectsToScene()
        {
            Code     rasterCode    = RasterLib.RasterApi.CreateCode(Code);
            Grid     grid          = RasterLib.RasterApi.CodeToGrid(rasterCode);
            RectList rectsFromGrid = RasterLib.RasterApi.GridToRects(grid);

            Grid gridFromRects = grid.Clone();

            Assert.IsTrue(grid.IsEqualTo(gridFromRects));

            RasterLib.RasterApi.Renderer.RenderRectsToGrid(rectsFromGrid, gridFromRects);
            Assert.IsTrue(grid.IsEqualTo(gridFromRects));

            Scene    sceneFromRects = RasterLib.RasterApi.RectsToScene(rectsFromGrid);
            RectList rectsFromScene = RasterLib.RasterApi.SceneToRects(sceneFromRects);

            Assert.IsTrue(rectsFromGrid.IsEqualTo(rectsFromScene));

            Grid gridMega = grid.Clone();

            RasterLib.RasterApi.Renderer.RenderRectsToGrid(rectsFromScene, gridMega);

            Assert.IsTrue(grid.IsEqualTo(gridMega));
        }
Exemplo n.º 2
0
        static void Main()
        {
            //Simple Glyphics codeString
            const string code =
                @"Simple,

#Size of Grid
Size3D4 16 16 16;

#Blue color ground
PenColorD4 31 127 255 255;WallCube 1;

#White border around ground's edge
PenColorD4 255 255 255 255;Rect 0 0 0 15 0 15;

#Red box in center
PenColorD4 255 31 127 255;FillRect 4 1 4 11 2 11;

#Green text letter 'A' (ascii 65) on top
PenColorD4 31 255 127 255;Text 6 3 8 65";

            //Glyphics codeString object
            Code rasterCode = RasterLib.RasterApi.CreateCode(code);

            //Save final result to PNG file
            string filename = "..\\..\\" + RasterLib.RasterApi.CodeToCodename(rasterCode).Name + ".PNG";

            Grid grid = RasterLib.RasterApi.CodeToGrid(rasterCode);

            RectList rectsFromGrid = RasterLib.RasterApi.GridToRects(grid);
            Grid     gridFromRects = grid.Clone();

            if (grid.IsEqualTo(gridFromRects) == false)
            {
                Console.WriteLine("Grids are diff");
                return;
            }

            RasterLib.RasterApi.Renderer.RenderRectsToGrid(rectsFromGrid, gridFromRects);
            if (grid.IsEqualTo(gridFromRects) == false)
            {
                Console.WriteLine("Grids are diff");
                return;
            }

            Scene    sceneFromRects = RasterLib.RasterApi.RectsToScene(rectsFromGrid);
            RectList rectsFromScene = RasterLib.RasterApi.SceneToRects(sceneFromRects);

            if (rectsFromGrid.IsEqualTo(rectsFromScene) == false)
            {
                Console.WriteLine("Rects are diff");
                return;
            }

            Grid gridMega = grid.Clone();

            RasterLib.RasterApi.Renderer.RenderRectsToGrid(rectsFromScene, gridMega);

            if (grid.IsEqualTo(gridMega) == false)
            {
                Console.WriteLine("Grids are diff");
                return;
            }

            //Loops Code->Grid->Rects->Scene->Rects->Grid.. and all same
            Console.WriteLine("All conversions are okay");
        }