jessyhoule icon

Titanium / Device Independent Size

jessyhoule | PRO | 10/19/15 06:03:45 AM UTC | 0 ⭐ | 200 👁️ | Never ⏰ | []
JavaScript |

1.31 KB

|

None

|

0 👍

/

0 👎

// device independent size caclulations 
var baseSize = Math.min(Ti.Platform.displayCaps.platformWidth, Ti.Platform.displayCaps.platformWidth);
var baseDPI = Ti.Platform.displayCaps.dpi;
 
function getDeviceIndependentSize(num) {
    'use strict';
    var tpSize = 0;
     
    if (Ti.Platform.osname === 'android') {
        tpSize = Math.ceil( baseSize * num / 320 );
        tpSize = tpSize * (160 / baseDPI);
    }
    else {
        tpSize = Math.ceil( baseSize * num / 320 );
    }
    
    return tpSize;
}
 
// size settings
var giftCardScreenSettings = {
    containerWidth: getDeviceIndependentSize(290),
    partnerLogoWidth: getDeviceIndependentSize(290),
    partnerLogoHeight: getDeviceIndependentSize(165),
    companyNameLabelFontSize: getDeviceIndependentSize(10),
    priceLabelFontSize: getDeviceIndependentSize(29),
    redeemButtonFontSize: getDeviceIndependentSize(16),
    barCodeLabelFontSize: getDeviceIndependentSize(100),
    giftCardTextLabelFontSize: getDeviceIndependentSize(8),
    giftCardNumberLabelFontSize: getDeviceIndependentSize(24),
    giftCardPinTextLabelFontSize: getDeviceIndependentSize(8),
    giftCardPinLabelFontSize: getDeviceIndependentSize(24),
    legalLabelFontSize: getDeviceIndependentSize(10),
    legalLabelTopMarginOnRedeem: getDeviceIndependentSize(10)
};

Comments