| 
														 | 
														 | 
														 | 
														 | 
														 | 
													
													
												
													
														 | 
														 | 
																* Add grid lines and edge labels to image. (DONE) | 
														 | 
														 | 
																* Add grid lines and edge labels to image. (DONE) | 
													
													
												
													
														 | 
														 | 
																* Add legend to image, based on the `symbols` dictionary. (DONE) | 
														 | 
														 | 
																* Add legend to image, based on the `symbols` dictionary. (DONE) | 
													
													
												
													
														 | 
														 | 
																* Correspond hex colors to floss colors, where possible. | 
														 | 
														 | 
																* Correspond hex colors to floss colors, where possible. | 
													
													
												
													
														 | 
														 | 
																* (Maybe) add stitch count for each color. | 
														 | 
														 | 
														 | 
													
													
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
																* (Maybe) add stitch count for each color. (DONE) | 
													
													
												
													
														 | 
														 | 
																* (Maybe) add GUI. | 
														 | 
														 | 
																* (Maybe) add GUI. | 
													
													
												
													
														 | 
														 | 
														""" | 
														 | 
														 | 
														""" | 
													
													
												
													
														 | 
														 | 
														
  | 
														 | 
														 | 
														
  | 
													
													
												
											
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
														 | 
													
													
												
													
														 | 
														 | 
														
  | 
														 | 
														 | 
														
  | 
													
													
												
													
														 | 
														 | 
															symbols = defaultdict(str) | 
														 | 
														 | 
															symbols = defaultdict(str) | 
													
													
												
													
														 | 
														 | 
															symbols["transparent"] = " " | 
														 | 
														 | 
															symbols["transparent"] = " " | 
													
													
												
													
														 | 
														 | 
															characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | 
														 | 
														 | 
														 | 
													
													
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
															characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" | 
													
													
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
															symbol_counts = defaultdict(int) | 
													
													
												
													
														 | 
														 | 
														#	l = 0 | 
														 | 
														 | 
														#	l = 0 | 
													
													
												
													
														 | 
														 | 
															lines = [] | 
														 | 
														 | 
															lines = [] | 
													
													
												
													
														 | 
														 | 
															for i in range(h): | 
														 | 
														 | 
															for i in range(h): | 
													
													
												
											
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
														 | 
													
													
												
													
														 | 
														 | 
																		if cs not in symbols.keys(): | 
														 | 
														 | 
																		if cs not in symbols.keys(): | 
													
													
												
													
														 | 
														 | 
																			symbols[cs] = characters[0] | 
														 | 
														 | 
																			symbols[cs] = characters[0] | 
													
													
												
													
														 | 
														 | 
																			characters = characters[1:] | 
														 | 
														 | 
																			characters = characters[1:] | 
													
													
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
																		symbol_counts[cs] += 1 | 
													
													
												
													
														 | 
														 | 
																		d = symbols[cs] | 
														 | 
														 | 
																		d = symbols[cs] | 
													
													
												
													
														 | 
														 | 
																	line.append(d) | 
														 | 
														 | 
																	line.append(d) | 
													
													
												
													
														 | 
														 | 
														#			print(d, end="") | 
														 | 
														 | 
														#			print(d, end="") | 
													
													
												
											
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
														 | 
													
													
												
													
														 | 
														 | 
															 | 
														 | 
														 | 
															 | 
													
													
												
													
														 | 
														 | 
														#	print("\nLEGEND") | 
														 | 
														 | 
														#	print("\nLEGEND") | 
													
													
												
													
														 | 
														 | 
															legend = [] | 
														 | 
														 | 
															legend = [] | 
													
													
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
															keys = 0 | 
													
													
												
													
														 | 
														 | 
															for k,v in symbols.items(): | 
														 | 
														 | 
															for k,v in symbols.items(): | 
													
													
												
													
														 | 
														 | 
																if v != " ": | 
														 | 
														 | 
																if v != " ": | 
													
													
												
													
														 | 
														 | 
																	legend.append("{}: #{}".format(v,k)) | 
														 | 
														 | 
														 | 
													
													
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
																	keys += 1 | 
													
													
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
																	legend.append("{}: #{} ({}ct)".format(v, k, symbol_counts[k])) | 
													
													
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
															print("{} keys".format(keys)) | 
													
													
												
													
														 | 
														 | 
														#	print("\n".join(legend)) | 
														 | 
														 | 
														#	print("\n".join(legend)) | 
													
													
												
													
														 | 
														 | 
														
  | 
														 | 
														 | 
														
  | 
													
													
												
													
														 | 
														 | 
															owid, ohgt = (w*10)+10, (h*10)+30 | 
														 | 
														 | 
														 | 
													
													
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
															owid, ohgt = (w*10)+10, (h*10)+10+(15*(int(keys/3)+1)) | 
													
													
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
															print((owid, ohgt)) | 
													
													
												
													
														 | 
														 | 
															oimg = Image.new("RGB", (owid, ohgt), "white") | 
														 | 
														 | 
															oimg = Image.new("RGB", (owid, ohgt), "white") | 
													
													
												
													
														 | 
														 | 
															draw = ImageDraw.Draw(oimg) | 
														 | 
														 | 
															draw = ImageDraw.Draw(oimg) | 
													
													
												
													
														 | 
														 | 
															for ww in range(1, w+1): | 
														 | 
														 | 
															for ww in range(1, w+1): | 
													
													
												
													
														 | 
														 | 
																posx = ww * 10 | 
														 | 
														 | 
																posx = ww * 10 | 
													
													
												
													
														 | 
														 | 
																linecolor = 0 if posx % 100 == 0 else (128,128,128) | 
														 | 
														 | 
																linecolor = 0 if posx % 100 == 0 else (128,128,128) | 
													
													
												
													
														 | 
														 | 
																linewidth = 2 if posx % 100 == 0 else 1 | 
														 | 
														 | 
																linewidth = 2 if posx % 100 == 0 else 1 | 
													
													
												
													
														 | 
														 | 
																draw.line((posx, 10, posx, ohgt-20), fill=linecolor, width=linewidth) | 
														 | 
														 | 
														 | 
													
													
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
																draw.line((posx, 10, posx, (h*10)), fill=linecolor, width=linewidth) | 
													
													
												
													
														 | 
														 | 
															for hh in range(1, h+1): | 
														 | 
														 | 
															for hh in range(1, h+1): | 
													
													
												
													
														 | 
														 | 
																posy = hh * 10 | 
														 | 
														 | 
																posy = hh * 10 | 
													
													
												
													
														 | 
														 | 
																linecolor = 0 if posy % 100 == 0 else (128,128,128) | 
														 | 
														 | 
																linecolor = 0 if posy % 100 == 0 else (128,128,128) | 
													
													
												
											
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
														 | 
													
													
												
													
														 | 
														 | 
																for char in range(len(line)): | 
														 | 
														 | 
																for char in range(len(line)): | 
													
													
												
													
														 | 
														 | 
																	draw.text((char_positions[char], char_positions[0]-4+adjust), line[char], fill=0) | 
														 | 
														 | 
																	draw.text((char_positions[char], char_positions[0]-4+adjust), line[char], fill=0) | 
													
													
												
													
														 | 
														 | 
																adjust += 10 | 
														 | 
														 | 
																adjust += 10 | 
													
													
												
													
														 | 
														 | 
															draw.text((20, ohgt-10), "    ".join(legend), fill=0) | 
														 | 
														 | 
														 | 
													
													
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
															legend_out = "" | 
													
													
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
															item_ct = 0 | 
													
													
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
															for item in legend: | 
													
													
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
																item_ct += 1 | 
													
													
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
																legend_out += item | 
													
													
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
																if item_ct % 3 == 0: | 
													
													
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
																	legend_out += "\n" | 
													
													
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
																else: | 
													
													
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
																	legend_out += "    " | 
													
													
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
															draw.text((20, (h*10)+10), legend_out, fill=0) | 
													
													
												
													
														 | 
														 | 
															oimg.save(oimg_name) | 
														 | 
														 | 
															oimg.save(oimg_name) | 
													
													
												
													
														 | 
														 | 
															print("Saved {}".format(oimg_name)) | 
														 | 
														 | 
															print("Saved {}".format(oimg_name)) | 
													
													
												
													
														 | 
														 | 
														
  | 
														 | 
														 | 
														
  |