Пример #1
0
        static void ClickEllipses()
        {
            Random rnd = new Random();
            CDrawer can = new CDrawer();
            System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
            watch.Reset();
            watch.Start();
            can.AddText("Random Bounding Box Ellipses : 2s", 28, 0, 0, can.ScaledWidth, can.ScaledHeight, Color.White);
            can.AddText("Random Bounding Box Ellipses : 2s", 28, 2, 2, can.ScaledWidth + 2, can.ScaledHeight + 2, Color.Black);
            while (watch.ElapsedMilliseconds < 5000)
            {
                Point p = new Point(rnd.Next(-50, can.ScaledWidth + 50), rnd.Next(-50, can.ScaledHeight - 50));
                switch (rnd.Next(6))
                {
                    case 0:
                        can.AddEllipse(p.X, p.Y, 100, 100);
                        break;
                    case 1:
                        can.AddEllipse(p.X, p.Y, 100, 100, RandColor.GetKnownColor(), rnd.Next(1, 4), RandColor.GetKnownColor());
                        break;
                    case 2:
                        can.AddPolygon(p.X, p.Y, 100, rnd.Next(3, 8));
                        break;
                    case 3:
                        can.AddPolygon(p.X, p.Y, 100, rnd.Next(3, 8), rnd.NextDouble() * Math.PI, RandColor.GetKnownColor(), 2, RandColor.GetKnownColor());
                        break;
                    case 4:
                        can.AddRectangle(p.X, p.Y, 100, 100);
                        break;
                    case 5:
                        can.AddRectangle(p.X, p.Y, 100, 100, RandColor.GetKnownColor(), rnd.Next(1, 4), RandColor.GetKnownColor());
                        break;
                    default:
                        break;
                }
                System.Threading.Thread.Sleep(100);

            }
            can.Close();

            can = new CDrawer(1000, 400, false);
            //System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
            watch.Reset();
            watch.Start();
            can.AddText("Random Bounding Box Ellipses : 2s", 28, 0, 0, can.ScaledWidth, can.ScaledHeight, Color.White);
            can.AddText("Random Bounding Box Ellipses : 2s", 28, 2, 2, can.ScaledWidth + 2, can.ScaledHeight + 2, Color.Black);
            while (watch.ElapsedMilliseconds < 2000)
            {
                Point p = new Point(rnd.Next(50, can.ScaledWidth - 50), rnd.Next(50, can.ScaledHeight - 50));
                can.AddCenteredEllipse(p.X, p.Y, 100, 100, RandColor.GetKnownColor(), 2, Color.White);
                can.AddCenteredEllipse(p.X, p.Y, 5, 5, RandColor.GetKnownColor(), 1, Color.Red);
                System.Threading.Thread.Sleep(100);

            }
            can.Render();
            System.Threading.Thread.Sleep(1000);
            can.Close();
        }
Пример #2
0
        public void Show(CDrawer canvas, int ballCount)
        {
            Color complimentColor = Color.FromArgb(BallColor.ToArgb() ^ 0x00FFFFFF);

            canvas.AddCenteredEllipse(_ballLocation.X, _ballLocation.Y, _ballRadius * 2, _ballRadius * 2, BallColor);
            canvas.AddText(ballCount.ToString(), 14, _ballLocation.X - _ballRadius, _ballLocation.Y - _ballRadius, _ballRadius*2, _ballRadius*2, complimentColor);
        }
Пример #3
0
 public void Show(CDrawer Canvas, int num)
 {
     Canvas.AddCenteredEllipse(newPoint.X, newPoint.Y, ballRadius * 2, ballRadius * 2, ballColor);
     Canvas.AddText(num.ToString(), 14, newPoint.X - ballRadius, newPoint.Y - ballRadius, ballRadius * 2, ballRadius * 2, Color.FromArgb(ballColor.ToArgb() ^ 0x00FFFFFF));
     Canvas.Render();
 }
Пример #4
0
        //***************************************************************************************************
        //Method: static public void drawMoney(CDrawer window, decimal cashVal, decimal[,] currVals)
        //Purpose: Displays visually the amounts of denominations to the user in GDI Drawer.
        //Parameters: CDrawer window - the GDI Drawer window to be drawn to.
        //            decimal cashVal - the total amount of cash being divided.
        //            decimal[,] currVals - the array of denominations being divided into.
        //Returns: void
        //****************************************************************************************************

        static public void drawMoney(CDrawer window, decimal cashVal, decimal[,] currVals)
        {
            //declare vars
            Color[] colours = { Color.Firebrick, Color.LightGreen, Color.Magenta, Color.LightSkyBlue,
                Color.Silver, Color.Gold, Color.Silver,
                Color.Silver, Color.Silver, Color.Brown }; // array of colours to draw the appropriate denomination.

            //draws total amount at the top.
            window.AddText(cashVal.ToString("C"), 24, 400, 50, 0, 0, Color.Yellow);
            
            //loops to draw each denomination.
            for (int i = 0, x = 100, y = 100; i < currVals.GetLength(1); ++i)
            {
                //checks to make sure drawing won't go off screen. If it might, resets it to the top and
                //offsets to the right.
                if (y > 500 && x != 500)
                {
                    y = 100;
                    x = 500;
                }

                //checks to make sure current denomination type is being used.
                if (currVals[1, i] > 0)
                {
                    //draws large bills.
                    if (i <= 3)
                    {
                        window.AddRectangle(x, y, 180, 80, colours[i], 1, Color.Beige);
                        window.AddText((currVals[0,i].ToString("C")) + " x " + currVals[1, i].ToString(), 14, x + 90, y + 40, 0, 0, Color.Black);
                        y += 90;
                    }
                    //draws coins.
                    else
                    {
                        window.AddEllipse(x + 45, y, 85, 85, colours[i], 1, Color.Beige);
                        if (currVals[0, i] == 2) window.AddEllipse(x + 63, y + 20, 47, 47, Color.Gold);
                        window.AddText((currVals[0, i].ToString("C")) + " x " + currVals[1, i].ToString(), 14, x + 85, y + 42, 0, 0, Color.Black);
                        y += 90;
                    }

                }
            }
        }
