Skip to content

Commit

Permalink
[EPO-973] Support multipe skyviewer widgets.
Browse files Browse the repository at this point in the history
  * Add settings to lasso, circle and rectangle init methods.
  * `pointsFilter` takes settings.
  * Remove singleton settings variable.
  * Incremeent version to 0.2.8.

	modified:   README.md
	modified:   dist/bundle.js
	modified:   examples/circle/dist/app.bundle.js
	modified:   examples/circle/package.json
	modified:   examples/circle/src/app.js
	modified:   examples/circle/webpack.config.js
	modified:   examples/lasso/dist/app.bundle.js
	modified:   examples/lasso/dist/index.html
	modified:   examples/lasso/package.json
	modified:   examples/lasso/src/app.js
	modified:   examples/rectangle/package.json
	modified:   examples/rectangle/src/app.js
	modified:   package.json
	modified:   src/circle.js
	modified:   src/index.js
	modified:   src/lasso.js
	modified:   src/rectangle.js
	modified:   yarn.lock
  • Loading branch information
jmatt committed Jul 11, 2018
1 parent 79f14ec commit 90cbf4a
Show file tree
Hide file tree
Showing 18 changed files with 40,400 additions and 82 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@ To use it, import it and use one of the selection tools.
```javascript
import * as pst from 'paper-select-tool';

var core = document.getElementById('core');
var project;
var core = document.getElementById('core'),
settings;
window.onload = function() {
pst.lasso(core);
settings = Settings();
pst.lasso(settings, core);
}
// ...
var things = [{ point: new paper.Point(100, 100),
id: 'big bada boom' }];
var inSelection = pst.hitFilter(things);
var inSelection = pst.pointsFilter(settings, things);
// returns the filtered collection of objects with points in the selection.
```

Expand Down
2 changes: 1 addition & 1 deletion dist/bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20,124 changes: 20,123 additions & 1 deletion examples/circle/dist/app.bundle.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions examples/circle/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "paper-select-tool-circle-example",
"version": "0.1.8",
"version": "0.2.9",
"description": "Paper.js based selection tool example.",
"browser": "./dist/app.bundle.js",
"main": "./dist/app.bundle.js",
Expand Down Expand Up @@ -31,7 +31,7 @@
"http-server": "^0.11.1",
"npm": "^6.0.1",
"paper": "^0.11.5",
"paper-select-tool": "^0.1.8"
"paper-select-tool": "^0.2.9"
},
"devDependencies": {
"babel-cli": "^6.26.0",
Expand Down
5 changes: 3 additions & 2 deletions examples/circle/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ window.onload = function() {
core.style.width = '100vw';
core.height = document.body.height;
core.width = document.body.width;
pst.circle(core);
}
var settings = pst.Settings();
pst.circle(settings, core);
};
18 changes: 9 additions & 9 deletions examples/circle/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ const path = require('path');

