For example, if I have the following rows: 25, 50, 25, then the total size is 100 and their percentages are 25%, 50%, 25%. If the display is then resized to 111 pixels, the percentages yield 27.75px, 55.5px, 27.75 px. How do I decide who gets an extra pixel and who gets it taken away? (the problem looks tougher when you have percentages that yield numbers like 10.17px, 11.1245px...)
How do I create an algorithm to decide this "intelligently?"
Originally posted by Paul Clapham:
You might not think that this article is relevant to your question, but scroll down until you see Alexander Hamilton mentioned and start reading there.
Hmm, that's a pretty good start, but it doesn't fully answer the following (IMO):
Nor this one:
In the first, you've got equal remainders so we're again back to the original question. With the second, while I can just give an extra pixel to "C," "B" is so close to 55 that it almost seems incorrect to push it all the way back to 54.
Originally posted by Ilja Preuss:
Don't calculate the width of each component. Instead, calculate its left and right boundary, by adding up the percentages of all components left of it.
Would that help?
I'm not sure I follow you on this. Can you give some pseudo code to help explain what you mean? Thanks!
Yeah. The article doesn't actually say there is no good answer to the question (or does it? I didn't read the whole durn thing either), but that's basically the case. No matter which algorithm you choose, there are always cases where that algorithm produces ugly results.
Originally posted by Dan Bizman:
Hmm, that's a pretty good start, but it doesn't fully answer the following (IMO):...