Created
May 8, 2012 11:35
-
-
Save micheljansen/2634387 to your computer and use it in GitHub Desktop.
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
function encodeRGB(r,g,b) { | |
return encode_triplet(0,r,g)+encode_triplet(b,255,255); | |
} | |
function encode_triplet(e1, e2, e3) { | |
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; | |
enc1 = e1 >> 2; | |
enc2 = ((e1 & 3) << 4) | (e2 >> 4); | |
enc3 = ((e2 & 15) << 2) | (e3 >> 6); | |
enc4 = e3 & 63; | |
return keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4); | |
} |
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
.gifrgb(@r,@g,@b) { | |
@k: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; | |
@g1: "url(data:image/gif;base64,R0lGODlhAQABAPAAA"; | |
@g2: "///yH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==)"; | |
@b64img: ~`function(r,g,b){var k=@{k};return @{g1}+k.charAt(((0&3)<<4)|(r>>4))+k.charAt(((r&15)<<2)|(g>>6))+k.charAt(g&63)+k.charAt(b>>2)+k.charAt(((b&3)<<4)|(255>>4))+@{g2}}(@{r},@{g},@{b})`; | |
background-image: @b64img; | |
} | |
div.progressitem { | |
.gifrgb(255,255,0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment