Esempio n. 1
0
        /// <summary>
        /// This method paints the matrix in the Paint Box
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PBAutomataSimulator_Paint(object sender, PaintEventArgs e)
        {
            int x_size = matrix.GetLength(0);
            int y_size = matrix.GetLength(1);

            total_cells = x_size * y_size;

            Graphics graphics = e.Graphics;

            for (int row = 0; row < x_size; row++)
            {
                for (int col = 0; col < y_size; col++)
                {
                    if (matrix[row, col] != DEAD)
                    {
                        SolidBrush aliveCellColor = new SolidBrush(ColorHandler.fromIntToGradient(matrix[row, col], ALIVE));
                        graphics.FillRectangle(aliveCellColor, row * cellArea, col * cellArea, cellArea, cellArea);
                    }
                    else
                    {
                        graphics.FillRectangle(dead, row * cellArea, col * cellArea, cellArea, cellArea);
                    }
                }
            }

            for (int y = 0; y < y_size; y++)
            {
                graphics.DrawLine(grid, 0, y * cellArea, total_cells * cellArea, y * cellArea);
            }

            for (int x = 0; x < x_size; x++)
            {
                graphics.DrawLine(grid, x * cellArea, 0, x * cellArea, total_cells * cellArea);
            }
        }
Esempio n. 2
0
        public void paintNormalSpace(Graphics graphics)
        {
            int x_size = matrix.GetLength(0);
            int y_size = matrix.GetLength(1);

            total_cells = x_size * y_size;

            for (int row = 0; row < x_size; row++)
            {
                for (int col = 0; col < y_size; col++)
                {
                    if (matrix[row, col] != DEAD)
                    {
                        SolidBrush aliveCellColor = new SolidBrush(ColorHandler.fromIntToGradient(matrix[row, col], ALIVE));
                        graphics.FillRectangle(aliveCellColor, row * cellArea, col * cellArea, cellArea, cellArea);
                    }
                    else
                    {
                        graphics.FillRectangle(dead, row * cellArea, col * cellArea, cellArea, cellArea);
                    }
                }
            }

            for (int y = 0; y < y_size; y++)
            {
                graphics.DrawLine(grid, 0, y * cellArea, total_cells * cellArea, y * cellArea);
            }

            for (int x = 0; x < x_size; x++)
            {
                graphics.DrawLine(grid, x * cellArea, 0, x * cellArea, total_cells * cellArea);
            }
        }
Esempio n. 3
0
        private void button2_Click_1(object sender, EventArgs e)
        {
            Color color = getColor();

            alive = new SolidBrush(color);
            ALIVE = ColorHandler.fromColorToInt(color);
            initMosaics();
            PBAutomataSimulator.Invalidate();
        }