This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for(var i = 0; i < 50; i++){ | |
var x = Math.random()*width, | |
y = Math.random()*height, | |
vx = (Math.random()*8)-4, | |
vy = (Math.random()*8)-4, | |
size = Math.floor(Math.random()*60)+60; | |
points.push({x:x,y:y,vx:vx,vy:vy, size:size}); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function metabalize(){ | |
var imageData = tempCtx.getImageData(0,0,width,height), | |
pix = imageData.data; | |
for (var i = 0, n = pix.length; i <n; i += 4) { | |
// Checks threshold | |
if(pix[i+3]<threshold){ | |
pix[i+3]=0; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sum = function(){ | |
var arr = [].slice.apply(arguments), | |
total = arr.reduce(function(a,b){ | |
b = parseInt(b); | |
if(!isNaN(b)){ | |
return a+b; | |
}else{ | |
return a; | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<canvas id="canvas"></canvas> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cards = []; | |
function initDeck(){ | |
for(var cardNum = 1; cardNum < 14; cardNum++){ | |
for(var i = 0; i < 4; i++){ | |
var suit = i; | |
switch(i){ | |
case 0: | |
suit = "\u2665"; | |
break; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="hitarea"> | |
<div id="a-1" class="hitbox"></div> | |
<div id="a-2" class="hitbox"></div> | |
<div id="a-3" class="hitbox"></div> | |
<div id="a-4" class="hitbox"></div> | |
<div id="a-5" class="hitbox"></div> | |
<div id="b-1" class="hitbox"></div> | |
<div id="b-2" class="hitbox"></div> | |
<div id="b-3" class="hitbox"></div> | |
<div id="b-4" class="hitbox"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<canvas id="canvas"></canvas> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<canvas id="canvas"></canvas> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getOffsetRect(elem) { | |
var box = elem.getBoundingClientRect(), | |
body = document.body, | |
docElem = document.documentElement, | |
scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop, | |
scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft, | |
clientTop = docElem.clientTop || body.clientTop || 0, | |
clientLeft = docElem.clientLeft || body.clientLeft || 0, | |
top = box.top + scrollTop - clientTop, | |
left = box.left + scrollLeft - clientLeft, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function post(url, data, callback){ | |
var ajaxRequest = new XMLHttpRequest(); | |
ajaxRequest.onreadystatechange = function(){ | |
if(ajaxRequest.readyState == 4 || ajaxRequest.readyState == 200){ | |
callback(ajaxRequest.responseText); | |
} | |
} | |
ajaxRequest.open("POST", url); | |
ajaxRequest.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); |