public Crystal(CrystalMapping matrix, int ruleNumber)
 {
     source = matrix;
     source.SetCellColor(source.GetLength() / 2, source.GetLength() / 2, 1);
     target = new CrystalMapping(source.GetLength());
     rule = new CrystalRule(ruleNumber);
 }
 static void SaveMatrixAsImage(CrystalMapping matrix)
 {
     Bitmap bitmap = new Bitmap(matrix.GetLength(), matrix.GetLength());
     for (int i = 0; i < matrix.GetLength(); i++)
         for (int k = 0; k < matrix.GetLength(); k++)
         {
             if (matrix.GetCellColor(i, k) == 1)
                 bitmap.SetPixel(i, k, Color.White);
             else
                 bitmap.SetPixel(i, k, Color.Black);
         }
     Console.WriteLine(GetNewImageFileName());
     bitmap.Save(GetNewImageFileName(),System.Drawing.Imaging.ImageFormat.Bmp);
 }
 private void DrawMatrix(CrystalMapping matrix)
 {
     SolidBrush myBrush = new SolidBrush(System.Drawing.Color.White);
     for (int i = 0; i < matrix.GetLength(); i++)
     {
         for (int k = 0; k < matrix.GetLength(); k++)
         {
             if (matrix.GetCellColor(i, k) == 1)
                 canvas.FillRectangle(myBrush, new Rectangle(i * SCALE, k * SCALE, SCALE, SCALE));
         }
     }
     myBrush.Dispose();
 }