drawing lines on a grid with skips after every 2 and 3 lines
Posted on 2011-03-12
I'm writing a quick program to print out a grid. I have the code to draw the horiz lines:
float horizline = 0;
float vertline = 0;
RectangleF rect = g.Clip.GetBounds(g);
SizeF size = rect.Size;
float myy = size.Height;
float myx = rect.Right;
for(horizline = 1;horizline < 20;horizline += 0.1F)
g.DrawLine(new Pen(Brushes.Black, 0.01f), 0, horizline, myx, horizline);
Then I want to draw the vert lines with an extra space at every 4th and 7th line then repeat.
Its going to be used as notation for piano so the lines will represent the black keys and the spaces between the lines will represent the white keys. The following will draw a line at every interval:
for (vertline = 1; vertline < 20; vertline += 0.2F)
g.DrawLine(new Pen(Brushes.Blue, 0.01f), vertline, 0, vertline, myy);
I'm thinking an enum of 7 booleans where the 1st 3 are true, the 4th false, the next 2 are true and the last false. Then have a loop inside the above for loop which checks the enum. Any ideas?
And no, this isn't homework.