This file contains hidden or 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
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
# | |
# Created by Nat Noordanus on 2012-10-20. | |
# | |
# requires a text file of digits of pi http://stuff.mit.edu/afs/sipb/contrib/pi/pi-billion.txt | |
def find_in_pi string, pi_file_path | |
# convert string to base 10 ascii |
This file contains hidden or 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
# Construct a chained array of callbacks that "thread" a sequence of async functions in the smallest possible code. | |
# tldr; call the next async function in fn, "wait" for its callback to store the result and call the next async callback in cb | |
# each async function | |
# accepts 1 callback argument | |
# passes 1 arg of result data to the callback | |
# construct the callback | |
# when callback in cb evaluates, replaces itself in cb array with the result | |
# calls the next callback in cb | |
# after last callback in cb, return joined results stored in cb |
This file contains hidden or 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
Jax.getGlobal().ApplicationHelper = Jax.Helper.create | |
patch_world: -> | |
Jax.World.prototype.find_region_centers = () -> | |
context = this.context | |
w = context.canvas.width | |
h = context.canvas.height | |
f = 4 | |
wf = w*f | |
data = new Uint8Array(w*h*4) | |
pickBuffer = new Jax.Framebuffer |
This file contains hidden or 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
Jax.getGlobal().ApplicationHelper = Jax.Helper.create | |
patch_world: -> | |
Jax.World.prototype.pick_all_visible = () -> | |
context = this.context | |
w = context.canvas.width | |
h = context.canvas.height | |
data = new Uint8Array(w*h*4) | |
data.w = w | |
data.h = h | |
data.f = f = 4 |
This file contains hidden or 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
Jax.Controller.create "Mybsp", ApplicationController, | |
index: -> | |
sphere = new Jax.Mesh.Sphere | |
this.ball1 = new Jax.Model({ mesh:sphere }) | |
this.ball2 = new Jax.Model({ mesh:sphere, position:[0,5,0] }) | |
this.ball1.bsp = new BSP | |
this.ball2.bsp = new BSP |
This file contains hidden or 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
Jax.getGlobal().AsyncHelper = Jax.Helper.create | |
load_from_idb: (idb_name, os_name, key, onsuccess, onfailure) -> | |
indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB | |
IDBTransaction = IDBTransaction || window.webkitIDBTransaction | |
IDBKeyRange = IDBKeyRange || window.webkitIDBKeyRange | |
idb_request = indexedDB.open @indexedDB | |
idb_request.onsuccess = (e) => | |
idb = e.target.result | |
if idb.objectStoreNames.contains @objectStore |
This file contains hidden or 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
Jax.getGlobal()['LoadedMesh'] = Jax.Model.create | |
after_initialize: -> | |
model_data = null | |
@mesh = new Jax.Mesh | |
init: (vertices, colors, texCoords, normals, indices) -> | |
if model_data | |
vertices.push datum for datum in model_data["vertices"][0]["values"] | |
normals.push datum for datum in model_data["vertices"][1]["values"] | |
indices.push datum for datum in model_data["connectivity"][0]["indices"] | |
update: ((updated_mesh) => model_data = updated_mesh; @mesh.rebuild()) |
NewerOlder