Browse Source

Explicit integers (needed for python 3.5)

pull/280/head
Stéphane Jourdois 9 years ago
parent
commit
e4dd2747b3
  1. 6
      pygal/colors.py

6
pygal/colors.py

@ -126,19 +126,19 @@ def unparse_color(r, g, b, a, type):
if type == '#rgb': if type == '#rgb':
# Don't lose precision on rgb shortcut # Don't lose precision on rgb shortcut
if r % 17 == 0 and g % 17 == 0 and b % 17 == 0: if r % 17 == 0 and g % 17 == 0 and b % 17 == 0:
return '#%x%x%x' % (r / 17, g / 17, b / 17) return '#%x%x%x' % (r // 17, g // 17, b // 17)
type = '#rrggbb' type = '#rrggbb'
if type == '#rgba': if type == '#rgba':
if r % 17 == 0 and g % 17 == 0 and b % 17 == 0: if r % 17 == 0 and g % 17 == 0 and b % 17 == 0:
return '#%x%x%x%x' % (r / 17, g / 17, b / 17, a * 15) return '#%x%x%x%x' % (r // 17, g // 17, b // 17, int(a * 15))
type = '#rrggbbaa' type = '#rrggbbaa'
if type == '#rrggbb': if type == '#rrggbb':
return '#%02x%02x%02x' % (r, g, b) return '#%02x%02x%02x' % (r, g, b)
if type == '#rrggbbaa': if type == '#rrggbbaa':
return '#%02x%02x%02x%02x' % (r, g, b, a * 255) return '#%02x%02x%02x%02x' % (r, g, b, int(a * 255))
if type == 'rgb': if type == 'rgb':
return 'rgb(%d, %d, %d)' % (r, g, b) return 'rgb(%d, %d, %d)' % (r, g, b)

Loading…
Cancel
Save