memononen/nanovg

There's no method to draw triangles

Closed this issue · 3 comments

btmxh commented
There's no method to draw triangles

Yes there is.

I will try to give a more helpful answer. This will draw a filled or outlined triangle with vertices at (aX,aY), (bX,bY), (xY,cY):

void nvgDrawTriangle ( NVGcontext context, float ax, float aY, float bX, float bY, float cX, float cY, bool fill )
{
nvgBeginPath ( context );
nvgMoveTo ( context, aX, aY );
nvgLineTo ( context, bX, bY );
nvgLineTo ( context, cX, cY );
if ( filled )
{
nvgFill ( context );
}
else
{
nvgLineTo ( context, aX, aY );
nvgStroke ( context );
}
}

btmxh commented

I already found the way to draw triangles a while ago, but I forgot to close the issue. Thanks for replying btw.