DrawPoly

Monkey Forums/Monkey Programming/DrawPoly

degac(Posted 2011) [#1]
Hi
there are plans to add DrawPoly (filled) command to Monkey?
I think it will be handy.


invaderJim(Posted 2011) [#2]
This is the best I could do porting over some old code from the blitzmax forums.

You can either draw a poly by passing a list of vertices, or by specifying a number of sides and a radius. If you try the latter method, you will see that I'm having issues with spacing between the triangles. Fun fun...

example.monkey:



drawpoly.monkey:




degac(Posted 2011) [#3]
Hi

Thanks for your contribution, but I think a 'native' solution should be better: I've already changed mojo-html5 to handle DrawPoly, and I'm sure it could be done in all the other platforms.


invaderJim(Posted 2011) [#4]
Yeah, I noticed you had done that shortly after posting :P

I wasn't aware that it was so easy to 'hack' mojo like that. Following your example, I've fixed my triangle drawing problem by natively drawing them in each platform.

I went with just triangles to reduce the amount of code required to triangulate the polygons properly in each platform, plus I really like warpy's triangulation method ;)

If you or anyone else is interested, I can post all of my DrawTriangle() functions here, but, for the most part, all I did was copy and modify the DrawRect() functions to draw one tri instead of two.


degac(Posted 2011) [#5]
Well, the 'Monkey Code Section' is here to be filled!
Each new hack/function is welcomed!
(and maybe Mark could be impressed/interested/stimulated enough to port the changes as 'official' in mojo...


hardcoal(Posted 2011) [#6]
Can you draw poly as lines only without fill?


Jesse(Posted 2011) [#7]
No. It shouldn't be too hard for you too implement.


hardcoal(Posted 2011) [#8]
ok good to know.
tnx