Drawing Lines Correctly - with SetLineWidth?

BlitzMax Forums/BlitzMax Beginners Area/Drawing Lines Correctly - with SetLineWidth?

What I draw a thick line in BMAX I get some half-hearted result at the ends of the lines.

This is caused by this code:
Method DrawLine( x0#,y0#,x1#,y1#,tx#,ty# )
		If islost Return
		Local lx0#,ly0#,lx1#,ly1#
		
		lx0=x0*ix+y0*iy+tx
		ly0=x0*jx+y0*jy+ty
		lx1=x1*ix+y1*iy+tx
		ly1=x1*jx+y1*jy+ty
		
		If linewidth=1.0
			cverts[0]=lx0+.5001
			cverts[1]=ly0+.5001
			cverts[4]=lx1+.5001
			cverts[5]=ly1+.5001
			SetActiveFrame Null
			device.DrawPrimitive(D3DPT_LINESTRIP,D3DFVF_XYZ|D3DFVF_DIFFUSE,cverts,2,0)
		Else
			Local lw#=linewidth*0.5
			If Abs(ly1-ly0)>Abs(lx1-lx0)
				cverts[0]=lx0-lw
				cverts[1]=ly0
				cverts[4]=lx0+lw
				cverts[5]=ly0
				cverts[8]=lx1-lw
				cverts[9]=ly1
				cverts[12]=lx1+lw
				cverts[13]=ly1
			Else
				cverts[0]=lx0
				cverts[1]=ly0-lw
				cverts[4]=lx0
				cverts[5]=ly0+lw
				cverts[8]=lx1
				cverts[9]=ly1-lw
				cverts[12]=lx1
				cverts[13]=ly1+lw
			EndIf
			SetActiveFrame Null
			device.DrawPrimitive(D3DPT_TRIANGLESTRIP,D3DFVF_XYZ|D3DFVF_DIFFUSE,cverts,4,0)
		EndIf
	End Method

I change the code and I get semi-decent results, problem is that it don't work all the time.

Here is the new code:
Method DrawLine( x0#,y0#,x1#,y1#,tx#,ty# )
		If islost Return
		Local lx0#,ly0#,lx1#,ly1#
		
		lx0=x0*ix+y0*iy+tx
		ly0=x0*jx+y0*jy+ty
		lx1=x1*ix+y1*iy+tx
		ly1=x1*jx+y1*jy+ty
		
		If linewidth=1.0
			cverts[0]=lx0+.5001
			cverts[1]=ly0+.5001
			cverts[4]=lx1+.5001
			cverts[5]=ly1+.5001
			SetActiveFrame Null
			device.DrawPrimitive(D3DPT_LINESTRIP,D3DFVF_XYZ|D3DFVF_DIFFUSE,cverts,2,0)
		Else
			Local lw#=linewidth*0.5
			
			Local xd# = lx0 - lx1
			Local yd# = ly0 - ly1 
			Local Mag:Double = Sqr(xd*xd + yd*yd) 
			xd = xd / mag * lw
			yd = yd / mag * lw
			
			If Abs(ly1-ly0)>Abs(lx1-lx0)
				cverts[0]=lx0-xd
				cverts[1]=ly0+yd
				cverts[4]=lx0+xd
				cverts[5]=ly0-yd
				cverts[8]=lx1-xd
				cverts[9]=ly1+yd
				cverts[12]=lx1+xd
				cverts[13]=ly1-yd
			Else
				cverts[0]=lx0+xd
				cverts[1]=ly0-yd
				cverts[4]=lx0-xd
				cverts[5]=ly0+yd
				cverts[8]=lx1+xd
				cverts[9]=ly1-yd
				cverts[12]=lx1-xd
				cverts[13]=ly1+yd
			EndIf
			SetActiveFrame Null
			device.DrawPrimitive(D3DPT_TRIANGLESTRIP,D3DFVF_XYZ|D3DFVF_DIFFUSE,cverts,4,0)
		EndIf
	End Method

And now some lines are correct and some are worse!

The two lines (on last pic) were drawn with :
SetLineWidth(24)
DrawLine 400,50,240,200 ' GOOD LINE
DrawLine 10,180,400,050 ' WORSE LINE


Can someone please help, it's been a long day.

No worries, I figured it out.

Well what was the answer? Now I'm curious!

Dang it man! Share with us! The suspense is killing me!!

Something like this :
Method DrawTexturedLine( frame:TDX7ImageFrame,x0#,y0#,x1#,y1#,tx#,ty# )
		If islost Return
		Local lx0#,ly0#,lx1#,ly1#
		
		lx0=x0*ix+y0*iy+tx
		ly0=x0*jx+y0*jy+ty
		lx1=x1*ix+y1*iy+tx
		ly1=x1*jx+y1*jy+ty
		
		Local lw#=linewidth*0.5
		
		Local xd# = lx0 - lx1
		Local yd# = ly0 - ly1 
		Local Mag:Double = Sqr(xd*xd + yd*yd) 
		xd = xd / mag * lw
		yd = yd / mag * lw
		
		Local verts#[]=New Float[20]
		
		
		If Abs(ly1-ly0)>Abs(lx1-lx0)
			verts[0]=lx0-yd
			verts[1]=ly0+xd
			verts[2]=0
			verts[3]=0
			verts[4]=0
		
			verts[5]=lx0+yd
			verts[6]=ly0-xd
			verts[7]=0
			verts[8]=0
			verts[9]=1
		
			verts[10]=lx1-yd
			verts[11]=ly1+xd
			verts[12]=0
			verts[13]=1
			verts[14]=0
		
			verts[15]=lx1+yd
			verts[16]=ly1-xd
			verts[17]=0
			verts[18]=1
			verts[19]=1
	
		Else
			verts[0]=lx0+yd
			verts[1]=ly0-xd
			verts[2]=0
			verts[3]=0
			verts[4]=0
		
			verts[5]=lx0-yd
			verts[6]=ly0+xd
			verts[7]=0
			verts[8]=0
			verts[9]=1
		
			verts[10]=lx1+yd
			verts[11]=ly1-xd
			verts[12]=0
			verts[13]=1
			verts[14]=0
		
			verts[15]=lx1-yd
			verts[16]=ly1+xd
			verts[17]=0
			verts[18]=1
			verts[19]=1
		EndIf
	
		SetActiveFrame frame
		device.DrawPrimitive(D3DPT_TRIANGLESTRIP,D3DFVF_XYZ|D3DFVF_TEX1,verts,4,0)
	End Method