<pre>void GenerateChalkStripes() { //ADD A REAL RANDOM ALGORITHM LATER GenerateColorScheme(2); /* If i comment this section out like this using (Graphics gfx = Graphics.FromImage(bmp)) using (SolidBrush brush = new SolidBrush(colors[0])) { gfx.FillRectangle(brush, 0, 0, 400, 400); } */ /*It works. It generates the stripes as I want it to, but with a background in the color "Control" (the default for WinForms). I want it to draw this background, and then add the stripes over the background... BUT when I try this by removing this comment, it simply does the background and ignores the stripes. Why? How is it not possible to layer pixels? Do I to like print it out to the pictureBox1, then create a new bitmap variable from the pictureBox1 or something? Or have I simply forgotten to like close the brush tool or something stupid?*/ Bitmap bmp = new Bitmap(400, 400); Random r = new Random(); int numOfStripes = r.Next(4, 16); MessageBox.Show(numOfStripes.ToString()); int stripeThickness = r.Next(1, 16); int cutoutThickness = r.Next(1, 8); int numOfCutouts = r.Next(20, 80); int thicknessPerThickBar = (400 /*- (numOfStripes * stripeThickness)*/) / numOfStripes; using (Graphics gfx = Graphics.FromImage(bmp)) using (SolidBrush brush = new SolidBrush(colors[1])) { for (int i = 0; i < numOfStripes; i++) { int startX = thicknessPerThickBar * i; gfx.FillRectangle(brush, startX, 0, stripeThickness, 400); } } pictureBox1.Image = bmp; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)