Exemple #1
0
        //helper methods
        private static void RenderGrid(CDrawer canvas, Color[,] colAr)
        {
            canvas.Clear();

            for (int iR = 0; iR < canvas.ScaledHeight; iR++)
                for (int iC = 0; iC < canvas.ScaledWidth; iC++)
                    canvas.SetBBScaledPixel(iC, iR, colAr[iR, iC]);

            for (int i = 0; i < canvas.ScaledWidth; i++)
                canvas.AddLine(i, 0, i, canvas.ScaledWidth, Color.Black, 1);

            for (int i = 0; i < canvas.ScaledHeight; i++)
                canvas.AddLine(0, i, canvas.ScaledWidth, i, Color.Black, 1);

            canvas.Render();
        }
Exemple #2
0
 public static void DisplayLife(CDrawer lifeField, byte[,] lifeArray)
 {
     //Loops once for each row in the array
     for (int a = 0; a < lifeArray.GetLength(0); a++)
     {
         //Loops once for each column in each row
         for (int b = 0; b < lifeArray.GetLength(1); b++)
         {
             //Draws a live cell in specified location if index is 1
             if (lifeArray[a, b] == 1)
             {
                 lifeField.SetBBScaledPixel(b, a, drawColor);
             }
             //Draws a Dead cell in each index if index is 0
             else if (lifeArray[a, b] == 0)
             {
                 lifeField.SetBBScaledPixel(b, a, Color.Black);
             }
             //Draws a gray border around entire field
             if (lifeArray[a, b] != 1 && lifeArray[a, b] != 0)
             {
                 lifeField.SetBBScaledPixel(b, a, Color.Gray);
             }
         }
     }
 }
Exemple #3
0
        static void RandomBlocks()
        {
            Random rnd = new Random();
            CDrawer can = new CDrawer();
            System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
            watch.Reset();
            watch.Start();
            can.AddText("Random Known Colors SetBBPixel : 2s", 28, 0, 0, can.ScaledWidth, can.ScaledHeight, Color.White);
            can.AddText("Random Known Colors SetBBPixel : 2s", 28, 2, 2, can.ScaledWidth + 2, can.ScaledHeight + 2, Color.Black);
            while (watch.ElapsedMilliseconds < 2000)
            {
                can.SetBBPixel(rnd.Next(can.ScaledWidth), rnd.Next(can.ScaledHeight), RandColor.GetKnownColor());
            }
            can.Close();

            can = new CDrawer(800, 800);
            can.Scale = 10;
            Console.WriteLine("Random Known Colors SetBBScaledPixel : 2s");
            watch.Reset();
            watch.Start();
            can.AddText("Random Known Colors SetBBScaledPixel : 2s", 24);
            while (watch.ElapsedMilliseconds < 2000)
            {
                can.SetBBScaledPixel(rnd.Next(can.ScaledWidth), rnd.Next(can.ScaledHeight), RandColor.GetKnownColor());
            }
            can.Close();
        }