-
Notifications
You must be signed in to change notification settings - Fork 0
/
color-pal
executable file
·93 lines (80 loc) · 3.41 KB
/
color-pal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env python3
""" color-pal - Display color palate generated by color-gen
Copyright (C) 2020 RueiKe
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
__author__ = 'RueiKe'
__copyright__ = 'Copyright (C) 2020 RueiKe'
__credits__ = []
__license__ = 'GNU General Public License'
__program_name__ = 'color-pal'
__version__ = 'v0.0.1'
__maintainer__ = 'RueiKe'
__status__ = 'Development'
__docformat__ = 'reStructuredText'
# pylint: disable=multiple-statements
# pylint: disable=line-too-long
import argparse
import sys
import math
import matplotlib.pyplot as plt
import colorsugen
def main():
"""
Main flow for color-pal.
"""
parser = argparse.ArgumentParser()
parser.add_argument('--about', help='README',
action='store_true', default=False)
parser.add_argument('--num_colors', help='number of colors to generate',
type=int, default=150)
parser.add_argument('--color_space', help='color space for source: rgb, hsv or yiq',
type=str, default='hsv')
parser.add_argument('--normal', help='Normalize Luminosity',
action='store_true', default=False)
parser.add_argument('-d', '--debug', help='Debug output',
action='store_true', default=False)
args = parser.parse_args()
# About me
if args.about:
print(__doc__)
print('Author: ', __author__)
print('Copyright: ', __copyright__)
print('Credits: ', *['\n {}'.format(item) for item in __credits__])
print('License: ', __license__)
print('Version: ', __version__)
print('Maintainer: ', __maintainer__)
print('Status: ', __status__)
sys.exit(0)
colors = colorsugen.colorsugen.ColorUgen()
color_list = list(colors.unique_colors(args.num_colors, color_space=args.color_space,
normalization=args.normal, debug=args.debug))
colors.print()
print('target colors: {}. generated colors: {}'.format(args.num_colors, len(color_list)))
fig_size = 10
fig = plt.figure(figsize=(fig_size, fig_size))
ax = fig.add_subplot(1, 1, 1)
ax.set_facecolor('#d0dbd5')
fig.patch.set_facecolor('#eeeeee')
plt.subplots_adjust(left=0.01, right=0.99, top=0.99, bottom=0.01)
c_len = len(list(color_list))
for i, f_col in enumerate(colors.unique_colors(args.num_colors, color_space=args.color_space,
normalization=args.normal, debug=args.debug)):
a_deg = 90.0*float(i)/float(c_len)
y1 = abs(math.sin(a_deg * math.pi / 180.0))
x1 = abs(math.cos(a_deg * math.pi / 180.0))
ref_y = [0.0, y1]
ref_x = [0.0, x1]
ax.plot(ref_x, ref_y, label=f_col, color=f_col, linewidth=2)
plt.show()
if __name__ == '__main__':
main()