Advertisement
Guest User

Untitled

a guest
May 27th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. fn RGB(comptime hexspec : [7] const u8) error{NoHash}!Color
  2. {
  3. if(hexspec[0] != '#')
  4. return error.NoHash;
  5. return Color {
  6. .R = (try std.fmt.charToDigit(hexspec[1]) << 4) | try std.fmt.charToDigit(hexspec[2]),
  7. .G = (try std.fmt.charToDigit(hexspec[3]) << 4) | try std.fmt.charToDigit(hexspec[4]),
  8. .B = (try std.fmt.charToDigit(hexspec[5]) << 4) | try std.fmt.charToDigit(hexspec[6]),
  9. };
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement