public static void SuperDebug(ScratchControl ctl) { Grid grid = null; if (ctl.FileNameInCode == null && ctl.FileNameInImage == null && ctl.FileNameInStl == null && ctl.FileNameInSvg == null) { Console.WriteLine("Must have FileNameIn type."); return; } if (ctl.FileNameInSvg != null) { Console.WriteLine("SVG Input filename: {0}", ctl.FileNameInSvg); string codeString = Svg2Gly.ConvertSvg2Gly(ctl.FileNameInSvg); Console.WriteLine("SVG:\n" + codeString); Code code = RasterLib.RasterApi.CreateCode(codeString); if (ctl.Resize != null) { code = RasterLib.RasterApi.CodeToRescaledCode(code, ctl.Resize[0], ctl.Resize[1], ctl.Resize[2]); } Console.WriteLine("Code: {0}\n", codeString); grid = RasterLib.RasterApi.CodeToGrid(code); } else if (ctl.FileNameInStl != null) { grid = RasterLib.RasterApi.CreateGrid(64, 64, 64, 4); Console.WriteLine("STL Input filename: {0}", ctl.FileNameInStl); //Load the triangles from the STL file and reduce to a unit 1x1x1 size Triangles triangles = RasterLib.RasterApi.StlToTriangles(ctl.FileNameInStl); triangles.ReduceToUnit(); Console.WriteLine("Triangle count: {0}", triangles.Count); //Render the triangles to the grid, will autosize to grid size RasterLib.RasterApi.Renderer.RenderTrianglesToGrid(triangles, grid); } else if (ctl.FileNameInImage != null) { Grid gridImg = GraphicsApi.FileToGrid(ctl.FileNameInImage); GridContext gc = new GridContext(gridImg); RasterLib.RasterApi.Painter.FlipY(gc); int div = 63;// 31;// 15; grid = RasterLib.RasterApi.CreateGrid(gridImg.SizeX, 255 / div + 1, gridImg.SizeY, 4); Console.WriteLine("Extruding"); Extrusion(grid, gridImg, div); Console.WriteLine("Rendering"); Grid gridIsometricScaledQuick = RasterLib.RasterApi.Renderer.RenderIsometricCellsScaled(grid, 0, 0, 0, 0, 4, 4); Console.WriteLine("Saving"); GraphicsApi.SaveFlatPng(ctl.FileNameOutIsometric, gridIsometricScaledQuick); Console.WriteLine("Saved"); } else if (ctl.FileNameInCode != null) { string codeString = RasterLib.RasterApi.ReadGlyc(ctl.FileNameInCode).Replace(';', '\n'); Code code = RasterLib.RasterApi.CreateCode(codeString); Console.WriteLine("Code: {0}\n", codeString); Codename codename = RasterLib.RasterApi.CodeToCodename(code); Console.WriteLine("Codename: {0}\n", codename); if (ctl.OutputTokens) { TokenList glyphTokens = RasterLib.RasterApi.CodeToTokens(code); string tokenDesc = "Tokens:\n" + glyphTokens + "\n"; Console.WriteLine(tokenDesc); } if (ctl.Resize != null) { code = RasterLib.RasterApi.CodeToRescaledCode(code, ctl.Resize[0], ctl.Resize[1], ctl.Resize[2]); } grid = RasterLib.RasterApi.CodeToGrid(code); Console.WriteLine("Grid: {0}\n", grid); if (ctl.FileNameOutOrthogonalAnimated || ctl.FileNameOutIsometricAnimated) { ControlAnimator.DoAnimation(ctl, code.codeString, codename.ToString()); } } //DownSolver ds = new GeneralLibrary.DownSolver(codeString); if (ctl.OutputBytes && grid != null) { string bytesDesc = RasterLib.RasterApi.BytesToString(grid.CloneData()); Console.WriteLine("GridBytes:\n{0}\n", bytesDesc); } RectList rects = RasterLib.RasterApi.GridToRects(grid); if (ctl.OutputRectangles)//rects { Console.WriteLine("Rects: {0}\n{1}", rects.Count, rects); RasterLib.RasterApi.BuildCircuit(rects, true); string serialized = RasterLib.RasterApi.RectsToSerializedRectsLimit255(rects).SerializedData; Console.WriteLine("Serialized Rects: (len={0})\n{1}\n", serialized.Length, serialized); RasterLib.RasterApi.SaveFlatText("..\\..\\foo.txt", serialized); //Clipboard.SetText(serialized); SerializedRects serializedRects = new SerializedRects(serialized); RectList rectsDecoded = RectConverter.SerializedRectsToRects(serializedRects); int count = 0; Console.WriteLine("# of Decoded Rects = {0}", rectsDecoded.Count); foreach (Rect rect in rectsDecoded) { Console.WriteLine(count + " : " + rect); count++; } } if (ctl.OutputRenderedAscii) { Console.WriteLine("2d view:\n{0}", RasterLib.RasterApi.Renderer.GridToHexDescription(grid)); Console.WriteLine("3d view:\n{0}", RasterLib.RasterApi.Renderer.GridTo3DDescription(grid, 0, 0, 0)); } if (ctl.OutputSceneGraph) { Scene scene = RasterLib.RasterApi.RectsToScene(rects); Console.WriteLine("Scene: {0}", scene); QuadList quads = RasterLib.RasterApi.RectsToQuads(rects); Console.WriteLine("Quads: {0}", quads); Triangles triangles = RasterLib.RasterApi.QuadsToTriangles(quads); Console.WriteLine("Triangles: {0}", triangles); } if (ctl.FileNameOutStl != null) { ControlStl.Control(ctl, rects); } if (ctl.FileNameOutOrthogonal != null) { Console.WriteLine("Orthogonal Rendering.."); Grid gridOrthogonal = RasterLib.RasterApi.Renderer.RenderObliqueCells(grid); GraphicsApi.SaveFlatPng(ctl.FileNameOutOrthogonal, gridOrthogonal); } if (ctl.FileNameOutIsometric != null) { Console.WriteLine("Isometric Rendering.."); if (ctl.IsometricCellWidth < 1) { ctl.IsometricCellWidth = 1; } if (ctl.IsometricCellHeight < 1) { ctl.IsometricCellHeight = 1; } Grid gridIsometricScaled = RasterLib.RasterApi.Renderer.RenderIsometricCellsScaled(grid, ctl.IsometricBgRgba[0], ctl.IsometricBgRgba[1], ctl.IsometricBgRgba[2], ctl.IsometricBgRgba[3], ctl.IsometricCellWidth, ctl.IsometricCellHeight); GraphicsApi.SaveFlatPng(ctl.FileNameOutIsometric, gridIsometricScaled); } Console.WriteLine(); }
//"../../../../Glyph Cores/Nexus.glyc" -sr static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine("Usage : GlyView <filename> "); Console.WriteLine(" Output types:"); Console.WriteLine(" -c : display code "); Console.WriteLine(" -r : display rects "); Console.WriteLine(" -sr : display serialized rects "); Console.WriteLine(" -q : display quads "); Console.WriteLine(" -t : display triangles "); Console.WriteLine(" -sg : display scenegraph"); Console.WriteLine(" -ci : display circuit"); return; } string filename = args[0]; Options options = new Options(); for (int i = 0; i < args.Length; i++) { if (args[i] == "-c") { options.displayCode = true; } if (args[i] == "-r") { options.displayRects = true; } if (args[i] == "-sr") { options.displaySerializedRects = true; } if (args[i] == "-q") { options.displayQuads = true; } if (args[i] == "-t") { options.displayTriangles = true; } if (args[i] == "-sg") { options.displaySceneGraph = true; } if (args[i] == "-ci") { options.displayCircuit = true; } } string codeString = RasterLib.RasterApi.ReadGlyc(filename); Code code = new Code(codeString); if (options.displayCode) { Console.WriteLine("Code: " + codeString); } Grid grid = RasterLib.RasterApi.CodeToGrid(code); if (grid != null) { //string bytesDesc = RasterLib.RasterApi.BytesToString(grid.CloneData()); //Console.WriteLine("GridBytes:\n{0}\n", bytesDesc); } RectList rects = RasterLib.RasterApi.GridToRects(grid); //rects { if (options.displayRects) { Console.WriteLine("Rects: {0}\n{1}", rects.Count, rects); } RasterLib.RasterApi.BuildCircuit(rects, options.displayCircuit); string serialized = RasterLib.RasterApi.RectsToSerializedRectsLimit255(rects).SerializedData; if (options.displaySerializedRects) { Console.WriteLine("{0}\n", serialized); } //Console.WriteLine("Serialized Rects: (len={0})\n{1}\n", serialized.Length, serialized); SerializedRects serializedRects = new SerializedRects(serialized); RectList rectsDecoded = RectConverter.SerializedRectsToRects(serializedRects); } //if (ctl.OutputRenderedAscii) { //Console.WriteLine("2d view:\n{0}", RasterLib.RasterApi.Renderer.GridToHexDescription(grid)); //Console.WriteLine("3d view:\n{0}", RasterLib.RasterApi.Renderer.GridTo3DDescription(grid, 0, 0, 0)); } //if (ctl.OutputSceneGraph) { Scene scene = RasterLib.RasterApi.RectsToScene(rects); if (options.displaySceneGraph) { Console.WriteLine("Scene: {0}", scene); } QuadList quads = RasterLib.RasterApi.RectsToQuads(rects); if (options.displayQuads) { Console.WriteLine("Quads: {0}", quads); } Triangles triangles = RasterLib.RasterApi.QuadsToTriangles(quads); if (options.displayTriangles) { Console.WriteLine("Triangles: {0}", triangles); } } }