earlygrey / shapedrawer

A library for libGDX that draws simple shapes using a batch.
MIT License
185 stars 32 forks source link

Allow to modify the estimation of number of sides required to draw an ellipse / circle. #18

Closed dcostap closed 4 years ago

dcostap commented 4 years ago

All the ellipses I draw in my projects need more polygon sides to look smooth. This is because I use units, so ShapeDrawer might think a circle has a radius of 4 pixels when it's actually 80 pixels. (PPU (pixels per unit) being 20 in this case)

earlygrey commented 4 years ago

You can set how big a pixel is in world units using setPixelSize(), so it can get a better estimate. So in your case you'd set it to 1/20 (units per pixel).

There's also an updatePixelSize() method, which is supposed to calculate the pixel size for you based on the projection matrix of the batch.

Let me know if they work! I haven't tested it with that large of a difference between world units and pixels yet, so it would be good to know if it works as intended.

Now that you mention it, I probably should have used a setPixelsPerUnit() method instead of its inverse since PPU is the ratio people normally use, maybe I'll add it in an update.

dcostap commented 4 years ago

Thanks! Didn't see the updatePixelSize() methods, dunno how I missed that. They both work perfectly!