module.exports = {
entry: {
app: './src/app.js'
app: './src/app.js',
},
output: {
filename: 'app.bundle.js',
path: path.resolve(__dirname, 'dist')
path: path.resolve(__dirname, 'dist'),
},
module: {
rules: [
Expand All @@ -16,13 +16,13 @@ module.exports = {
use: {
loader: 'babel-loader',
options: {
presets: ['env']
}
}
}
]
presets: ['env'],
},
},
},
],
},
stats: {
colors: true
}
colors: true,
},
};
20,210 changes: 20,209 additions & 1 deletion examples/lasso/dist/app.bundle.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion examples/lasso/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
<title>paper-select-tool</title>
</head>
<body style="width: 100vw; height: 100vh; margin: 0px;">
<canvas id="core"></canvas>
<canvas id="core"></canvas>
<canvas id="core2"></canvas>
<script src="app.bundle.js">
</script>
</body>
Expand Down
4 changes: 2 additions & 2 deletions examples/lasso/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "paper-select-tool-lasso-example",
"version": "0.1.8",
"version": "0.2.9",
"description": "Paper.js based selection tool example.",
"browser": "./dist/app.bundle.js",
"main": "./dist/app.bundle.js",
Expand Down Expand Up @@ -31,7 +31,7 @@
"http-server": "^0.11.1",
"npm": "^6.0.1",
"paper": "^0.11.5",
"paper-select-tool": "^0.1.8"
"paper-select-tool": "^0.2.9"
},
"devDependencies": {
"babel-cli": "^6.26.0",
Expand Down
25 changes: 20 additions & 5 deletions examples/lasso/src/app.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
// or var pst = require('paper-select-tool);
import * as pst from 'paper-select-tool';
import * as paper from 'paper';

var core = document.getElementById('core');
var core = document.getElementById('core'),
core2 = document.getElementById('core2');

window.onload = function() {
core.style.height = '100%';
core.style.background = '#eeeeee';
core.style.height = '50%';
core.style.width = '100vw';
core.height = document.body.height;
core.width = document.body.width;
core2.style.background = '#dedede';
core2.style.height = '50%';
core2.style.width = '100vw';
core2.height = document.body.height;
core2.width = document.body.width;
window.paper = paper;
var settings = new pst.Settings();
// configure settings through the pst.settings object.
pst.settings.strokeColor = '#08BCBC';
pst.lasso(core);
}
settings.strokeColor = '#08BCBC';
pst.lasso(settings, core);

var settings2 = new pst.Settings();
// configure settings through the pst.settings object.
settings2.strokeColor = '#08BCBC';
pst.lasso(settings2, core2);
};
4 changes: 2 additions & 2 deletions examples/rectangle/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "paper-select-tool-rectangle-example",
"version": "0.1.8",
"version": "0.2.9",
"description": "Paper.js based selection tool example.",
"browser": "./dist/app.bundle.js",
"main": "./dist/app.bundle.js",
Expand Down Expand Up @@ -31,7 +31,7 @@
"http-server": "^0.11.1",
"npm": "^6.0.1",
"paper": "^0.11.5",
"paper-select-tool": "^0.1.8"
"paper-select-tool": "^0.2.9"
},
"devDependencies": {
"babel-cli": "^6.26.0",
Expand Down
5 changes: 3 additions & 2 deletions examples/rectangle/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ window.onload = function() {
core.style.width = '100vw';
core.height = document.body.height;
core.width = document.body.width;
pst.rectangle(core);
}
var settings = pst.Settings();
pst.rectangle(settings, core);
};
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"name": "paper-select-tool",
"version": "0.1.8",
"version": "0.2.9",
"description": "Paper.js based selection tool.",
"browser": "./dist/bundle.js",
"main": "./dist/bundle.js",
"module": "./src/index.js",
"scripts": {
"start": "http-server",
"dev": "webpack --mode development",
"prettier": "prettier --single-quote --trailing-comma es5 './src/**/*.js' --write",
"prettier": "prettier --single-quote --trailing-comma es5 './src/**/*.js' --write",
"prettier-examples": "prettier --single-quote --trailing-comma es5 './examples/**/src/*.js' --write",
"build": "webpack --mode production",
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand Down
9 changes: 4 additions & 5 deletions src/circle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

import * as paper from 'paper';

import { settings } from './index.js';

export default function rectangleInit(canvas) {
export default function circleInit(settings, canvas) {
if (!canvas) canvas = document.createElement('canvas');
var ps = paper.default.setup(canvas);
var ps = new paper.default.PaperScope();
ps.setup(canvas);
settings.scope = ps;
var path1,
point1,
Expand Down Expand Up @@ -88,7 +87,7 @@ export default function rectangleInit(canvas) {
path1.fullySelected = true;
};

console.debug('Select Cricle Added!');
console.debug('Select Circle Added!');
ps.project.view.draw();
return ps;
}
5 changes: 2 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const rectangle = rectangleInit;
import circleInit from './circle';
export const circle = circleInit;

class Settings {
export class Settings {
constructor() {
this.alpha = 0.2;
this.lightness = 0.28;
Expand Down Expand Up @@ -66,9 +66,8 @@ class Settings {
this._strokeColor = strokeColor;
}
}
export let settings = new Settings();

export function pointsFilter(points) {
export function pointsFilter(settings, points) {
var hits = [];
points.forEach(function(p) {
var h = settings.scope.project.hitTest(p['point']);
Expand Down
8 changes: 3 additions & 5 deletions src/lasso.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

import * as paper from 'paper';

import { settings } from './index.js';

export default function lassoInit(canvas) {
export default function lassoInit(settings, canvas) {
if (!canvas) canvas = document.createElement('canvas');
var ps = paper.default.setup(canvas);
var ps = new paper.default.PaperScope();
ps.setup(canvas);
settings.scope = ps;

var path1,
path2,
segment,
Expand Down
8 changes: 3 additions & 5 deletions src/rectangle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

import * as paper from 'paper';

import { settings } from './index.js';

export default function rectangleInit(canvas) {
export default function rectangleInit(settings, canvas) {
if (!canvas) canvas = document.createElement('canvas');
var ps = paper.default.setup(canvas);
var ps = new paper.default.PaperScope();
ps.setup(canvas);
settings.scope = ps;

var path1,
point1,
path2,
Expand Down
Loading

0 comments on commit 90cbf4a

Please sign in to comment.