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
/** | |
* Last updated to work with version 0.60 | |
* Library Repo: https://github.com/oframe/ogl | |
* Definitions extracted from https://github.com/nshen/ogl-typescript/ | |
* | |
*/ | |
declare module 'ogl/src/math/functions/ColorFunc' { | |
const NAMES: { | |
black: string; |
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
//Some functions where taken from Jistin Windle's sketch.js at https://github.com/soulwire/sketch.js | |
// Modulus with support for negative integers | |
Mod = function(current, limit) { | |
return ( (current % limit) + limit ) % limit; | |
}; | |
function isArray( object ) { | |
return Object.prototype.toString.call( object ) == '[object Array]'; |
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
// Micro utility to execute a function when all globals are present | |
var waitForGlobal = function(params) { | |
var pathExists = function( arr, obj ) { | |
var target = obj[ arr.shift() ]; | |
var exists = target !== undefined; | |
return arr.length == 0 ? exists : exists && pathExists(arr, target); | |
}; | |
var predicate = function() { | |
return params.globals.every(function(path) { |
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
module.exports = { | |
paths: { | |
watched: ['resources'] | |
}, | |
files: { | |
javascripts: { joinTo: { | |
'scripts/app.js': /^resources/, | |
'scripts/vendor.js': /^node_modules/ | |
} }, | |
stylesheets: { joinTo: { |
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 generateID() { | |
return ("000000" + (Math.random()*Math.pow(36,6) << 0).toString(36)).slice(-6)); | |
} | |
function generateIDFromStr() { | |
var seed = str.split("").reduce(function(a,b){a=((a<<5)-a)+b.charCodeAt(0);return a&a},0); | |
return ( "000000" + ( seed << 0 ).toString( 36 ) ).slice( -6 ); | |
} |
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 getRandomNumber(min, max) { | |
return Math.random() * (max - min) + min; | |
} | |
function getRandomColor() { | |
// http://stackoverflow.com/questions/1484506/random-color-generator-in-javascript | |
return "#"+((1<<24)*Math.random()|0).toString(16); | |
} |
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
private traverse(obj: any, interatee: Funcion) { | |
for (var i in obj) { | |
func.apply(this, [i, obj[i]]); | |
if (obj[i] !== null && typeof (obj[i]) == "object") { | |
this.traverse(obj[i], iteratee); | |
} | |
} | |
} |
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 getSizeToCover(width, height, maxWidth, maxHeight) { | |
var ratio = Math.max(maxWidth / width, maxHeight / height); | |
return { | |
width: width * ratio, | |
height: height * ratio | |
}; | |
} | |
function getSizeToContain(width, height, maxWidth, maxHeight) { | |
var ratio = Math.min(maxWidth / width, maxHeight / height); |
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
// @input: discrete counter | |
// @min: lower value | |
// @max: maximum value | |
function oscillate(input, min, max) { | |
var range = max - min; | |
return min + Math.abs(((input + range) % (range * 2)) - range); | |
} |
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 isOdd(number) { | |
return !!(number & 1); | |
} | |
// Floor Float aka cast to Int | |
var n = 1.9 | 0; // -> 1 |
NewerOlder