Beispiel #1
0
        public myDrawer(int width = 800, int height = 400) : base(width, height)
        {
            //initialize your derived Random class to 1/5 of the current scaled width
            random = new myRandom(ScaledWidth / 5);

            BBColour = Color.White;
            //Utilizing your derived Random class, create 100 Rectangles
            for (int i = 0; i < 100; i++)
            {
                AddRectangle(random.NextDrawerRect(this), RandColor.GetKnownColor());
            }
        }
Beispiel #2
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();
        }
Beispiel #3
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();
        }
Beispiel #4
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();
        }