If you reduce your for loop to a single pass ( i < 1 ), you'll see that you're drawing 4 lines each pass when you should be drawing 5. (Kinda obvious without reducing the loops, but it helped me see...