concept width in category nativescript

appears as: width, Width
NativeScript in Action

This is an excerpt from Manning's book NativeScript in Action.

Dots per inch (DPI) is a measure of dot (or pixel) density on a mobile device’s screen. In mobile apps, it’s used to describe the number of pixels appearing in an inch of screen along the width or height. Most devices have the same DPI in both horizontal and vertical directions, so the DPI is described as a single number. For example, 400 DPI would mean 400 pixels per inch exist in each row and column of pixels.

Let’s go back to the percentage calculation to understand why the first column is 66.6% and the second column is 33.3%. You’ll recall the calculation adds the total number of stars in all columns, which is 3 stars (because 2* means 2 stars and 2* + * = 3 stars). Each column’s star count is divided by the total number of stars and changed to a percentage. This means the first column’s width is 2* (2 stars) divided by 3* (3 stars) = 66.6% and the second column’s width is * (1 star) divided by 3* (3 stars) = 33.3%.

Listing 9.12 Passing parameters to the takePicture() function on the update page to control the image size
exports.onAddImageTap = function (args) { var page = args.object; var scrapbookPage = page.bindingContext; camera.requestPermissions(); camera .takePicture({ width: 100, #1 height: 100, #1 keepAspectRatio: true}) #2 .then(function (picture) { image.fromAsset(picture).then(function (imageSource) { scrapbookPage.set("image", imageSource); }); }); } #1 Set the height and width of the image we take with the camera #2 Tell the camera module to maintain the aspect ratio of the picture taken