Пример #1
0
        public void RunOriginal()
        {
            try
            {
                //copy opend image information onto image variable
                _image = new Bitmap(openFileDialog1.FileName);

                for (int x = 0; x < _image.Width; x++)
                {
                    //while x value goes up make progress bar follows
                    Invoke(new delVoidInt(cbUpdateProgress), x);
                    for (int y = 0; y < _image.Height; y++)
                    {
                        //draw image point by point
                        _canvas.SetBBPixel(x, y, _image.GetPixel(x, y));
                    }
                }
                //finish prograss bar
                Invoke(new delVoidVoid(cbUpdateComplete));
            }
            catch (Exception ex)
            {
                //if cath an exception goes here
                MessageBox.Show(ex.Message, ("GDIImage Example"));
            }
        }
Пример #2
0
        private void GrowFungus(object canvasObj)
        {
            while (true)
            {
                Dictionary <Point, int> SortDictionary;
                CDrawer      canvas        = (CDrawer)canvasObj;
                List <Point> freePositions = GeneratePos(pos, canvas);

                if (freePositions.TrueForAll(pos => pos.X > 995 && pos.Y > 995))
                {
                    Console.WriteLine("Glitched!");
                }

                ShufflePositions(freePositions);

                SortDictionary = freePositions.ToDictionary(pos => pos, pos => (visitedPoints.Keys.Contains(pos) ? visitedPoints[pos] : 0));

                SortDictionary = SortDictionary.OrderBy(kvp => kvp.Value).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
                pos            = SortDictionary.First().Key;


                if (visitedPoints.Keys.Contains(pos))
                {
                    if (visitedPoints[pos] + 16 >= 255)
                    {
                        visitedPoints[pos] = 255;
                    }
                    else
                    {
                        visitedPoints[pos] += 16;
                    }
                }
                else
                {
                    visitedPoints.Add(pos, 32);
                }


                switch (growColor)
                {
                case FungusColor.Blue:
                    canvas.SetBBPixel(pos.X, pos.Y, Color.FromArgb(0, 0, visitedPoints[pos]));
                    break;

                case FungusColor.Green:
                    canvas.SetBBPixel(pos.X, pos.Y, Color.FromArgb(0, visitedPoints[pos], 0));
                    break;

                default:
                    canvas.SetBBPixel(pos.X, pos.Y, Color.FromArgb(visitedPoints[pos], 0, 0));
                    break;
                }


                Thread.Sleep(0);
            }
        }
Пример #3
0
        private void FungusThread()
        {
            Dictionary <Point, int> tempD = new Dictionary <Point, int>();

            int c = 0;

            while (true)
            {
                AdjP = NeighbourPoint(point);

                AdjP.RemoveAll(o => o.X <0 || o.X> canvas.m_ciWidth - 1 || o.Y <0 || o.Y> canvas.m_ciHeight - 1);

                AdjP = Shuffle(AdjP);

                tempD = AdjP.ToDictionary(o => o, o => dict.ContainsKey(o) ? dict[o] : 0);

                List <KeyValuePair <Point, int> > temp = tempD.OrderBy(o => o.Value).ToList();


                point = temp.First().Key;

                if (dict.ContainsKey(point))
                {
                    if (dict[point] + 16 < 255)
                    {
                        dict[point] += 16;
                    }
                    else
                    {
                        dict[point] = 255;
                    }
                }
                else
                {
                    dict.Add(point, 32);
                }

                if (test == Colors.Red)
                {
                    canvas.SetBBPixel(point.X, point.Y, Color.FromArgb(dict[point], 0, 0));
                }
                else if (test == Colors.Blue)
                {
                    canvas.SetBBPixel(point.X, point.Y, Color.FromArgb(0, 0, dict[point]));
                }
                else if (test == Colors.Green)
                {
                    canvas.SetBBPixel(point.X, point.Y, Color.FromArgb(0, dict[point], 0));
                }

                //canvas.Render();
                Thread.Sleep(0);
            }
        }
Пример #4
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();
        }
Пример #5
0
 private void SetGuard(CDrawer dr, int ix, int iy, Color col)
 {
     if (ix >= 0 && ix < dr.m_ciWidth && iy >= 0 && iy < dr.m_ciHeight)
     {
         dr.SetBBPixel(ix, iy, col);
     }
 }
