How to get the covered area?

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
User avatar
darkfrei
Party member
Posts: 1178
Joined: Sat Feb 08, 2020 11:09 pm

How to get the covered area?

Post by darkfrei »

Hi all!
I have this code:

Code: Select all

function love.draw()
	-- getPixelDimensions
	pixelwidth, pixelheight = love.graphics.getPixelDimensions( )
	love.graphics.print('pixelwidth: '..pixelwidth..' pixelheight: '..pixelheight, 64, 64)
	
	-- getDimensions
	width, height = love.graphics.getDimensions( )
	love.graphics.print('width: '..width..' height: '..height, 64, 100)
	
	-- circle in the middle
	love.graphics.circle("line", width/2, height/2, math.min(width/2, height/2))
end
It gets the following picture. As you see, the android has covered area, in this situation it's 72 pixels.

1. How to get the size of this cover ribbon?
2. Why getPixelDimensions are not same as getDimensions?
Attachments
covered-03.love
(635 Bytes) Downloaded 209 times
Screenshot_20210101-153150.jpg
Screenshot_20210101-153150.jpg (89.08 KiB) Viewed 6316 times
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
darkfrei
Party member
Posts: 1178
Joined: Sat Feb 08, 2020 11:09 pm

Re: How to get the covered area?

Post by darkfrei »

For example same code on windows10 (150% scale because of 4K)

(here is no covered area, size and pixel size are same)
Attachments
2021-01-01T19_46_12-Untitled.png
2021-01-01T19_46_12-Untitled.png (68.37 KiB) Viewed 6313 times
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
darkfrei
Party member
Posts: 1178
Joined: Sat Feb 08, 2020 11:09 pm

Re: How to get the covered area?

Post by darkfrei »

The same, but from the tablet, covered 32 top pixels:
Also 64 bottom pixels, but without covering.
Attachments
Screenshot_20210101-194951.png
Screenshot_20210101-194951.png (42.75 KiB) Viewed 6312 times
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
slime
Solid Snayke
Posts: 3132
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: How to get the covered area?

Post by slime »

darkfrei wrote: Fri Jan 01, 2021 6:38 pm 1. How to get the size of this cover ribbon?
love.window.getSafeArea should get the screen area not covered by the bar I think - if not, there might be issues within SDL that the upcoming love 11.4 release might fix.
darkfrei wrote: Fri Jan 01, 2021 6:38 pm 2. Why getPixelDimensions are not same as getDimensions?
DPI scaling (which as per the other thread isn't supported at all on Windows, currently).
User avatar
AuahDark
Party member
Posts: 107
Joined: Mon Oct 23, 2017 2:34 pm
Location: Indonesia
Contact:

Re: How to get the covered area?

Post by AuahDark »

There's currently issue in 11.3 which causes the area behind the status bar counted as part of the draw area. The upcoming 11.4 fixes that issue.
Profile. Do you encounter crashes in LÖVE Android and wanna send me logcats? Please hit me up in LÖVE Discord and send the full logcat file!
Post Reply

Who is online

Users browsing this forum: No registered users and 198 guests