# Setting size of display window to a percentage of screen size

**URL:** <https://discourse.processing.org/t/setting-size-of-display-window-to-a-percentage-of-screen-size/22228>\
**Category:** Beginners\
**Created:** [June 29, 2020, 1:22am UTC](https://discourse.processing.org/t/setting-size-of-display-window-to-a-percentage-of-screen-size/22228 "2020-06-29T01:22:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luckyboy](https://avatars.discourse-cdn.com/v4/letter/l/919ad9/32.png) [@luckyboy](https://discourse.processing.org/u/luckyboy)\
**Post date:** [June 29, 2020, 1:22am UTC](https://discourse.processing.org/t/setting-size-of-display-window-to-a-percentage-of-screen-size/22228/1 "2020-06-29T01:22:33Z")

</div>

I’m trying to make a program where users input values and the program spits out a final value through an equation.

This is all pretty simple, but the one thing I can’t seem to figure out is display window sizing.

My display is 4k, so if I were to size the window a reasonable size for a 1080p screen, say 1000x1000 pixels, it would be tiny and unreadable for me and other 4k users.

A workaround I thought I found for this was sizing the window as half of the screen size using:

```auto
size(displayWidth*1>>2,displayHeight*1>>2);

```

but this spits out the error for only using numbers rather than variables for the size command.

This also means using integers at the beginning of the code to calculate a fraction of the screen size won’t work, ie.:

```auto
int sizeX = displayWidth*1>>2;
int sizeY = displayHeight*1>>2;

size(sizeX,sizeY);

```

Would there be any workaround for this or am I cursed to have to either change my screen resolution every time I run the program or run the program at fullscreen?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![SomeOne](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/someone/32/8639_2.png) [@SomeOne](https://discourse.processing.org/u/SomeOne)\
**Post date:** [June 29, 2020, 5:51am UTC](https://discourse.processing.org/t/setting-size-of-display-window-to-a-percentage-of-screen-size/22228/2 "2020-06-29T05:51:45Z")

</div>

`size()` usage is quite limited: It can be used only once and it requires explicit values, no variables. So you need to think a bit differently. You can use `displayWidth` to test display size and based on that set size like this.

```auto
void settings() {
  if (displayWidth > 2000) {
    size(2000,2000);
  } else if(displayWidth < 1000) {
    size(500,500);
  } else {
    size(1000,1000);
  }
  
}

```