Пример #6
0
        static void Background()
        {
            Console.WriteLine("Resource Picture");
            Bitmap  bm = new Bitmap(Properties.Resources.jupiter);
            CDrawer dr = new CDrawer(bm.Width, bm.Height);

            dr.ContinuousUpdate = false;
            dr.SetBBPixel(bm.Width / 2, bm.Height / 2, Color.Wheat);

            for (int y = 0; y < bm.Height; ++y)
            {
                for (int x = 0; x < bm.Width; ++x)
                {
                    dr.SetBBPixel(x, y, bm.GetPixel(x, y));
                }
            }
            dr.Render();
            System.Threading.Thread.Sleep(1000);
            dr.Close();
        }
Пример #7
0
        static public void DrawSky(CDrawer gdi, bool[,] stars)
        {
            int row    = 0;
            int column = 0;

            for (row = 0; row < stars.GetLength(0); row++)
            {
                for (column = 0; column < stars.GetLength(1); column++)
                {
                    if (stars[row, column])
                    {
                        gdi.SetBBPixel(column, row, RandColor.GetColor());
                    }
                    else
                    {
                        gdi.SetBBPixel(column, row, Color.Black);
                    }
                }
            }
            gdi.Render();
            Console.Clear();
            Console.WriteLine("\t\t\tSky updated\n");
        }
Пример #8
0
        static void Grid(CDrawer canvas)
        {
            for (int x = 0; x < 800; x++)
            {
                canvas.SetBBPixel(x, 300, Color.Red);

                //drawing the x ticks
                if ((x % unitValue) == 0)
                {
                    for (int y = 294; y < 306; ++y)
                    {
                        canvas.SetBBPixel(x, y, Color.Red);
                    }
                }



                if ((x % unitValue2) == 0)
                {
                    for (int y = 297; y < 304; ++y)
                    {
                        canvas.SetBBPixel(x, y, Color.Red);
                    }
                }

                if ((x % unitValue4) == 0)
                {
                    for (int y = 299; y < 302; ++y)
                    {
                        canvas.SetBBPixel(x, y, Color.Red);
                    }
                }
            }

            for (int y = 0; y < 600; y++)
            {
                canvas.SetBBPixel(400, y, Color.Red);

                //drawing y ticks
                if ((y % unitValue3) == 0)
                {
                    for (int x = 395; x < 405; ++x)
                    {
                        canvas.SetBBPixel(x, y, Color.Red);
                    }
                }
            }
        }
