¿How to correctly work with dp's?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
cristoferfb
Prole
Posts: 16
Joined: Wed May 15, 2019 12:41 am
Location: Valparaiso, Chile.

¿How to correctly work with dp's?

Post 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 2546 times
What I am doing wrong?

[1] https://material.io/components/buttons- ... ion-button
User avatar
slime
Solid Snayke
Posts: 3132
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

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

Post by slime »

love already uses DP units by default, so you should just be able to remove the toPixels call.
cristoferfb
Prole
Posts: 16
Joined: Wed May 15, 2019 12:41 am
Location: Valparaiso, Chile.

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

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 97 guests