Skip to content

Commit

Permalink
rgb_to_hex: fix typo and use bit operator instead of multiplication (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
gaoxinge authored Oct 10, 2021
1 parent 434607f commit 508053a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions python/taichi/misc/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,14 +828,14 @@ def rgb_to_hex(c):
"""Convert rgb color format to hex color format.
Args:
c (List[int]): The rbg representation of color.
c (List[int]): The rgb representation of color.
Returns:
The hex representation of color.
"""
to255 = lambda x: np.clip(np.int32(x * 255), 0, 255)
return 65536 * to255(c[0]) + 256 * to255(c[1]) + to255(c[2])
return (to255(c[0]) << 16) + (to255(c[1]) << 8) + to255(c[2])


def hex_to_rgb(color):
Expand Down

0 comments on commit 508053a

Please sign in to comment.