Skip to content

Instantly share code, notes, and snippets.

View zz85's full-sized avatar

Joshua Koo zz85

View GitHub Profile
@zz85
zz85 / gist:1395215
Created November 26, 2011 07:13
Testing Creation of Simplex Noise Textures
function createNoiseTexture(width, height) {
var canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
var context = canvas.getContext('2d');
var image = context.createImageData( width, height );
var imageData = image.data;
@zz85
zz85 / werckmeister.js
Created November 29, 2011 20:19
midi number to frequency using Werckmeister I (III) temperament
// by https://github.com/zz85
// http://en.wikipedia.org/wiki/Werckmeister_temperament
// Werckmeister I (III): "correct temperament" based on 1/4 comma divisions
var werckmeister = [
1, // c
256/243, // c#
64 / 81 * Math.pow(2, 1/2), // d
32/27, // d#
@zz85
zz85 / OrbitControls.js
Created December 1, 2011 21:00
At times, don't you just need a simple camera which rotates around an object in Theee.js?
/*
* @author @blurspline https://github.com/zz85
* Similar to a turntable or a hovering camera?
*/
THREE.OrbitControls = function( camera, target, distance, height, time ) {
var rotationUnits = time * 1000;
var startTime;
this.start = function() {
@zz85
zz85 / LICENSE.txt
Created December 2, 2011 10:25 — forked from mirceapricop/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@zz85
zz85 / gist:1933802
Created February 28, 2012 17:21
Annotated Code Segment for Snow Scene
// Produces 50 snow particles every second
particleProducer = new SPARKS.SteadyCounter( 50 );
// Create the sparks.js Emitter
sparksEmitter = new SPARKS.Emitter( particleProducer );
// This defines that snow should emit from an plane like area
// instead of a point, giving the feel of snow falling from the sky
var zone = new SPARKS.ParallelogramZone(
new THREE.Vector3(-1400,800,-1000),
@zz85
zz85 / dabblet.css
Created March 2, 2012 12:47
Playing with the slider
body {
background-color: #333;
}
#rslider {
position:absolute;
left:50%;
width:100px;
height:18px;
border-radius:0 6px 6px 0;
@zz85
zz85 / fraction.js
Created April 12, 2012 18:55
Fractional / Rational Number Class for performing fractional calculations
// fraction / rational number class
// @author zz85
Vex.Flow.Fraction = function(numerator, denominator) {
this.set(numerator, denominator);
};
Vex.Flow.Fraction.prototype.constructor = Vex.Flow.Fraction;
Vex.Flow.Fraction.prototype.set = function(numerator, denominator) {
this.numerator = numerator === undefined ? 1 : numerator;
@zz85
zz85 / signed_distance_fields.js
Created April 29, 2012 12:44
Javascript Signed Distance Fields Generation
/*
* signed distance fields generation in javascript
* uses the 8SSEDT algorithm for linear-time processing
*
* done in conjustion with the signed distance fields text experiment
*
* references:
* http://www.lems.brown.edu/vision/people/leymarie/Refs/CompVision/DT/DTpaper.pdf
* http://www.codersnotes.com/notes/signed-distance-fields
* http://guides4it.com/Mobile/iphone-3d-programming---crisper-text-with-distance-fields-(part-1)---generating-distance-fields-with-python.aspx
@zz85
zz85 / SimpleEventExample.js
Created June 22, 2012 21:01
Example for SimpleEvent component from http://jsdo.it/zz85/75cq
// generates a "event channel"
var onFire = new SimpleEvent();
// adds an listener
onFire.add(function aListener(hello, world){
alert(hello + ' ' + world);
})
// notifies listeners
onFire.notify('Bye', 'Universe');
@zz85
zz85 / in_words.js
Last active December 14, 2015 08:29 — forked from bcamarda/in_words.js
Now support up to 999 trillion. (fixed a flooring error with ~~ and removed unneeded console.log)
// Converts a number to english words
// Based on https://gist.github.com/bcamarda/3001102
// Refactored and made some changes to support numbers to a hundred (US) trillion
// github.com/zz85
var inWords = (function() {
var numberHash = {
0:"", 1:"one", 2:"two", 3:"three", 4: "four", 5: "five", 6: "six", 7: "seven", 8: "eight", 9: "nine", 10: "ten",