lifesized
v1.0.1
Published
Display things in life size
Downloads
63
Maintainers
Readme
Overview
An Electron module for displaying objects in physically accurate sizes on screens.
Downloadable versions of the Demos are available for Macs.
I hope this module and its uses will convince browser makers to provide this as a native API or at least to Electron in its core
Installation
npm install --save lifesized
Usage
var lifesized = require('lifesized');
// Get the pixels per inch of the display the current render process' BrowserWindow
// is mostly overlayed on
var pixelsPerInch = lifesized.ppi();
See the Demos and their source for a working example.
API
lifesized.ppi(display)
Get the Pixels Per Inch of a display.
- display (optional*) - The Display who's PPI you want. If not provided it use the display the current BrowserWindow is most over.
Returns: (Number) The displays Pixels Per Inch.
lifesized.scale(objectRealSize, objectPixelSize, display)
Calculate how much you have to scale an object in an image to make it appear life sized on the screen.
- objectRealSize (Number) Real size of an object in inches
- objectPixelSize (Number) Size of the object in an image in pixels
- display (optional*) The Display you want to show the object on. If not provided it use the display the current BrowserWindow is most over.
Returns: (Number) Scale factor to use to scale images (1.0 === 100%)
* Some OSs display windows on multiple displays at once when a Window spans
more than one display, some do not. We use the best guest using Electron's screen.getDisplayMatching(rect)
Demos
To run the coins app that shows this off do the following:
Get the code and npm install things
git clone [email protected]:francoislaberge/lifesized.git cd lifesized npm Install
Launch the coins demo
npm run coins
Get some coins and verify that they are the same size in real life as they are on screen.
- Run other demos via
npm run shaqs-hands
ornpm run ruler
Limitations
- Only accurate on OSX right now, falls back to a sane default of 72 pixels/inch (Pull Requests welcome, I will add Windows/Linux support as soon as I can)
- Doesn't currently detect when a BrowserWindow's Display changes (This should be detectable, will add ASAP)
Contributing
git clone [email protected]:francoislaberge/lifesized.git
cd lifesized
yarn install
See the Todos for planned work if you want to chip in.