# \[Solved\] How do I get consistant screen dimensions with zoomEven?

**URL:** <https://forums.solar2d.com/t/solved-how-do-i-get-consistant-screen-dimensions-with-zoomeven/355132>\
**Category:** General Questions/Discussion\
**Created:** [October 22, 2022, 12:12am UTC](https://forums.solar2d.com/t/solved-how-do-i-get-consistant-screen-dimensions-with-zoomeven/355132 "2022-10-22T00:12:15Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Develephant](https://forums.solar2d.com/user_avatar/forums.solar2d.com/develephant/32/2729_2.png) [@Develephant](https://forums.solar2d.com/u/Develephant)\
**Post date:** [October 22, 2022, 12:12am UTC](https://forums.solar2d.com/t/solved-how-do-i-get-consistant-screen-dimensions-with-zoomeven/355132/1 "2022-10-22T00:12:15Z")

</div>

Hi,

Trying to do something incredibly simple. I just want to put a rectangle on each side of the screen for use with physics. The app is set to `zoomEven`.

I have tried every display parameter on the list, but cannot get a consistant result. Hopefully someone can enlighten me.

This is my final code before giving up. The left and top are working fine, but the right, bottom is a severe pain in my rear.

```lua
  local side_box_width = 120
  local side_box_height = 0 --will come from screen size
  local top_bottom_box_width = 0 --will come from screen size
  local top_bottom_box_height = 120

  -- Create a vector rectangle sized exactly to the "screen area"
  local area = display.newRect(
      display.screenOriginX, 
      display.screenOriginY,
      display.contentWidth, 
      display.contentHeight
  )

  print(area.x, area.y, area.width, area.height)

  area.isVisible = false

  local left_box = display.newRect(area.x, area.y, side_box_width, area.height)
  local right_box = display.newRect(area.width, area.y, side_box_width, area.height)
  local top_box = display.newRect(area.x, area.y, area.width, top_bottom_box_height)
  local bottom_box = display.newRect(area.x, area.height, area.width, top_bottom_box_height)

```

Note: They are not centered at the moment, but that is intentional for the testing.

Config snippet:

```lua
width = 640,
height = 960, 
scale = "zoomEven",

```

Thanks in advance for any tips.

-dev

---

<div class="post-metadata">

**Author:** ![Siu](https://forums.solar2d.com/user_avatar/forums.solar2d.com/siu/32/2129_2.png) [@Siu](https://forums.solar2d.com/u/Siu)\
**Post date:** [October 22, 2022, 3:00am UTC](https://forums.solar2d.com/t/solved-how-do-i-get-consistant-screen-dimensions-with-zoomeven/355132/2 "2022-10-22T03:00:33Z")

</div>

Not sure whether this is what you’re looking for, but:

```lua
local side_box_width = 120
  local side_box_height = 0 --will come from screen size
  local top_bottom_box_width = 0 --will come from screen size
  local top_bottom_box_height = 120

  -- Create a vector rectangle sized exactly to the "screen area"
  local area = display.newRect(
      display.screenOriginX, 
      display.screenOriginY,
      display.actualContentWidth, 
      display.actualContentHeight
  )

  print(area.x, area.y, area.width, area.height)

 -- area.isVisible = false

  local left_box = display.newRect(area.x, area.y, side_box_width, area.height):setFillColor(1,0,0)
  local right_box = display.newRect(area.width+display.screenOriginX, area.y, side_box_width, area.height):setFillColor(0,1,0)
  local top_box = display.newRect(area.x, area.y, area.width, top_bottom_box_height):setFillColor(0,0,1)
  local bottom_box = display.newRect(area.x, area.height+display.screenOriginY, area.width, top_bottom_box_height):setFillColor(1,1,0)

```

Key notes:  
For the right and bottom you’ll want to use `actualContentWidth` and `actualContentHeight`.  
I’m not sure exactly how the numbers differ between `letterBox` and `zoomEven`, but to get an accurate position for right and bottom you might also need to add `screenOriginX` and `screenOriginY` respectively.

---

<div class="post-metadata">

**Author:** ![XeduR](https://forums.solar2d.com/user_avatar/forums.solar2d.com/xedur/32/256_2.png) [@XeduR](https://forums.solar2d.com/u/XeduR)\
**Post date:** [October 22, 2022, 8:07am UTC](https://forums.solar2d.com/t/solved-how-do-i-get-consistant-screen-dimensions-with-zoomeven/355132/3 "2022-10-22T08:07:06Z")

</div>

I’ve been using my screen module to accomplish that:

> <https://github.com/SpyricGames/Solar2D-Plugins-Public/blob/main/Screen/spyric/screen.lua>

When you require my module, you can just access its properties to get the minimum and maximum x and y coordinates for the screen, as well as its width, height, etc.

Also, personally, I’ve always preferred letterbox over other scaling modes.

---

<div class="post-metadata">

**Author:** ![Develephant](https://forums.solar2d.com/user_avatar/forums.solar2d.com/develephant/32/2729_2.png) [@Develephant](https://forums.solar2d.com/u/Develephant)\
**Post date:** [October 22, 2022, 8:02pm UTC](https://forums.solar2d.com/t/solved-how-do-i-get-consistant-screen-dimensions-with-zoomeven/355132/4 "2022-10-22T20:02:19Z")

</div>

Bingo! Thank you. I still don’t quite understand so I’m gonna need to study up a bit. 🙂

Thank you for your help, I really appreciate it.

-dev

---

<div class="post-metadata">

**Author:** ![Develephant](https://forums.solar2d.com/user_avatar/forums.solar2d.com/develephant/32/2729_2.png) [@Develephant](https://forums.solar2d.com/u/Develephant)\
**Post date:** [October 22, 2022, 8:04pm UTC](https://forums.solar2d.com/t/solved-how-do-i-get-consistant-screen-dimensions-with-zoomeven/355132/5 "2022-10-22T20:04:47Z")

</div>

Hi,

I actually have been using `screen` and I like it very much, but it wasn’t giving me good results either. But probably wasn’t using it correctly looking at the answer above. Historically I do letterbox but I really dislike having any overflow, there is a particular aesthetic to a full screen immersive app that is hard to recreate with letterbox. Screen is now a part of my app toolkit, so thank you for sharing the code. 👍

---

<div class="post-metadata">

**Author:** ![Develephant](https://forums.solar2d.com/user_avatar/forums.solar2d.com/develephant/32/2729_2.png) [@Develephant](https://forums.solar2d.com/u/Develephant)\
**Post date:** [October 22, 2022, 8:24pm UTC](https://forums.solar2d.com/t/solved-how-do-i-get-consistant-screen-dimensions-with-zoomeven/355132/6 "2022-10-22T20:24:33Z")

</div>

Hi,

I just tried again using `screen` and it works perfectly. 🤦‍♂️

Not sure what I missed the first time, but I will never underestimate the power of `screen` again. 💪

-dev

---

<div class="post-metadata">

**Author:** ![XeduR](https://forums.solar2d.com/user_avatar/forums.solar2d.com/xedur/32/256_2.png) [@XeduR](https://forums.solar2d.com/u/XeduR)\
**Post date:** [October 23, 2022, 2:46pm UTC](https://forums.solar2d.com/t/solved-how-do-i-get-consistant-screen-dimensions-with-zoomeven/355132/7 "2022-10-23T14:46:07Z")

</div>

If you’re on Android, it may be an issue with the ”immersiveSticky” mode that takes a moment to kick in, which leads to the screen size changing once it does.
