Skip to content

Instantly share code, notes, and snippets.

@scottkellum
Created December 9, 2013 13:23
Show Gist options
  • Save scottkellum/7872171 to your computer and use it in GitHub Desktop.
Save scottkellum/7872171 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.1)
// Compass (v0.13.alpha.10)
// ----
@function baseten-hex($number) {
$hex-values: 0 1 2 3 4 5 6 7 8 9 a b c d e f;
@if round($number) != $number {
@warn "base10-hex() needs a integer";
}
@if $number > 255 {
@warn "baseten-hex() numbers need to be less than or equal to 255"
}
@if $number < 0 {
@warn "baseten-hex() numbers need to be more than or equal to 0"
}
@return #{nth($hex-values, floor($number / 16) + 1)}#{nth($hex-values,((($number / 16) - floor($number / 16)) * 16) + 1)};
}
@function iehex($color) {
$hex: opacify($color, 1);
$opacity: opacity($color);
$alpha: baseten-hex(round($opacity * 255));
$red: baseten-hex(red($hex));
$green: baseten-hex(green($hex));
$blue: baseten-hex(blue($hex));
@return unquote("##{$alpha}#{$red}#{$green}#{$blue}");
}
$color: rgba(123,123,123,.8);
foo {
bar: iehex($color);
}
foo {
bar: #cc7b7b7b;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment