initial commit
This commit is contained in:
18
node_modules/lifesized/.npmignore
generated
vendored
Normal file
18
node_modules/lifesized/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
.DS_Store
|
||||
node_modules
|
||||
npm-debug.log
|
||||
|
||||
build/*.app
|
||||
build/*.app.zip
|
||||
build/lifesized-cli/Build/Intermediates
|
||||
build/lifesized-cli/Logs
|
||||
build/lifesized-cli/info.plist
|
||||
build/ModuleCache
|
||||
|
||||
|
||||
README.md
|
||||
TODOS.md
|
||||
demos
|
||||
*.md
|
||||
lifesized-cli/*
|
||||
lifesized-cli.xcodeproj
|
||||
21
node_modules/lifesized/LICENSE
generated
vendored
Normal file
21
node_modules/lifesized/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Francois Laberge
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
72
node_modules/lifesized/README.md
generated
vendored
Normal file
72
node_modules/lifesized/README.md
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
### Overview
|
||||
An Electron module for displaying objects in physically accurate sizes on screens.
|
||||
|
||||
[Downloadable versions of the Demos are available](https://github.com/francoislaberge/lifesized/releases) 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
|
||||
|
||||
```bash
|
||||
npm install --save lifesized
|
||||
```
|
||||
|
||||
### Usage
|
||||
|
||||
```js
|
||||
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](#demo) and their [source](https://github.com/francoislaberge/lifesized/tree/master/examples) 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:
|
||||
|
||||
1. Get the code and npm install things
|
||||
|
||||
git clone git@github.com:francoislaberge/lifesized.git
|
||||
cd lifesized
|
||||
npm Install
|
||||
|
||||
2. Launch the coins demo
|
||||
|
||||
npm run coins
|
||||
|
||||
3. Get some coins and verify that they are the same size in real life as they are on screen.
|
||||
|
||||
<img src="https://raw.githubusercontent.com/francoislaberge/lifesized/master/demos/coins/screenshot.jpg" width="360">
|
||||
|
||||
4. 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
|
||||
See the [Todos](https://github.com/francoislaberge/lifesized/blob/master/TODOS.md) for planned work if you want to chip in.
|
||||
25
node_modules/lifesized/bin/build-apps.js
generated
vendored
Executable file
25
node_modules/lifesized/bin/build-apps.js
generated
vendored
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
// NOTE: OSX only for now
|
||||
|
||||
var execSync = require('child_process').execSync;
|
||||
|
||||
// Create an Electron app for each demo
|
||||
createApp("demos/coins", "Coins");
|
||||
createApp("demos/shaqs-hands", "ShaqsHands");
|
||||
createApp("demos/ruler", "Ruler");
|
||||
|
||||
// Copy electron-prebuilt's dist/Electron.app as a starting point and then
|
||||
// customize it
|
||||
function createApp(demoFolder, appName){
|
||||
execSync("rm -rf build/Electron.app");
|
||||
execSync("rm -rf build/" + appName + ".app");
|
||||
execSync("cp -r node_modules/electron-prebuilt/dist/Electron.app build");
|
||||
execSync("mkdir -p build/Electron.app/Contents/Resources/app");
|
||||
execSync("mv build/Electron.app/Contents/Resources/default_app/package.json build/Electron.app/Contents/Resources/app/");
|
||||
execSync("rm -rf build/Electron.app/Contents/Resources/default_app");
|
||||
execSync("cp -r " + demoFolder + "/ build/Electron.app/Contents/Resources/app");
|
||||
execSync("cp -r src build/Electron.app/Contents");
|
||||
execSync("cp -r bin build/Electron.app/Contents");
|
||||
execSync("mv build/Electron.app build/" + appName + ".app");
|
||||
}
|
||||
6
node_modules/lifesized/bin/npm-publish.sh
generated
vendored
Executable file
6
node_modules/lifesized/bin/npm-publish.sh
generated
vendored
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
npm version $1
|
||||
git push
|
||||
git push --tags
|
||||
npm publish
|
||||
BIN
node_modules/lifesized/build/lifesized-cli/Build/Products/Debug/lifesized-cli
generated
vendored
Executable file
BIN
node_modules/lifesized/build/lifesized-cli/Build/Products/Debug/lifesized-cli
generated
vendored
Executable file
Binary file not shown.
37
node_modules/lifesized/package.json
generated
vendored
Normal file
37
node_modules/lifesized/package.json
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "lifesized",
|
||||
"version": "0.10.2",
|
||||
"description": "Display things in life size",
|
||||
"main": "src/lifesized.js",
|
||||
"scripts": {
|
||||
"start": "npm start",
|
||||
"coins": "./node_modules/.bin/electron demos/coins/main.js",
|
||||
"shaqs-hands": "./node_modules/.bin/electron demos/shaqs-hands/main.js",
|
||||
"ruler": "./node_modules/.bin/electron demos/ruler/main.js",
|
||||
"build-apps": "node ./bin/build-apps.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"electron-prebuilt": "0.33.7"
|
||||
},
|
||||
"author": {
|
||||
"name": "Francois Laberge",
|
||||
"email": "francoislaberge@gmail.com"
|
||||
},
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/francoislaberge/lifesized"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/francoislaberge/lifesized/issues"
|
||||
},
|
||||
"homepage": "https://github.com/francoislaberge/lifesized",
|
||||
"keywords": [
|
||||
"CSS",
|
||||
"Units",
|
||||
"DPI",
|
||||
"PPI",
|
||||
"Pixel",
|
||||
"Ratio"
|
||||
]
|
||||
}
|
||||
64
node_modules/lifesized/src/lifesized.js
generated
vendored
Normal file
64
node_modules/lifesized/src/lifesized.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* lifesized: Get the physical size of displays and their ppi
|
||||
*/
|
||||
|
||||
var screen = require('screen'),
|
||||
execSync = require('child_process').execSync,
|
||||
path = require('path'),
|
||||
os = require('os');
|
||||
|
||||
var lifesized = {
|
||||
|
||||
/**
|
||||
* Get the pixels per inch of a screen
|
||||
*
|
||||
* @param [display] (Electron Screen Instance) If not provided the display
|
||||
this process' BrowserWindow' is over will be used
|
||||
*/
|
||||
ppi: function(display){
|
||||
display = display || getBrowserWindowDisplay();
|
||||
return getPPI(display);
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the pixels per inch of a screen
|
||||
*
|
||||
* @param objectRealSize (Number) Real size of an object in inches
|
||||
* @param objectPixelSize (Number) Size of the object in an image in pixels
|
||||
* @param [display] (Electron Screen Instance) If not provided the display
|
||||
this process' BrowserWindow' is over will be used
|
||||
*/
|
||||
scale: function(objectRealSize, objectPixelSize, display){
|
||||
var ppi = lifesized.ppi(display);
|
||||
return objectRealSize*ppi/objectPixelSize;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the display that the window is mostly over
|
||||
*/
|
||||
function getBrowserWindowDisplay(){
|
||||
// Don't require remote unless we hit here as it can't be required in the
|
||||
// main process. Main processes need to provide
|
||||
var remote = require('remote');
|
||||
return screen.getDisplayMatching(remote.getCurrentWindow().getBounds());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a screens PPI
|
||||
*/
|
||||
function getPPI(display){
|
||||
// If on a mac use our native binary to do the work, otherwise fall back
|
||||
// to a default
|
||||
if(os.platform() === "darwin"){
|
||||
return parseFloat(
|
||||
execSync(
|
||||
path.resolve(__dirname, "../build/lifesized-cli/Build/Products/Debug/lifesized-cli") + " " + display.id
|
||||
)
|
||||
);
|
||||
} else {
|
||||
return 72.0;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = lifesized;
|
||||
Reference in New Issue
Block a user