community
directory
books
authors
images
encyclopedia

Email:
Password:
Register

Knowledgerush Search

 

Google
  Web knowledgerush


Search for images of Bresenham's line algorithm Visual basic code


Message boards   Post comment

Bresenham's line algorithm Visual basic code

An example of Bresenham's line algorithm in Visual Basic follows. The "Swap" procedure is not shown.

Private Sub BresLine(InitialX As Long, InitialY As Long, FinalX As Long, FinalY As Long) ' Bresenham's line algorithm for Microsoft Visual Basic 6.0 ' Implementation by Robert Lee July, 2002 Public Domain

Dim Steep As Boolean Dim DeltaX As Long, DeltaY As Long, Delta As Long Dim StepX As Long, StepY As Long Dim Coord As Long

Steep = False DeltaX = Abs(FinalX - InitialX) If (FinalX - InitialX) > 0 Then StepX = 1 Else StepX = -1 End If DeltaY = Abs(FinalY - InitialY) If (FinalY - InitialY) > 0 Then StepY = 1 Else StepY = -1 End If If DeltaY > DeltaX Then Steep = True Swap InitialX, InitialY Swap DeltaX, DeltaY Swap StepX, StepY End If Delta = (DeltaY * 2) - DeltaX For Coord = 0 To DeltaX - 1 If Steep Then Me.PSet (InitialY, InitialX) Else Me.PSet (InitialX, InitialY) End If While Delta >= 0 InitialY = InitialY + StepY Delta = Delta - (DeltaX * 2) Wend InitialX = InitialX + StepX Delta = Delta + (DeltaY * 2) Next Coord Me.PSet (FinalX, FinalY) End Sub

Referenced By

Bresenham's line algorithm

 

Compose Your Message

Your Email Address or Pen Name (optional):
Subject:
Your Message:
 

 

 

 

 

 

This article is licensed under the GNU Free Documentation License. It uses material from the Wikipedia article "Bresenham's line algorithm Visual basic code".

 

Contact UsPrivacy Statement & Terms of Use

 
Copyright © 1999-2003 Knowledgerush.com. All rights reserved.