Пример #9
0
        //         END OF MAIN                 END OF MAIN               END OF MAIN

        static int[] Draw(int xCoordinate, int yCoordinate, CDrawer s_Draw)
        {
            int[] arrayOfXValues = new int[500000];
            int[] arrayOfYValues = new int[500000];
            int   v = 0;

            int[]          colorAtMove_PlaceDesignator = new int[500000];
            int            xPoint  = xCoordinate;
            int            ypoint  = yCoordinate;
            Color          color   = Color.Green;
            Color          r       = Color.Red;
            Color          g       = Color.Green;
            Color          b       = Color.Blue;
            bool           success = false;
            ConsoleKeyInfo lineDirection;



            do
            {
                if (color == Color.Red)
                {
                    lineDirection = Console.ReadKey();
                    if (lineDirection.Key == ConsoleKey.UpArrow)
                    {
                        yCoordinate += 1;
                        s_Draw.SetBBPixel(xPoint, ypoint, r);
                        colorAtMove_PlaceDesignator[v] = 1;
                        v += 1;
                    }

                    if (lineDirection.Key == ConsoleKey.DownArrow)
                    {
                        yCoordinate -= 1;
                        s_Draw.SetBBPixel(xPoint, ypoint, r);
                        colorAtMove_PlaceDesignator[v] = 2;
                        v += 1;
                    }

                    if (lineDirection.Key == ConsoleKey.LeftArrow)
                    {
                        xCoordinate -= 1;
                        s_Draw.SetBBPixel(xPoint, ypoint, r);
                        colorAtMove_PlaceDesignator[v] = 3;
                        v += 1;
                    }

                    if (lineDirection.Key == ConsoleKey.RightArrow)
                    {
                        xCoordinate += 1;
                        s_Draw.SetBBPixel(xPoint, ypoint, r);
                        colorAtMove_PlaceDesignator[v] = 4;
                        v += 1;
                    }
                }


                if (color == Color.Green)
                {
                    lineDirection = Console.ReadKey();
                    if (lineDirection.Key == ConsoleKey.UpArrow)
                    {
                        yCoordinate += 1;
                        s_Draw.SetBBPixel(xPoint, ypoint, g);
                        colorAtMove_PlaceDesignator[v] = 5;
                        v += 1;
                    }
                    if (lineDirection.Key == ConsoleKey.DownArrow)
                    {
                        yCoordinate -= 1;
                        s_Draw.SetBBPixel(xPoint, ypoint, g);
                        colorAtMove_PlaceDesignator[v] = 6;
                        v += 1;
                    }
                    if (lineDirection.Key == ConsoleKey.LeftArrow)
                    {
                        xCoordinate -= 1;
                        s_Draw.SetBBPixel(xPoint, ypoint, g);
                        colorAtMove_PlaceDesignator[v] = 7;
                        v += 1;
                    }
                    if (lineDirection.Key == ConsoleKey.RightArrow)
                    {
                        xCoordinate += 1;
                        s_Draw.SetBBPixel(xPoint, ypoint, g);
                        colorAtMove_PlaceDesignator[v] = 8;
                        v += 1;
                    }
                }


                if (color == Color.Blue)
                {
                    lineDirection = Console.ReadKey();
                    if (lineDirection.Key == ConsoleKey.UpArrow)
                    {
                        yCoordinate += 1;
                        s_Draw.SetBBPixel(xPoint, ypoint, b);
                        colorAtMove_PlaceDesignator[v] = 9;
                        v += 1;
                    }
                    if (lineDirection.Key == ConsoleKey.DownArrow)
                    {
                        yCoordinate -= 1;
                        s_Draw.SetBBPixel(xPoint, ypoint, b);
                        colorAtMove_PlaceDesignator[v] = 10;
                        v += 1;
                    }
                    if (lineDirection.Key == ConsoleKey.LeftArrow)
                    {
                        xCoordinate -= 1;
                        s_Draw.SetBBPixel(xPoint, ypoint, b);
                        colorAtMove_PlaceDesignator[v] = 11;
                        v += 1;
                    }
                    if (lineDirection.Key == ConsoleKey.RightArrow)
                    {
                        xCoordinate += 1;
                        s_Draw.SetBBPixel(xPoint, ypoint, b);
                        colorAtMove_PlaceDesignator[v] = 12;
                        v += 1;
                    }
                }
            } while (!success);
            return(arrayOfXValues);
        }// draws the lines and returns array of x values
Пример #10
0
        }// draws the lines and returns array of x values

        //         END OF DRAW                 END OF DRAW               END OF DRAW



        static void PlayBack(int[] arrayOfMoves, int xCoordinate, int yCoordinate, CDrawer s_Draw)
        {
            Color r = Color.Red;
            Color g = Color.Green;
            Color b = Color.Blue;

            s_Draw.SetBBPixel(xCoordinate, yCoordinate, b);
            foreach (int i in arrayOfMoves)
            {
                if (arrayOfMoves[i] == 1)
                {
                    yCoordinate += 1;
                    s_Draw.SetBBPixel(xCoordinate, yCoordinate, r);
                }

                if (arrayOfMoves[i] == 2)
                {
                    yCoordinate -= 1;
                    s_Draw.SetBBPixel(xCoordinate, yCoordinate, r);
                }

                if (arrayOfMoves[i] == 3)
                {
                    xCoordinate -= 1;
                    s_Draw.SetBBPixel(xCoordinate, yCoordinate, r);
                }

                if (arrayOfMoves[i] == 4)
                {
                    xCoordinate += 1;
                    s_Draw.SetBBPixel(xCoordinate, yCoordinate, r);
                }

                if (arrayOfMoves[i] == 5)
                {
                    yCoordinate += 1;
                    s_Draw.SetBBPixel(xCoordinate, yCoordinate, g);
                }

                if (arrayOfMoves[i] == 6)
                {
                    yCoordinate -= 1;
                    s_Draw.SetBBPixel(xCoordinate, yCoordinate, g);
                }

                if (arrayOfMoves[i] == 7)
                {
                    xCoordinate -= 1;
                    s_Draw.SetBBPixel(xCoordinate, yCoordinate, g);
                }

                if (arrayOfMoves[i] == 8)
                {
                    xCoordinate += 1;
                    s_Draw.SetBBPixel(xCoordinate, yCoordinate, g);
                }

                if (arrayOfMoves[i] == 9)
                {
                    yCoordinate += 1;
                    s_Draw.SetBBPixel(xCoordinate, yCoordinate, b);
                }

                if (arrayOfMoves[i] == 10)
                {
                    yCoordinate -= 1;
                    s_Draw.SetBBPixel(xCoordinate, yCoordinate, b);
                }

                if (arrayOfMoves[i] == 11)
                {
                    xCoordinate -= 1;
                    s_Draw.SetBBPixel(xCoordinate, yCoordinate, b);
                }

                if (arrayOfMoves[i] == 12)
                {
                    xCoordinate += 1;
                    s_Draw.SetBBPixel(xCoordinate, yCoordinate, b);
                }



                //end of array draw foreach____
            }
        }
