Skip to content

Instantly share code, notes, and snippets.

@remitbri
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save remitbri/c7ef255cc99a14b0ba6a to your computer and use it in GitHub Desktop.
Save remitbri/c7ef255cc99a14b0ba6a to your computer and use it in GitHub Desktop.
table alpha to hexa

alpha to hexa

Useful for colour values, the 'AA' in #RRGGBBAA

hexa = Math.round(i*255).toString(16)

for (i=0; i<=1; i+=0.05) {
console.log(i, Math.round(i*255).toString(16))
}
  • 0.05 <=> 0d
  • 0.10 <=> 1a
  • 0.15 <=> 26
  • 0.20 <=> 33
  • 0.25 <=> 40
  • 0.30 <=> 4d
  • 0.35 <=> 59
  • 0.40 <=> 66
  • 0.45 <=> 73
  • 0.50 <=> 7f
  • 0.55 <=> 8c
  • 0.60 <=> 99
  • 0.65 <=> a6
  • 0.70 <=> b3
  • 0.75 <=> bf
  • 0.80 <=> cc
  • 0.85 <=> d9
  • 0.90 <=> e6
  • 0.95 <=> f2
  • 1.00 <=> ff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment