Skip to content

Instantly share code, notes, and snippets.

View mudcube's full-sized avatar

Miko Meow mudcube

View GitHub Profile
@mudcube
mudcube / W3Contrast.scss
Created October 22, 2016 02:59
Determine whether the difference between two colors meets the W3 standards for contrast.
@function isW3Contrast($rgb1, $rgb2) {
$rgb1: red($rgb1), green($rgb1), blue($rgb1);
$rgb2: red($rgb2), green($rgb2), blue($rgb2);
$brightness: W3Brightness($rgb1, $rgb2) <= 125;
$difference: W3Difference($rgb1, $rgb2) <= 500;
@if ($brightness and $difference) {
@return false;
} @else {
@return true;
}
@mudcube
mudcube / AudioBufferTimer
Created August 8, 2015 08:41
Compare window.setTimeout() vs. using Audio BufferSource shim
var timeout = .50;
///
var channels = 1;
var audioCtx = new AudioContext;
var sampleRate = audioCtx.sampleRate;
var audioDuration = 0.01;
var audioBufferSize = sampleRate * audioDuration;
var audioBuffer = audioCtx.createBuffer(channels, audioBufferSize, sampleRate);
var date = Date.now();
var source = audioCtx.createBufferSource();