Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7846291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:32:07+00:00 2026-06-02T17:32:07+00:00

Note: This is not for a webpage, it is a simple program that holds

  • 0

Note: This is not for a webpage, it is a simple program that holds a set of images and will randomly pick a number of images and display them on the screen. Imagine working with an image editor and manually positioning imported images on the canvas.

I am having difficulty coming up with a way to position a set of arbitrary images on a screen of fixed dimension (it’s just a window)

So for example, if I have one image, I would probably just position it in the center of the screen.

          |

If I have two images, I would try to place them in the center of the screen, but then spread them apart horizontally so that they look centered relative to each other and also the screen.

     |          |

But what if one image is larger than the other two? I might have something like

    |-----|

  |         |

Similarly, maybe I have two larger ones and two smaller ones

|-----|   |-----|

  |         |

So that the large one appears “in the back” while the small ones are up front.

It is inevitable that some images will end up covering up parts of other images but the best I can do is try to make it as orderly as possible.

I can quickly grab the dimensions of each image object that is to be drawn, and there is a limit on how many images will be drawn (from 1 to 8 inclusive).

Images can be drawn anywhere on the screen, and if any part of the image is outside of the screen those parts will just be cut off. All images have dimensions smaller than the dimensions of the screen, and are typically no bigger than 1/4 of the entire screen.

What is a good way to approach this problem? Even handling the base cases like having two images (of possibly different sizes) is already pretty confusing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T17:32:09+00:00Added an answer on June 2, 2026 at 5:32 pm

    You could treat this as the 2D bin packing problem, which will optimise for non-overlapping rectangles in a “compact” way, though aesthetics won’t be a consideration.

    If you want to roll your own, you could try placing all images on the canvas on a grid, with the centre-to-centre spacing being large enough that no images overlap. Then “squash” the images closer together, left to right and top to bottom, to reduce the amount of whitespace.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please note that this is not homework and i did search before starting this
Screenshot Important Note : This application does not support Internet Explorer. I will be
Note that this function does not have a { and } body. Just a
(note that this question is not about CAS, it's about the May fail spuriously
Note This is not a REBOL-specific question. You can answer it in any language.
Note: this is not real information: $ ssh-keygen -t rsa -C "tekkub@gmail.com" Generating public/private
Note: this is NOT about concurrency. This is about the thread macro. I know
Please note this is not a question about online/hosted SVN services. I am working
Note: This is similar to this question but it is not the same. I
(Note: This is for MySQL's SQL, not SQL Server.) I have a database column

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.