Skip to content

Commit

Permalink
Refactor sample code
Browse files Browse the repository at this point in the history
  • Loading branch information
habbes committed Aug 4, 2018
1 parent 62ef368 commit dbbb088
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 78 deletions.
27 changes: 4 additions & 23 deletions src/samples/edge-detection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,10 @@ camera.start();
// create edge detection widget
widgets.define('EdgeDetection', {
params: {
threshold1: {
type: 'number',
min: 1,
max: 500,
initial: 50
},
threshold2: {
type: 'number',
min: 1,
max: 500,
initial: 100
},
apertureSize: {
type: 'number',
min: 3,
max: 7,
step: 2,
initial: 3
},
l2Gradient: {
type: 'boolean',
initial: false
}
threshold1: { type: 'number', min: 1, max: 500, initial: 50 },
threshold2: { type: 'number', min: 1, max: 500, initial: 100 },
apertureSize: { type: 'number', min: 3, max: 7, step: 2, initial: 3 },
l2Gradient: { type: 'boolean', initial: false }
},
inputs: ['image'],
outputs: ['edges'],
Expand Down
21 changes: 3 additions & 18 deletions src/samples/simple-green-screen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,9 @@ const cameraStream = camera.getStream({ fps: 30 });
widgets.define('Blend', {
params: {
minG: {
type: 'number',
min: 0,
max: 255,
initial: 200
},
maxR: {
type: 'number',
min: 0,
max: 255,
initial: 50
},
maxB: {
type: 'number',
min: 0,
max: 255,
initial: 50
}
minG: { type: 'number', min: 0, max: 255, initial: 200 },
maxR: { type: 'number', min: 0, max: 255, initial: 50 },
maxB: { type: 'number', min: 0, max: 255, initial: 50 }
},
inputs: ['green', 'target'],
outputs: ['res'],
Expand Down
42 changes: 6 additions & 36 deletions src/samples/widgets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,12 @@ const img = files.readImage('file1');
widgets.define('Rotation', {
// define parameters for this widget
params: {
angle: {
type: 'number',
min: -180,
max: 180,
initial: 0
},
scale: {
type: 'number',
initial: 1,
min: 0,
max: 5,
step: 0.1
},
interpolation: {
type: 'number',
control: 'select',
initial: 1,
options: {
1: 'Linear',
2: 'Cubic',
3: 'Area',
0: 'Nearest'
}
},
border: {
type: 'number',
control: 'select',
initial: 0,
options: {
0: 'Constant',
1: 'Replicate',
2: 'Reflect',
3: 'Wrap',
4: 'Reflect 101'
}
}
angle: { type: 'number', min: -180, max: 180, initial: 0 },
scale: { type: 'number', initial: 1, min: 0, max: 5, step: 0.1 },
interpolation: { type: 'number', control: 'select', initial: 1,
options: { 1: 'Linear', 2: 'Cubic', 3: 'Area', 0: 'Nearest' } },
border: { type: 'number', control: 'select', initial: 0,
options: { 0: 'Constant', 1: 'Replicate', 2: 'Reflect', 3: 'Wrap', 4: 'Reflect 101' } }
},
// define inputs
inputs: ['image'],
Expand Down
2 changes: 1 addition & 1 deletion src/ui/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ body {
display: flex;
align-items: center;
font-size: 0.8em;
width: 90px;
min-width: 90px;
justify-content: center;
}

Expand Down

0 comments on commit dbbb088

Please sign in to comment.