# Aspect ratio screen resizing

**URL:** <https://discourse.processing.org/t/aspect-ratio-screen-resizing/19538>\
**Category:** Coding Questions\
**Created:** [April 8, 2020, 12:57pm UTC](https://discourse.processing.org/t/aspect-ratio-screen-resizing/19538 "2020-04-08T12:57:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![s6277](https://avatars.discourse-cdn.com/v4/letter/s/cdc98d/32.png) [@s6277](https://discourse.processing.org/u/s6277)\
**Post date:** [April 8, 2020, 12:57pm UTC](https://discourse.processing.org/t/aspect-ratio-screen-resizing/19538/1 "2020-04-08T12:57:40Z")

</div>

Hey, I’m really struggling aspect ratio on processing, i want to be able to resize the screen and when i resize it the object inside is also resized according to the screen. I have currently used:

surface.setResizable(true);  
surface.setLocation(90, 90);  
(can also use scale(); or would that be wrong)  
This does allow me to change my screen but only o a certain limit and the object remains the same.  
Can someone please guide me through, as to what am i doing wrong.

Thank you.

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [April 8, 2020, 7:50pm UTC](https://discourse.processing.org/t/aspect-ratio-screen-resizing/19538/2 "2020-04-08T19:50:18Z")

</div>

Hello,

An example that uses scale() in proportion to screen size():

```auto
float iniWidth = 300; 
float iniHeight = 300;

void setup() 
  {
  size(300, 300);
  surface.setTitle("Hello World!");
  surface.setResizable(true);
  surface.setLocation(100, 100);
  }

void draw() 
  {
  background(204);
  scale(width/iniWidth, height/iniHeight);
  strokeWeight(2);
  rectMode(CENTER);
  rect(150, 150, 50, 50);
  line(0, 0, 300, 300);
  line(300, 0, 0, 300); 
  }

```

`:)`

---

<div class="post-metadata">

**Author:** ![Samaquias](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/samaquias/32/16203_2.png) [@Samaquias](https://discourse.processing.org/u/Samaquias)\
**Post date:** [May 9, 2022, 7:09pm UTC](https://discourse.processing.org/t/aspect-ratio-screen-resizing/19538/3 "2022-05-09T19:09:48Z")

</div>

within the context of p5.js - I am trying to digest the process of maintaining the aspect ratio of an image when resizing the window. Is it possible to position and scale images based on percentages??
