Together with HellMood we won this year's (2016) JS1K competition and thought this might be a good opportunity to write about the development process and my motivation behind it. If you're already familiar with JS1K, feel free to skip the next two paragraphs.
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
/** | |
* A `Window.postMessage()` wrapper that aims to simplify the process of | |
* having two windows communicate with each other (see below for more details). | |
* | |
* @author Lara Sophie Schütt (@literallylara) | |
* @license MIT | |
* @version 1.0.5 | |
*/ | |
const SYNC_STATE_IDLE = 0b00000 |
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
export default { | |
"aliceblue": "#f0f8ff", | |
"antiquewhite": "#faebd7", | |
"aqua": "#00ffff", | |
"aquamarine": "#7fffd4", | |
"azure": "#f0ffff", | |
"beige": "#f5f5dc", | |
"bisque": "#ffe4c4", | |
"black": "#000000", | |
"blanchedalmond": "#ffebcd", |
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
/** | |
* Calculates an element's bounds to any given | |
* layer/skin (content, padding, border margin). | |
* | |
* @author Lara Sophie Schütt (@literallylara) | |
* @license MIT | |
* | |
* @param {HTMLElement} el | |
* @param {object} [options] |
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
/** | |
* A collection of utility functions for working with 2d geometry: | |
* Polygons, Segments, Lines & Points | |
* | |
* @author Lara Sophie Schütt (@literallylara) | |
* @license MIT | |
*/ | |
/** | |
* @typedef {[x:Number,y:Number]} Point2D |
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
/** | |
* Performs a recursive binary search upon the interval [min,max] | |
* where `getDirection()` determines the direction of the current value | |
* in relation to the reference value. | |
* | |
* Due to the properties of this algorithm, | |
* reaching the solution will always take less than `⌈log₂(max-min)⌉` steps. | |
* | |
* @author Lara Sophie Schütt (@literallylara) | |
* @license MIT |
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
/** | |
* Performs a fuzzy search on a list of values (haystack) | |
* with the provided query (needle) and sorts each match | |
* based on its scoring. | |
* | |
* TODO: adjust scoring logic | |
* | |
* @author Lara Sophie Schütt (@literallylara) | |
* @license MIT | |
* |
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
/** | |
* Promise wrapper for web workers. | |
* | |
* @author Lara Sophie Schütt (@literallylara) | |
* @license MIT | |
*/ | |
export default class PromiseWorker | |
{ | |
constructor(fn, ...args) |
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
/** | |
* MIDI parser for JavaScript | |
* Reference: midi.org/specifications-old/item/the-midi-1-0-specification | |
* | |
* @author Lara Sophie Schütt (@literallylara) | |
* @license MIT | |
*/ | |
const MIDI = {} |
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
<canvas id=c style="border:1px solid"><script> | |
A = new AudioContext | |
C = c.getContext`2d` | |
a = A.createAnalyser() | |
s = A.createScriptProcessor(a.fftSize=b=1024,t=0,1) | |
s.connect(a) | |
a.connect(A.destination) |
NewerOlder