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
//http://www.gamedev.net/topic/579738-web-javascript-game-loop/ | |
//http://dev.opera.com/articles/view/framerate-control-system-for-javascript/ | |
//http://jsfiddle.net/digitalicarus/4kshN/3/ | |
var WEE = { | |
FPS: 60, | |
rate: 60, | |
dt: 1/60, | |
accrued: 0.0, | |
last: Date.now()/1000, |
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 roundRect = function(ctx,o) { | |
if(!ctx || !o.x || !o.y || !o.w || !o.h || !o.r) { | |
return; | |
} | |
var x = o.x, | |
y = o.y, | |
w = o.w, | |
h = o.h, | |
r = o.r, |
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
/* http://www.gameprogrammer.com/fractal.html */ | |
// Also, as expected, shifting is waaay faster than division, even in JS :) http://jsperf.com/division-vs-shift unfortunately it also truncates to the mantissa of floating points | |
// http://jsfiddle.net/digitalicarus/YUDgH/24/ | |
// TODO: abs option, obj args, exception reason | |
var calcTerrain = function(conf) { | |
var height = conf.height, | |
swing = conf.swing, | |
h = conf.decay || conf.smooth || conf.smoothness, | |
i = conf.degree, | |
lb = (height-swing < 0) ? conf.lowerBound : null, |
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($){ | |
$.fn.voila = function(content,cb) { | |
return this.each(function() { | |
var $this = $(this); | |
if($this.is(":visible")) { | |
//-- http://stackoverflow.com/questions/4085800/jquery-animate-changes-in-div-height-on-ajax-l | |
console.log("voila: origHeight="+$this.height()); | |
$this | |
.animate({height: $this.height(), opacity: 'hide'}, 'fast', function(){ |
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
/** | |
* Calls an array of asynchronous functions and calls the continuation | |
* function when all are done. | |
* @param {Array} functions Array of asynchronous functions, each taking | |
* one argument that is the continuation function that handles the result | |
* That is, each function is something like the following: | |
* function(continuation) { | |
* // compute result asynchronously | |
* continuation(result); |
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
//-- JS number | |
[-+]?(?:(?:\d+)|(?:\d+\.\d+)|(?:\.\d+))(?:e[-+]?\d+)? | |
//-- vim non-greedy multiline http://www.fumbling-in-the-dark.com/2011/08/non-greedy-multi-line-search-and.html | |
%s/text1\_.\{-}text2/text3/ |
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 asyncLoader (s, cb) { | |
var d = document | |
, h = document.getElementsByTagName('head')[0] | |
, b = (Math.random()*1e8>>0) | |
, i = 'loader_'+b | |
, t = (/\.js$/.test(s)) ? "js" : "css" | |
, j = (t === 'js') ? d.createElement('script') : d.createElement('link'); | |
j.id = i; |
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
Show hidden characters
{ | |
// -------------------------------------------------------------------- | |
// JSHint Configuration, Strict Edition | |
// -------------------------------------------------------------------- | |
// | |
// This is a options template for [JSHint][1], using [JSHint example][2] | |
// and [Ory Band's example][3] as basis and setting config values to | |
// be most strict: | |
// | |
// * set all enforcing options to true |
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 parseQueryString(altStr) { | |
var s = altStr || window.location.search.substring(1) | |
, p = s.split("&") | |
, t = [] | |
, q = {} | |
, i = 0 | |
; | |
for(i = 0; i < p.length; i++) { | |
t = p[i].split("="); |
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
this.parts = [ | |
{ | |
//head | |
points: [-1,2,-3,3,-3,6,-1,7,1,7,3,6,3,3,1,2,-1,2], | |
color: "#F00" | |
}, | |
{ | |
//body | |
points: [-3,2,3,2,3,-1,-3,-1,-3,2] | |
}, |
OlderNewer