Example #1
0
        static void Main(string[] args)
        {
            if (args.Length < 4)
            {
                Console.WriteLine("Draws a cube to specified image-file");
                Console.WriteLine("Usage: CubeDrawer <CubeWidth> <CubeHeight> <CubeDepth> <ImageFilePath>");
                Console.WriteLine("Or: CubeDrawer <CubeWidth> <CubeHeight> <CubeDepth> <ImageFilePath> <ImageFileWidth> <ImageFileHeight>");
                return;
            }

            int cubeWidth = 0, cubeHeight = 0, cubeDepth = 0;

            try
            {
                cubeWidth  = ParseDimensionParameter(args[0]);
                cubeHeight = ParseDimensionParameter(args[1]);
                cubeDepth  = ParseDimensionParameter(args[2]);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return;
            }

            string outputFilepath = args[3];

            int outputfileWidth  = 2000;
            int outputfileHeight = 2000;

            if (args.Length == 6)
            {
                outputfileWidth  = ParseDimensionParameter(args[4]);
                outputfileHeight = ParseDimensionParameter(args[5]);
            }


            using (Bitmap bitmap = new Bitmap(outputfileWidth, outputfileHeight))
            {
                Coord3D cubeorigin = new Coord3D(0, 0, 0);

                Cube3D Cube = new Cube3D(cubeorigin, cubeWidth, cubeHeight, cubeDepth);
                using (Graphics graafix = Graphics.FromImage(bitmap))
                {
                    Cube.Draw(graafix, new Coord2D(outputfileWidth / 2, outputfileHeight / 2), outputfileHeight);
                    try
                    {
                        bitmap.Save(outputFilepath);
                    }
                    catch
                    {
                        Console.WriteLine("Could not write to file \"{0}\"", outputFilepath);
                    }
                }
            }
        }
Example #2
0
 public Cube3D(Coord3D bottomLeftOrigin, double width, double height, double depth)
 {
     Corners = new List <Coord3D>();
     Corners.Add(bottomLeftOrigin.Add(0, 0, 0, "LBF", false));              //Left Bottom Front
     Corners.Add(bottomLeftOrigin.Add(width, 0, 0, "RBF", false));          //Right Bottom Front
     Corners.Add(bottomLeftOrigin.Add(0, height, 0, "LTF", false));         //Left Top Front
     Corners.Add(bottomLeftOrigin.Add(width, height, 0, "RTF", false));     //Right Top Front
     Corners.Add(bottomLeftOrigin.Add(0, 0, depth, "LBB", false));          //Left Bottom Back
     Corners.Add(bottomLeftOrigin.Add(width, 0, depth, "RBB", true));       //Right Bottom Back
     Corners.Add(bottomLeftOrigin.Add(0, height, depth, "LTB", false));     //Left Top Back
     Corners.Add(bottomLeftOrigin.Add(width, height, depth, "RTB", false)); //Right Top Back
 }