About Monkey 2 › Forums › Monkey 2 Development › DrawLine+Scale: thickness bug..
This topic contains 2 replies, has 2 voices, and was last updated by 
 abakobo
 2 years, 4 months ago.
- 
		AuthorPosts
 - 
		
			
				
November 22, 2016 at 6:22 pm #5346
Issued on github too
[/crayon]Monkey123456789101112131415161718192021222324252627282930313233343536373839[crayon-5cba8d889e04a117553990 inline="true" ]#Import "<std>"#Import "<mojo>"Using std..Using mojo..Class MyWindow Extends WindowField zoom:=25.0Field radius:=0.3Field x:=9.3Field y:=9.2Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=Null )Super.New( title,width,height,flags )EndMethod OnRender( canvas:Canvas ) Overridecanvas.BlendMode=BlendMode.Opaquecanvas.Scale(zoom,zoom)canvas.DrawCircle( x,y,radius )canvas.Color=Color.Blackcanvas.LineWidth=radius*2.0 'this line is supposed to be as thick as the circle...canvas.DrawLine(x,y,x+2.0,y)canvas.Color=Color.Whitecanvas.DrawCircle( x,y+2.0,radius*4.0 )canvas.Color=Color.Blackcanvas.LineWidth=radius*2.0*4.0 'this line is supposed to be as thick as the circle...canvas.DrawLine(x,y+2.0,x+2.0,y+2.0)EndEndFunction Main()New AppInstanceNew MyWindowApp.Run()EndNovember 23, 2016 at 8:06 pm #5391Ok, a fix for this is now up at github in develop branch – you just need to grab latest canvas.monkey2.
The problem was due to DrawLine using ‘normal’ DrawLine if LineWidth<1. But with scaling, this isn’t always correct.
So I’ve changed the check to LineWidth<=0 (LineWidth now defaults to 0 too) so any >0 linewidth will make mojo use it’s ‘fancy’ DrawLine, ie: draw rects instead of lines.
I’ve also added a LineSmoothing property to Canvas (defaults to false) to control the fake antialiasing of lines. If LineSmoothing is true, lines drawn with LineWidth>0 will be antialiased-ish.
This actually produces pretty convincing antialiased lines with LineWidth>=2 and less than about 5. Less than 2 and the line starts to ‘break up’ noticably, greater than 5 and the anitaliasing ‘fudge’ starts showing! I’ve added a little linetest banana showing this.
I’ve also tweaked draw circle/oval/ellipse so primtives are better ‘centered’ and hopefully more symmetrical.
There are still issues with line end points, but I think this is getting there!
November 23, 2016 at 8:30 pm #5393Great! Thanks.
I use them for 2d physics debug draw so perfection is not mandatory! A bit of consistency when scaling is a good point, I hope it’s not slowing down the process.. - 
		AuthorPosts
 
You must be logged in to reply to this topic.