Exemple #1
0
    public void DisplayEnergy(Grain[,] grains, Graphics g)
    {
        System.Drawing.SolidBrush cellBrushClear = new System.Drawing.SolidBrush(SystemColors.Control);

        for (int y = 0; y < SIZE_Y; y++)
        {
            for (int x = 0; x < SIZE_X; x++)
            {
                EnergyColors.InitializeColors(grains[y, x].Q + 1);

                int colorIndex = grains[y, x].Q;;  //> 1 ? 8 : grains[y, x].Q;

                System.Drawing.SolidBrush cellBrush = new System.Drawing.SolidBrush(EnergyColors.colors[colorIndex]);

                g.FillRectangle(cellBrush, (grains[y, x].X) * CELL_SIZE + (int)GRID_STATE, (grains[y, x].Y) * CELL_SIZE + (int)GRID_STATE,
                                CELL_SIZE - (int)GRID_STATE, CELL_SIZE - (int)GRID_STATE);
            }
        }
    }
Exemple #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // setting new sizes

            SET_SIZES(pictureBox1.Width / CELL_SIZE, pictureBox1.Height / CELL_SIZE);

            // --------

            grid        = new Grid();
            grainGrowth = new Simulation();
            monteCarlo  = new MonteCarlo();

            simulationBitmap = new Bitmap(SIZE_X * CELL_SIZE, SIZE_Y * CELL_SIZE);
            g = Graphics.FromImage(simulationBitmap);

            pictureBox1.Image = simulationBitmap;

            EnergyColors.InitializeColors();

            widthBox.Text  = SIZE_X.ToString();
            heightBox.Text = SIZE_Y.ToString();
        }