Results 1 to 2 of 2

Thread: Newbie Question: Funkey Pattern

  1. #1

    Thread Starter
    Hyperactive Member Comreak's Avatar
    Join Date
    Feb 2001
    Location
    Dis
    Posts
    319

    Newbie Question: Funkey Pattern

    I have a question about some program I made while playing with vb.net's drawing functions. Here's the code:

    Code:
    Public Class Form1
        Inherits System.Windows.Forms.Form
        Dim x As Long, y As Long, z As Long
        Dim black As Boolean, red As Boolean
    #Region " Windows Form Designer generated code "
    
        Public Sub New()
            MyBase.New()
    
            'This call is required by the Windows Form Designer.
            InitializeComponent()
    
            'Add any initialization after the InitializeComponent() call
    
        End Sub
    
        'Form overrides dispose to clean up the component list.
        Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
            If disposing Then
                If Not (components Is Nothing) Then
                    components.Dispose()
                End If
            End If
            MyBase.Dispose(disposing)
        End Sub
    
        'Required by the Windows Form Designer
        Private components As System.ComponentModel.IContainer
    
        'NOTE: The following procedure is required by the Windows Form Designer
        'It can be modified using the Windows Form Designer.  
        'Do not modify it using the code editor.
        Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
        Friend WithEvents Button1 As System.Windows.Forms.Button
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
            Me.PictureBox1 = New System.Windows.Forms.PictureBox()
            Me.Button1 = New System.Windows.Forms.Button()
            Me.SuspendLayout()
            '
            'PictureBox1
            '
            Me.PictureBox1.Location = New System.Drawing.Point(16, 8)
            Me.PictureBox1.Name = "PictureBox1"
            Me.PictureBox1.Size = New System.Drawing.Size(280, 280)
            Me.PictureBox1.TabIndex = 0
            Me.PictureBox1.TabStop = False
            '
            'Button1
            '
            Me.Button1.Location = New System.Drawing.Point(112, 296)
            Me.Button1.Name = "Button1"
            Me.Button1.TabIndex = 1
            Me.Button1.Text = "Button1"
            '
            'Form1
            '
            Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
            Me.ClientSize = New System.Drawing.Size(312, 334)
            Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button1, Me.PictureBox1})
            Me.Name = "Form1"
            Me.Text = "Form1"
            Me.ResumeLayout(False)
    
        End Sub
    
    #End Region
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            'cycle 1
            For z = 0 To 280
                x = x + 1
                y = y - 1
                If black = True Then
                    PictureBox1.CreateGraphics.DrawLine(System.Drawing.Pens.Black, x, 0, y, 280)
                    black = False
                Else
                    PictureBox1.CreateGraphics.DrawLine(System.Drawing.Pens.White, x, 0, y, 280)
                    black = True
                End If
            Next
    
            x = 0
            y = 280
            black = True
    
            'cycle 2
            For z = 0 To 280
                x = x + 1
                y = y - 1
                If black = True Then
                    PictureBox1.CreateGraphics.DrawLine(System.Drawing.Pens.Black, 0, x, 280, y)
                    black = False
                Else
                    PictureBox1.CreateGraphics.DrawLine(System.Drawing.Pens.White, 0, x, 280, y)
                    black = True
                End If
            Next
            x = 0
            y = 280
            black = True
    
        End Sub
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            black = True
            x = 0
            y = 280
        End Sub
    End Class
    I understand what I did here but I don't understand where the strange patterns came from. Run it and you'll see what I mean.
    Anyone know why it does this?

    Download the attached file if you don't feel like fooling around with the code.
    Attached Files Attached Files

  2. #2
    Member
    Join Date
    Sep 2002
    Posts
    40
    I don't see what happened, but that pattern kicks ass.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width