summaryrefslogtreecommitdiffstats
path: root/share/extensions/color_darker.py
blob: 6c57d78c962082d0d267412b2c094ca4c4841410 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env python
"""Darken colours of selected objects"""

import inkex

class Darker(inkex.ColorExtension):
    """Make the colours darker"""
    def modify_color(self, name, color):
        factor = 0.9
        if color.space == 'hsl':
            color.lightness = int(round(max(color.lightness * factor, 0)))
        else:
            color.red = int(round(max(color.red * factor, 0)))
            color.green = int(round(max(color.green * factor, 0)))
            color.blue = int(round(max(color.blue * factor, 0)))
        return color

if __name__ == '__main__':
    Darker().run()