Skip to content

Instantly share code, notes, and snippets.

@shawn42
Created November 23, 2009 19:12
Show Gist options
  • Save shawn42/241299 to your computer and use it in GitHub Desktop.
Save shawn42/241299 to your computer and use it in GitHub Desktop.
class Color
def self.from_css(hex)
if hex < 0x1000000
hex = hex >> 8
hex = hex & 0x000000FF
end
r = hex >> 24
g = (hex & 0x00FF0000) >> 16
b = (hex & 0x0000FF00) >> 8
a = (hex & 0x000000FF)
[r,g,b,a]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment