27
27
28
28
29
29
def generate_codeart (
30
- template , color_lookup , top = 20 , sample = 15 , bgcolor = "white" , outfile = "codeart.html"
30
+ template ,
31
+ color_lookup ,
32
+ top = 20 ,
33
+ sample = 15 ,
34
+ bgcolor = "white" ,
35
+ outfile = "codeart.html" ,
36
+ quiet = False ,
31
37
):
32
38
"""generate codeart will take a template image and generate a web interface
33
39
for the same image (plotted with the images from the color lookup)
@@ -43,7 +49,9 @@ def generate_codeart(
43
49
for x in range (width ):
44
50
for y in range (height ):
45
51
46
- print ("x: %s y: %s" % (x , y ), end = "\r " )
52
+ if not quiet :
53
+ print ("x: %s y: %s" % (x , y ), end = "\r " )
54
+
47
55
# And take only every [sample]th pixel
48
56
if x % sample == 0 and y % sample == 0 :
49
57
cpixel = pixels [x , y ]
@@ -82,6 +90,7 @@ def generate_codeart_text(
82
90
width = 600 ,
83
91
height = 600 ,
84
92
coords = None ,
93
+ quiet = False ,
85
94
):
86
95
image = Image .new ("RGBA" , (width , height ))
87
96
draw = ImageDraw .Draw (image )
@@ -101,7 +110,8 @@ def generate_codeart_text(
101
110
102
111
for x in range (width ):
103
112
for y in range (height ):
104
- print ("x: %s y: %s" % (x , y ), end = "\r " )
113
+ if not quiet :
114
+ print ("x: %s y: %s" % (x , y ), end = "\r " )
105
115
cpixel = pixels [x , y ]
106
116
if sum (cpixel ) != 0 :
107
117
# We don't take the exact match, but rather some distance from the top
@@ -132,6 +142,7 @@ def generate_colored_image(
132
142
bcol = "B" ,
133
143
maxwidth = 600 ,
134
144
maxheight = 600 ,
145
+ quiet = False ,
135
146
):
136
147
"""This function will take an input image and color vectors,
137
148
and generates a version of the image mapped to the color space of
@@ -160,7 +171,8 @@ def generate_colored_image(
160
171
for x in range (width ):
161
172
for y in range (height ):
162
173
163
- print ("%s %s" % (x , y ), end = "\r " )
174
+ if not quiet :
175
+ print ("%s %s" % (x , y ), end = "\r " )
164
176
rgb_pixel = pixels [x , y ]
165
177
166
178
# Create a temporary copy to calculate the closest
0 commit comments