Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed bytetohex function in CPColor to make conversion to hex more ac…

…curate
  • Loading branch information...
commit c135d4a942172ebad3597d5a1f0a7354d1df6c6d 1 parent 0062caa
Sheena Pakanati authored
Showing with 4 additions and 4 deletions.
  1. +4 −4 AppKit/CPColor.j
View
8 AppKit/CPColor.j
@@ -734,11 +734,11 @@ function rgbToHex(r,g,b) {
return byteToHex(r) + byteToHex(g) + byteToHex(b);
}
-function byteToHex(n) {
+function byteToHex(n) {
if (!n || isNaN(n)) return "00";
- n = ROUND(MIN(255,MAX(0,256*n)));
- return hexCharacters.charAt((n - n % 16) / 16) +
- hexCharacters.charAt(n % 16);
+
+ var m = MIN(255, MAX(0, ROUND(255 * n)));
+ return (m > 16 ? "" : "0") + m.toString(16);
}
// Toll-Free bridge CPColor to CGColor.
Please sign in to comment.
Something went wrong with that request. Please try again.