Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
felipenmoura committed Oct 3, 2014
1 parent b7859d0 commit 4fb998a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
17 changes: 16 additions & 1 deletion ck.js
Expand Up @@ -53,6 +53,19 @@ window.ck= (function(_d){

};

// criamos a função a ser executada no click
var _videoClick= function(evt){
// pegamos as cordenadas do click dentro do canvas
var line= evt.offsetY,
col= evt.offsetX,
// pegamos os pixels da imagem, exatamente no ponto onde foi clicado
frame= _ctx.getImageData(col, line, 1, 1),
// pegamos as cores rgb do pixel clicado
px= [frame.data[0], frame.data[1], frame.data[2]];
// e setamos como referência
_colors= px;
};

var _constructor= function(){

_w.URL= _w.URL || _w.webkitURL;
Expand All @@ -74,11 +87,13 @@ window.ck= (function(_d){

setInterval(_videoPlaying, 60);

// vamos usar o input range para definir a distância aceita
_d.getElementById('range').addEventListener('change', function(){
_range= 255 - this.value;
});

// começamos a escutar o click, no canvas
_canvas.addEventListener('click', _videoClick);

}, function(){
alert('O usuário não permitiu!');
});
Expand Down
1 change: 0 additions & 1 deletion index.html
Expand Up @@ -17,7 +17,6 @@
}
video{
border: solid 1px red;
/* vamos esconder o vídeo aqui */
position: absolute;
left: -999px;
}
Expand Down

0 comments on commit 4fb998a

Please sign in to comment.