Exemple #1
0
        //render method
        public void Render(CDrawer canvas, int lightNum)
        {
            int x;
            int y;

            x = lightNum % canvas.ScaledWidth;
            y = lightNum / canvas.ScaledWidth;

            if ((_byTick >= _byThreshold)&&(y<canvas.ScaledHeight))
            {
                canvas.AddRectangle(x, y, 1, 1, _LightColor, _Border, Color.Black);
            }
        }
Exemple #2
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;
                    }

                }
            }
        }
 //Implements unique version of vRender, drawing a rectangle. .Render() still calls vRender.
 protected override void vRender(CDrawer canvas)
 {
     canvas.AddRectangle(position.X - 10, position.Y - 10, size, size, color);
 }
Exemple #4
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();
        }
Exemple #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();
        }