Пример #1
0
        public Render(string inputFile)
        {
            InitializeComponent();

            _mainFigures = new List<Figure<Point2D, Matrix2D>[]>();
            _matrices = new Matrix2D[4];
            for (var i = 0; i < _matrices.Length; ++i)
                _matrices[i] = new Matrix2D().IdentMatrix<Matrix2D>();
            _transform = new ReduceTransform();

            var parser = new Parser(inputFile);
            InitializeParser(parser);
            Shown += (sender, args) => parser.Start();

            renderPanel.Paint += (sender, args) => RenderPicture(args.Graphics);
        }
Пример #2
0
        private void RecalculateMatrix(int type)
        {
            var moveventMatrix = new Matrix2D();
            var resizeMatrix = new Matrix2D();

            switch (type)
            {
                case 0:
                    MatrixAbstract.Multiply(
                        moveventMatrix.MovementMatrix(0, 1.0 / 3.0 * 200),
                        resizeMatrix.ResizeMatrix(1.0, 1.0),
                        _matrices[0]);
                    MatrixAbstract.Multiply(
                        moveventMatrix.MovementMatrix(0, 1.0 / 3.0 * 200),
                        resizeMatrix.ResizeMatrix(1.0, -1.0),
                        _matrices[1]);
                    MatrixAbstract.Multiply(
                        moveventMatrix.MovementMatrix(-200 / Math.Sqrt(3.0), -2.0 / 3.0 * 200),
                        resizeMatrix.ResizeMatrix(1.0, 1.0),
                        _matrices[2]);
                    MatrixAbstract.Multiply(
                        moveventMatrix.MovementMatrix(200 / Math.Sqrt(3.0), -2.0 / 3.0 * 200),
                        resizeMatrix.ResizeMatrix(1.0, 1.0),
                        _matrices[3]);
                    break;
                case 1:
                    MatrixAbstract.Multiply(
                        moveventMatrix.MovementMatrix(0, -1.0 / 3.0 * 100),
                        resizeMatrix.ResizeMatrix(2.0, 2.0),
                        _matrices[0]);
                    MatrixAbstract.Multiply(
                        moveventMatrix.MovementMatrix(-1000, -1000),
                        resizeMatrix.ResizeMatrix(1, 1),
                        _matrices[1]);
                    MatrixAbstract.Multiply(
                        moveventMatrix.MovementMatrix(-1000, -1000),
                        resizeMatrix.ResizeMatrix(1, 1),
                        _matrices[2]);
                    MatrixAbstract.Multiply(
                        moveventMatrix.MovementMatrix(-1000, -1000),
                        resizeMatrix.ResizeMatrix(1, 1),
                        _matrices[3]);
                    break;
                case 2:
                    MatrixAbstract.Multiply(
                        moveventMatrix.MovementMatrix(-1000, -1000),
                        resizeMatrix.ResizeMatrix(1, 1),
                        _matrices[0]);
                    MatrixAbstract.Multiply(
                        moveventMatrix.MovementMatrix(0, -1.0 / 3.0 * 100),
                        resizeMatrix.ResizeMatrix(2.0, 2.0),
                        _matrices[1]);
                    MatrixAbstract.Multiply(
                        moveventMatrix.MovementMatrix(-1000, -1000),
                        resizeMatrix.ResizeMatrix(1, 1),
                        _matrices[2]);
                    MatrixAbstract.Multiply(
                        moveventMatrix.MovementMatrix(-1000, -1000),
                        resizeMatrix.ResizeMatrix(1, 1),
                        _matrices[3]);
                    break;
                case 3:
                    MatrixAbstract.Multiply(
                        moveventMatrix.MovementMatrix(-1000, -1000),
                        resizeMatrix.ResizeMatrix(1, 1),
                        _matrices[0]);
                    MatrixAbstract.Multiply(
                        moveventMatrix.MovementMatrix(-1000, -1000),
                        resizeMatrix.ResizeMatrix(1, 1),
                        _matrices[1]);
                    MatrixAbstract.Multiply(
                        moveventMatrix.MovementMatrix(0, -1.0 / 3.0 * 100),
                        resizeMatrix.ResizeMatrix(2.0, 2.0),
                        _matrices[2]);
                    MatrixAbstract.Multiply(
                        moveventMatrix.MovementMatrix(-1000, -1000),
                        resizeMatrix.ResizeMatrix(1, 1),
                        _matrices[3]);
                    break;
                case 4:
                    MatrixAbstract.Multiply(
                        moveventMatrix.MovementMatrix(-1000, -1000),
                        resizeMatrix.ResizeMatrix(1, 1),
                        _matrices[0]);
                    MatrixAbstract.Multiply(
                        moveventMatrix.MovementMatrix(-1000, -1000),
                        resizeMatrix.ResizeMatrix(1, 1),
                        _matrices[1]);
                    MatrixAbstract.Multiply(
                        moveventMatrix.MovementMatrix(-1000, -1000),
                        resizeMatrix.ResizeMatrix(1, 1),
                        _matrices[2]);
                    MatrixAbstract.Multiply(
                        moveventMatrix.MovementMatrix(0, -1.0 / 3.0 * 100),
                        resizeMatrix.ResizeMatrix(2.0, 2.0),
                        _matrices[3]);
                    break;
            }
        }