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 arr = { | |
max: function(array) { | |
return Math.max.apply(null, array); | |
}, | |
min: function(array) { | |
return Math.min.apply(null, array); | |
}, | |
range: function(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
// grok'd from TinyColor.js | |
// https://bgrins.github.io/TinyColor/docs/tinycolor.html | |
// | |
function rgbToHsl(r, g, b) { | |
r = bound01(r, 255); | |
g = bound01(g, 255); |
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
// PSEUDO CODE | |
// via Herman Tulleken | |
// http://devmag.org.za/2012/07/29/how-to-choose-colours-procedurally-algorithms/ | |
maxJitter = 0.5; // any value between 0 and 1 | |
for(int i = 0; i < n; i++) | |
color[i] = gradient.GetColor( | |
(i + 0.5 + (2 * Random.NextFloat() - 1) * maxJitter) * intervalSize); |
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
// PSEUDO CODE | |
// via Herman Tulleken | |
// http://devmag.org.za/2012/07/29/how-to-choose-colours-procedurally-algorithms/ | |
offset = Random.NextFloat(); | |
for (int i = 0; i < n; i++) | |
color[i] = gradient.GetColor(offset + (0.618033988749895f * i) % 1); |
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
// grok'd from MIDI.js | |
// https://github.com/mudcube/MIDI.js | |
/* | |
---------------------------------------------------------- | |
MIDI.Synesthesia : 0.3.1 : 2012-01-06 | |
---------------------------------------------------------- | |
Peacock: “Instruments to perform color-music: Two centuries of technological experimentation,” Leonardo, 21 (1988), 397-406. | |
Gerstner: Karl Gerstner, The Forms of Color 1986 | |
Klein: Colour-Music: The art of light, London: Crosby Lockwood and Son, 1927. |
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
// grok'd from TinyColor | |
// https://bgrins.github.io/TinyColor/ | |
toString: function(format) { | |
var formatSet = !!format; | |
format = format || this._format; | |
var formattedString = false; | |
_applyModification: function(fn, args) { |
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
/* ---- | |
css custom properties to manipulate color | |
MIT - 2017 - Soft Punch | |
https://gist.github.com/softpunch/ | |
set initial "main" color via HSL values. | |
automatically calculate harmonies and variations of that color with pure css. | |
harmonies are determined solely by hue. |
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
:root { | |
--bpm: 120; | |
/* n4 = quarter note; t4 = quarter-note triplet; m4 = four measures */ | |
--n4: calc(60s / var(--bpm)); | |
--n1: calc(var(--n4) * 4); | |
--n2: calc(var(--n4) * 2); | |
--n8: calc(var(--n4) / 2); | |
--n16: calc(var(--n4) / 4); |
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
// | |
// useful WebMIDI variables and functions | |
// | |
// | |
// Chrome only; no iOS; does *not* incorporate shims | |
// | |
// Initialize WebMidi; create dropdown selector for output port |
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
// | |
// convenient variables and functions to schedule and control Web Audio; | |
// also useful for controlling other systems using Web Audio's utilities | |
// | |
window.AudioContext = window.AudioContext || window.webkitAudioContext; | |
var audioContext = new AudioContext(); | |
var baseFreq = 440; // A4, Midi Note #69 | |
var baseTempo = 120; // BPM | |
var audioOut = audioContext.destination; |
OlderNewer