Hacker News new | ask | show | jobs
by granttimmerman 4321 days ago
Fun stuff.

  function action(){
    var opacity1 = $('#color-1')[0].getContext('2d').getImageData(0,0,1,1).data[3];
    var opacity2 = $('#color-2')[0].getContext('2d').getImageData(0,0,1,1).data[3];
    if(opacity1 > opacity2){
      $('#color-1').trigger('click');
    }else{
      $('#color-2').trigger('click');
    } 
  };

  setInterval('action()', 100);
1 comments

I think the game has been updated, now the opacity of both colors are the same (255) but you can sum R, G and B parts. The highest will be the brightest.
function c(i,j){return $("#color-"+i)[0].getContext('2d').getImageData(0,0,1,1).data[j]} setInterval(function(){$("#color-"+(1+(c(1,0)+c(1,1)+c(1,2)<c(2,0)+c(2,1)+c(2,2)))).click()},1)