Ejemplo n.º 1
0
		public RandomWalk(int fileSize, bool createBitmap = false, string filePath = null)
        {
			int numberDrawn = 0;

			if (filePath == null)
				_filePath = @"C:\Users\kylan_000\Desktop\Test Projects\Random Bitmaps\RandomArt.2013\WithPointers\";
			else _filePath = filePath;

            Random randomW = new Random();
            //Random randomC = new Random();
            Random rr = new Random();
            Random rg = new Random();
            Random rb = new Random();

            Random random = new Random();

            Random randomR = new Random();

            Random randomG = new Random();

            Random randomB = new Random();

            Random pc = new Random();

            Random myRandom = new Random();

            //int LineLength = 1;

            //int FileSize = 10000000; //in bytes

            int x = (int)Math.Truncate(Math.Sqrt(fileSize / 36)) + 1;

            int Width = 4 * x;    // Screen.GetBounds(new Point(5, 5)).Width;

            int Height = 3 * x;   //Screen.GetBounds( new Point(5,5) ).Height;

            Random pick = new Random();

			TBitmap tBm = new TBitmap(Width, Height);

			//Console.WriteLine("width " + Width);
			//Console.WriteLine("heigth " + Height);

            for (int k = 0; k<tBm.values.GetLength(0); k++)
            {

                tBm.values[k].R = (byte)0;
                tBm.values[k].G = (byte)0;
                tBm.values[k].B = (byte)0;
				tBm.values[k].A = (byte)0;
            }

            int i;

            int randomNumber; randomNumber = random.Next(0, 255);

            //for (int g = 1; g < 10; g++)
            //{
                IntPoint ptStart = new IntPoint(random.Next(Width), random.Next(Height));

                double rnd;

                rnd = pc.Next(0, 8);

                int PenCase = 4;

                Color startColor = Color.FromArgb(random.Next(0,255),random.Next(0,255),random.Next(0,255));

                IntPoint ptEnd = new IntPoint(0, 0);

				Random randomC = new Random();

                for (i = 1; i < 1000000; i++)
                //do
                {

                    //IntPoint[] pts = new IntPoint[2];

                    int c;

                    Color endColor = new Color();

                    switch (PenCase)
                    {
                        case 1:
                            {

                                //ptEnd = GetNextPoint(ptStart, random, bpData.Stride, bpData.Height);

                                //ptEnd.Offset(random.Next(-(LineLength), LineLength + 1), random.Next(-(LineLength), LineLength + 1));

                                break;
                            }
                        case 2:
                            { //black
                                //pn.Width = randomW.Next(0, 5);

                                //ptEnd = GetNextPoint(ptStart, random, bpData.Stride, bpData.Height);

                                break;
                            }
                        case 3:
                            { //all colors, random line width between 0 and 5 px

                                endColor = Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255));

                                //ptEnd = GetNextPoint(ptStart, random, bpData.Stride, bpData.Height);
                                break;
                            }
                        case 4:
                            { //all colors, thinnest line width

                                ptEnd = GetNextPoint(new Point(ptStart.x, ptStart.y), random, tBm.Width, tBm.Height);

								endColor = Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255));

                                //endColor = Blend(startColor, GetPixelColor(ptEnd, tBm), random);

								numberDrawn += DrawToBitmap(ref tBm, new BitmapPoint(ptEnd.x, ptEnd.y), endColor);

								ptStart.x = ptEnd.x; ptStart.y = ptEnd.y;

                                break;
                            }
                        case 5:
                            { //greyscale
                                c = randomC.Next(0, 255);
                                //pn.Color = System.Drawing.Color.FromArgb(c, c, c);

                                //ptEnd = GetNextPoint(ptStart, random, bpData.Stride, bpData.Height);
                                break;
                            }
                        case 6:
                            { //white
                                //pn.Color = System.Drawing.Color.White;

                                //ptEnd.X = ptStart.X;

                                //ptEnd.Y = ptStart.Y;

                                //ptEnd = GetNextPoint(ptStart, random, bpData.Stride, bpData.Height);
                                break;
                            }
                        case 7:
                            { //black thinnest line width
                                //pn.Width = 1;

                                //ptEnd.X = ptStart.X;

                                //ptEnd.Y = ptStart.Y;

                                //ptEnd = GetNextPoint(ptStart, random, bpData.Stride, bpData.Height);
                                break;
                            }
                        case 8: //all colors, wider line width
                            {
                                //pn.Color = System.Drawing.Color.FromArgb( rr.Next(redBottom, redTop), rr.Next(greenBottom, greenCenter), rr.Next(blueBottom, blueTop) );
                                //pn.Width = randomW.Next(0, 50);

                                //ptEnd.X = ptStart.X;

                                //ptEnd.Y = ptStart.Y;

                                //ptEnd = GetNextPoint(ptStart, random, bpData.Stride, bpData.Height);
                                break;
                            }
                        default:
                            {

                                //ptEnd.X = ptStart.X;

                                //ptEnd.Y = ptStart.Y;

                                //ptEnd = GetNextPoint(ptStart, random, bpData.Stride, bpData.Height);

                                break;
                            }

                    } //end switch



                    //pts = null;

                }
            //}

            if(createBitmap)
				WriteDataToStandardBitmap(ref tBm);

        }
Ejemplo n.º 2
0
        static int DrawToBitmap(ref TBitmap bm, BitmapPoint pt, Color color)
        {

            int x = pt.x;

            int y = pt.y;

			bm.values[x + (y * (bm.Width-1))].R = (byte)color.R;
			bm.values[x + (y * (bm.Width-1))].G = (byte)color.G;
			bm.values[x + (y * (bm.Width-1))].B = (byte)color.B;
			bm.values[x + (y * (bm.Width-1))].A = (byte)color.A;

			bm.values[x + (y * (bm.Width-1))].point = pt;

			return 1;
			
        }
Ejemplo n.º 3
0
        private static void WriteTBitmapToBitmap(ref TBitmap tBm, ref Bitmap bm)
        {
			foreach (PixelValue pv in tBm.values)
			{
				bm.SetPixel(pv.point.x, pv.point.y, Color.FromArgb(pv.A, pv.R, pv.G, pv.B));
			}

        }
Ejemplo n.º 4
0
 private static Color GetPixelColor(IntPoint ptEnd, TBitmap bm)
 {
     return Color.FromArgb(bm.values[ptEnd.x + ptEnd.y * bm.Height].R, bm.values[ptEnd.x + ptEnd.y * bm.Height].G, bm.values[ptEnd.x + ptEnd.y * bm.Height].B);
 }
Ejemplo n.º 5
0
        private void WriteDataToStandardBitmap(ref TBitmap tBm)
        {
            bitmap = new Bitmap(tBm.Width, tBm.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            WriteTBitmapToBitmap(ref tBm, ref bitmap);

            bitmap.Save(_filePath + "Random Walk " + DateTime.Now.Month + "-" + DateTime.Now.Day + "-" + DateTime.Now.Year + " " + DateTime.Now.Hour + "h" + DateTime.Now.Minute + "m" + DateTime.Now.Second + "s" + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
        }