Пример #5
0
        static void SBlocks()
        {
            CDrawer can = new CDrawer(800, 600, false);

            for (int i = 0; i < 500; ++i)
            {
                can.AddCenteredEllipse(s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 800), RandColor.GetColor(), 1, RandColor.GetColor());
                can.AddCenteredEllipse(s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 800), RandColor.GetColor(), 1);
                can.AddCenteredEllipse(s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 800), RandColor.GetColor());
                can.AddCenteredEllipse(s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 800));

                can.AddEllipse(s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 800), RandColor.GetColor(), 1, RandColor.GetColor());
                can.AddEllipse(s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 800), RandColor.GetColor(), 1);
                can.AddEllipse(s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 800), RandColor.GetColor());
                can.AddEllipse(s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 800));

                try
                {
                    can.AddPolygon(s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 300), s_rnd.Next(0, 64), s_rnd.NextDouble() * Math.PI * 2, RandColor.GetColor(), 1, RandColor.GetColor());
                    can.AddPolygon(s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 300), s_rnd.Next(0, 64), s_rnd.NextDouble() * Math.PI * 2, RandColor.GetColor(), 1);
                    can.AddPolygon(s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 300), s_rnd.Next(0, 64), s_rnd.NextDouble() * Math.PI * 2, RandColor.GetColor());
                    can.AddPolygon(s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 300), s_rnd.Next(0, 64), s_rnd.NextDouble() * Math.PI * 2);
                    can.AddPolygon(s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 300), s_rnd.Next(0, 64));
                }
                catch (Exception err)
                {
                    Console.WriteLine(err.Message);
                }

                try
                {
                    can.AddRectangle(s_rnd.Next(-10, 810), s_rnd.Next(-10, 610), s_rnd.Next(-10, 810), s_rnd.Next(-10, 610), RandColor.GetColor(), 1, RandColor.GetColor());
                    can.AddRectangle(s_rnd.Next(-10, 810), s_rnd.Next(-10, 610), s_rnd.Next(-10, 810), s_rnd.Next(-10, 610), RandColor.GetColor(), 1);
                    can.AddRectangle(s_rnd.Next(-10, 810), s_rnd.Next(-10, 610), s_rnd.Next(-10, 810), s_rnd.Next(-10, 610), RandColor.GetColor());
                    can.AddRectangle(s_rnd.Next(-10, 810), s_rnd.Next(-10, 610), s_rnd.Next(-10, 810), s_rnd.Next(-10, 610));
                }
                catch (Exception err)
                {
                    Console.WriteLine(err.Message);
                }

                try
                {
                    can.AddText("Rats", s_rnd.Next(0, 100), s_rnd.Next (0, 800), s_rnd.Next (0, 600), s_rnd.Next(0, 200), s_rnd.Next (0, 200), RandColor.GetColor());
                    can.AddText("Rats", s_rnd.Next(0, 100), s_rnd.Next(0, 800), s_rnd.Next(0, 600), s_rnd.Next(0, 200), s_rnd.Next(0, 200));
                    can.AddText("Rats", s_rnd.Next(0, 100), RandColor.GetColor());
                }
                catch (Exception err)
                {
                    Console.WriteLine(err.Message);
                }
            }

            can.Render();
            Console.ReadKey();
        }
Пример #6
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();
        }
Пример #7
0
 static void Lines()
 {
     CDrawer can = new CDrawer(800, 600, false);
     can.Scale = 10;
     for (int i = -10; i < can.ScaledWidth + 1; i += 5)
     {
         for (int j = -10; j < can.ScaledHeight + 1; j += 5)
         {
             can.AddLine(i, j, can.ScaledWidth + 1 - i, can.ScaledHeight + 1 - j, RandColor.GetKnownColor(), 1);
         }
     }
     can.AddText("check...check.. ", 48);
     can.AddText("one two three", 12, -10, -10, 100, 50, Color.White);
     can.Render();
     Console.ReadKey();
 }