Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

lifesized

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lifesized

Display things in life size

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

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 git@github.com: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 or npm 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 git@github.com:francoislaberge/lifesized.git
cd lifesized
yarn install

See the Todos for planned work if you want to chip in.

Keywords

CSS

FAQs

Package last updated on 07 Sep 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts