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 4078930
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:44:09+00:00 2026-05-20T17:44:09+00:00

Here is the problem. I have rectangular canvas that have size of 1. So

  • 0

Here is the problem. I have rectangular canvas that have size of 1. So it have coordinate sistem of (0.0 … 1.0 – x and 0.0 … 1.0 – y).

I also have some tiles. Tiles are also rectangles. They have diffrent size and amount of tiles is a variable.

I want to stack tiles in rectangular canvas, from 0.0 to 1.0 (from left to right, from top to bottom):

1) tiles have to fit in canvas (but fill as much space as they could)

2) tiles have to be scaled (if they don’t fit), each tile should be scaled by the same amount (they have to remain same proportions).

3) imagine that you have this ’tiles’ in your hand, and you placing them into this canvas one after another

4) it almost like “TreeMap algorithm” but – shape of tiles have to be the same (rectangles) and i don’t need to fill all space of canvas

here is what i want to get

Is there anybody who can show me an algoritm in any C alike language (C, C++, Java, C#)?

*I tried this.

1) i calculated area of tile, then i calculate a sum of tile’s areas (for example: i have two tiles, one have area of 2, other area of 1, them it’s mean i have total sum of 3)

2) then i calculate what “proportion” each tile have in “total sum of areas” (for example: 2/3 and 1/3)

3) then calculate size of rectangle tile by Math.sqrt(x) (for example: Math.sqrt(2/3))

4) then draw tile one by one…

But this dosen’t work always. Sometimes i get tiles to be out of canvas..*

  • 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-05-20T17:44:10+00:00Added an answer on May 20, 2026 at 5:44 pm

    As others pointed – problem description is not very clear. But i’m assuming that you can scale each tile as you need (at least your examples shows that tile scaling is possible). So my solution will be simple (but maybe not what you want nor optimal):

    • Scale each tile by factor :
      EDGEspace / (EDGEtile * N ½)
    • Place each tile in current row, if tile gets out of space limits – advance to next row.

    Here N is nearest perfect square greater or equal to the total number of tiles.

    p.s. If you need some spacing between tiles – just make above scale factor a little bit smaller.

    Hope that helps.

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

Sidebar

Related Questions

Here's my problem - I have some code like this: <mx:Canvas width=300 height=300> <mx:Button
Here's my problem: I have a virtual method defined in a .h file that
Here's the problem: 1.) We have page here... www.blah.com/mypage.html 2.) That page requests a
Here's my problem I have some code and I'm using it to send an
Here's my problem : I have an Activity that includes a ListView with different
Here's my problem: I have a datagrid that is bound to a collection of
Here's my problem: I have a button in my android application that when I
I've got a strange problem here. I have a class that I'll call MainView
Here is the problem I have: I have a lot (tens of thousands) of
Here is the problem: we have lots of Javascripts and lots of CSS files,

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.