One Rect For All specificaiton
Sannyasin Brahmanathaswami
brahma at hindu.org
Wed Jan 27 23:39:22 CET 2016
FYI: My function was using the device ratio based on the screen rect….but your math uses the device *pixels* either way, the ratio is the same
16:9 | 736:414 | 1080:1920 and this does not affect your math:
( 1024 - (768/414*736) ) /2 = -171 (170.5) So thanks for that… I will try it… for the horizontal...
function getAltCardHeight tScreenRect
# get ratio for landscape height
put ( item 4 of tScreenRect/item 3 of tScreenRect) into tRatioForVertical
put ( (the width of this card) * tRatioForVertical) into tNewCardHeight
return tNewCardheight
end getAltCardHeight
The pillar box effect is clear… as you described it
But the scenario that I cannot solve is: a 16:9 stack running this on a 3:4 iPad… that’s the challenge to move a control to the bottom.
but perhaps it is the same math, just “turned vertically.”
Using your original suggestion “use any size comfortable to you” I choose 16:9 | 1200:675px stack size. Runs beautifully on iPhone 6+
Stating this for the vertical axis (trying to)
If you have a card that is 1200 X 675 (16:9) running on a device that is 3:4 (1024 X 768), showAll will make you see the full vertical 675 + (225/2) top and bottom.
So far this is true and can be demonstrated to be true. But the only value that works to set the bottom of a bottom control , is the “native” points height: 788 = 768 + 20 status bar)
We can hardwire this into the code for iPad, but then it is not an algorithm that ports to all the various Android devices. i.e. a single algorithm that works
*any ratio/point dimensions* to *any other ratio/point dimensions*
where we use some value reported by LC that will calculate the position of left or right (as you have done) or the top or bottom (still unsolved)
On January 27, 2016 at 11:32:52 AM, Colin Holgate (colinholgate at gmail.com<mailto:colinholgate at gmail.com>) wrote:
It’s the ratio of the device screen you need, not the ratio of the card.
To elaborate on that…
If you have a card that is 1024x768, running on a device that is 1920x1080, showAll will make you see the 1024x768, with an extra 171 pixels either side, to make 1366x768. That is then scaled up to fill the 1920x1080.
An object in the upper left corner would have its top at zero, but it’s left would want to be at -171. You can calculate that -171 like this:
(1024 - 768/1080<tel://1024%20-%20768/1080>*1920)/2
More generally, the left edge is the card width minus the card height divided by the device height, times the device width. All divided by 2.
More information about the use-livecode
mailing list