Private Sub CheckerBoard() Dim rect As New Rectangle ' create a Graphics object to draw into it Dim pbox As Graphics = PictureBox1.CreateGraphics mSquWidth = PictureBox1.Width / CDbl(mCols) mSquHeight = PictureBox1.Height / CDbl(mRows) rect.Width = mSquWidth rect.Height = mSquHeight Dim r, c For r = 0 To mRows - 1 For c = 0 To mCols - 1 If ((r + c) Mod 2) = 0 Then ' create a Graphics object to draw into it pbox.FillRectangle(Brushes.Azure, rect) pbox.DrawRectangle(Pens.Pink, rect) Else pbox.FillRectangle(Brushes.BlueViolet, rect) pbox.DrawRectangle(Pens.Red, rect) End If rect.X = c * mSquWidth rect.Y = r * mSquHeight ' create a Graphics object to draw into it pbox.FillRectangle(Brushes.BlueViolet, rect) pbox.DrawRectangle(Pens.Red, rect) Next Next End Sub
Wednesday, February 23, 2011
VB.NET -- Checkerboard in PictureBox
Labels:
Code
Subscribe to:
Post Comments (Atom)
This routine could use some work...
ReplyDelete