11define ( [ 'util' ] , function ( $ ) {
22
3- function camera2video ( _video = { } ) {
3+ function pipeCameraTo ( _video = { } ) {
44 if ( _video . tagName !== 'VIDEO' ) {
55 throw Error ( 'Pipes only to video elements' ) ;
66 }
@@ -31,19 +31,19 @@ define(['util'], function ($) {
3131 }
3232
3333 function video2canvas ( _video , _canvas ) {
34- var context , height , width , interval ;
34+ var context , height , width ;
3535
3636 context = _canvas . getContext ( '2d' ) ;
3737 height = _canvas . height = _video . videoHeight ;
3838 width = _canvas . width = _video . videoWidth ;
39- interval = setInterval ( foo => {
40- context . drawImage ( _video , 0 , 0 , width , height ) ;
41- } ) ;
4239 _video . hidden = true ;
4340
4441 return {
4542 _ : 'video2canvas' ,
46- _video, _canvas, context, height, width, interval,
43+ _video, _canvas, context, height, width,
44+ draw : foo => {
45+ context . drawImage ( _video , 0 , 0 , width , height ) ;
46+ } ,
4747 } ;
4848 }
4949
@@ -66,7 +66,7 @@ define(['util'], function ($) {
6666 }
6767
6868 return {
69- camera2video ,
69+ pipeCameraTo ,
7070 video2canvas,
7171 snapCanvas,
7272 } ;
0 commit comments