Page 1 of 1

¿How to correctly work with dp's?

Posted: Mon May 18, 2020 11:00 pm
by cristoferfb
Hi ! I currently doing some tests with UI in LOVE2D, actually I am trying to implement a floating action button (1) acordly to the documentation the "mini" version of this component have 20 dp of radius so I do this in my LOVE2D code:

Code: Select all

love.graphics.circle("fill", self:getX(), self:getY(), love.window.toPixels(20)) -- convert 20 dp to pixels 
but the result in my screen is bigger than expected:
Screenshot_LÖVE_for_Android_20200518-185029.png
Screenshot_LÖVE_for_Android_20200518-185029.png (24.35 KiB) Viewed 2634 times
What I am doing wrong?

[1] https://material.io/components/buttons- ... ion-button

Re: ¿How to correctly work with dp's?

Posted: Mon May 18, 2020 11:03 pm
by slime
love already uses DP units by default, so you should just be able to remove the toPixels call.

Re: ¿How to correctly work with dp's?

Posted: Mon May 18, 2020 11:18 pm
by cristoferfb
slime wrote: Mon May 18, 2020 11:03 pm love already uses DP units by default, so you should just be able to remove the toPixels call.
DAMN thanks