Пример #11
0
        // Set up drawing canvas
        public static CDrawer CreateDrawingWindow()
        {
            CDrawer Canvas = new CDrawer();

            Canvas.ContinuousUpdate = false;
            Canvas.RedundaMouse     = true;
            Canvas.Scale            = 1;
            for (int row = 0; row < 800; row++)
            {
                for (int col = 0; col < 600; col++)
                {
                    Canvas.SetBBPixel(row, col, Color.SkyBlue);
                }
            }
            //Some sandy ground color
            for (int row = 0; row < 800; row++)
            {
                for (int col = 400; col < 600; col++)
                {
                    Canvas.SetBBPixel(row, col, Color.SandyBrown);
                }
            }
            //A sun, perhaps?
            int a = 85, b = 85;

            for (int r = 1; r <= 40; r++)
            {
                for (double theta = 0.0; theta < 2 * Math.PI; theta += 0.0174533 / 2)
                {
                    Canvas.SetBBPixel((int)(r * Math.Cos(theta) + a), (int)(r * Math.Sin(theta) + b), Color.Yellow);
                }
            }
            //rays... y= m(x-a) + b
            for (double theta = 0; theta < 2 * Math.PI; theta += Math.PI / 6)
            {
                for (int r = 50; r <= 70; r++)
                {
                    Canvas.SetBBPixel((int)(r * Math.Cos(theta) + a), (int)(r * Math.Sin(theta) + b), Color.Yellow);
                }
            }
            //Draw hanging post, SetBBPixel?
            for (int x = 245; x <= 255; x++)
            {
                for (int y = 125; y <= 215; y++)
                {
                    Canvas.SetBBPixel(x, y, Color.Brown);
                }
            }
            for (int x = 150; x <= 250; x++)
            {
                for (int y = 125; y <= 135; y++)
                {
                    Canvas.SetBBPixel(x, y, Color.Brown);
                }
            }
            for (int x = 145; x <= 155; x++)
            {
                for (int y = 125; y <= 525; y++)
                {
                    Canvas.SetBBPixel(x, y, Color.Brown);
                }
            }
            for (int x = 100; x <= 200; x++)
            {
                for (int y = 520; y <= 530; y++)
                {
                    Canvas.SetBBPixel(x, y, Color.Brown);
                }
            }
            return(Canvas);
        }
Пример #12
0
 //********************************************************************************************
 //Method:     private void changePixel(int x,int y,Color Here)
 //Purpose:    changes amount of pixels and what color they are
 //            based on a trackbar value and where user clicked
 //Parameters: int xPos- amount of pixels to be drawn
 //            int yPos- amount of pixels to be drawn
 //            Color here- color of the pixels
 //*********************************************************************************************
 private void changePixel(int xPos, int yPos, Color Here)
 {
     // change pixels from what is set in wanderer
     _draw.SetBBPixel(xPos, yPos, Here);
 }