Page 1 of 1

Rounded corner polygon fast draw

PostPosted: Tue Nov 29, 2016 6:22 am
by abakobo
Hi it's my first post here..

The new monkey2 language ( has a chipmunk port and I'm working on a debugdraw based on monkey2's 2d graphics module(mojo).
I've seen the chipmunk debugdraw implementation with the C demo but I can't really understand all the GL triangles code and it's 60 lines long so kind of low level for a monkey2 user.

In my implementation I have to draw n circle, n fat lines and one n sided poly. This is taking a lot of resources..

here's the code in monkey2 (should be self explanatory)
Code: Select all
_canvas.Color=New Color( fillColor.r,fillColor.g,fillColor.b,fillColor.a )

_canvas.DrawPoly( count,vertices )
_canvas.Color=New Color( outlineColor.r,outlineColor.g,outlineColor.b,outlineColor.a )   
For Local i:=1 Until count      
   _canvas.DrawLine( verts[i-1].x,verts[i-1].y,verts[i].x,verts[i].y )
   _canvas.DrawCircle( verts[i-1].x,verts[i-1].y,radius )         
_canvas.DrawLine( verts[count-1].x,verts[count-1].y,verts[0].x,verts[0].y )
_canvas.DrawCircle( verts[count-1].x,verts[count-1].y,radius )

-Is the attached png (and above algorithm) a correct way to draw these rounded corner polys?
-Is there a "trick" to draw these rounded polys faster?

thx and congrats for the great lib chipmunk is

Re: Rounded corner polygon fast draw

PostPosted: Tue Nov 29, 2016 12:10 pm
by slembcke
Not really unfortunately. If there is an API to draw bezier curves, you could use that. Otherwise you have to draw them out of other pieces.