def create_seed(seed, name): global seed_png_path seed_svg_path = name + '_seed.svg' logger.debug('Seed svg path: ' + seed_svg_path) seed_png_path = seed_svg_path.strip('.svg') + '.png' logger.debug('Seed png path: ' + seed_png_path) try: svg = SVG({'width': 5700, 'height': 5700}) svg.addChildElement('rect', { 'x': 0, 'y': 0, 'fill': 'none', 'stroke': 'black', 'stroke-width': 0.5 }) seed_words = seed.split(' ') seed_lines = [] for x in range(0, 12, 2): word_num = x + 1 line = seed_words[x] + ' ' + seed_words[x + 1] seed_lines.append(line) position = 750 for x in range(0, 6): svg.addChildElement( 'text', { 'x': 2850, 'y': position, 'font-family': 'Ubuntu', 'font-size': 600, 'text-anchor': 'middle' }, seed_lines[x]) position += 900 svg.write(seed_svg_path) with open(seed_svg_path, 'rb') as svg_file: svg2png(file_obj=svg_file, write_to=seed_png_path, parent_width=1024, parent_height=1024) except Exception as e: logger.exception('Exception while creating seed file.') logger.exception(e) raise
def create_addr(addr): addr_file_path = 'test_addr.svg' logger.debug('Address file path: ' + addr_file_path) png_file_path = 'test_addr.png' logger.debug('PNG file path (original): ' + png_file_path) png_file_rotated_path = 'test_addr_rotated.png' logger.debug('PNG file path (rotated): ' + png_file_rotated_path) try: svg = SVG({'width': 700, 'height': 32}) svg.addChildElement( 'text', { 'x': 0, 'y': 13, 'font-family': 'Ubuntu', 'font-size': 30, 'text-anchor': 'start', 'alignment-baseline': 'central' }, addr) svg.write(addr_file_path) svg2png(file_obj=open(addr_file_path, 'rb'), write_to=png_file_path) img_orig = Image.open(png_file_path) img_rotated = img_orig.rotate(90, expand=True) img_rotated.save(png_file_rotated_path) except Exception as e: logger.exception('Exception while creating address file.') logger.exception(e) raise
def create_addr(addr, name): addr_file_path = name + '_addr.svg' logger.debug('Address SVG file path: ' + addr_file_path) png_file_path = name + '_addr.png' logger.debug('Address PNG file path: ' + png_file_path) try: svg = SVG({'width': 700, 'height': 32}) svg.addChildElement( 'text', { 'x': 0, 'y': 13, 'font-family': 'Ubuntu', 'font-size': 30, 'text-anchor': 'start', 'alignment-baseline': 'central' }, addr) svg.write(addr_file_path) svg2png(file_obj=open(addr_file_path, 'rb'), write_to=png_file_path) except Exception as e: logger.exception('Exception while creating address file.') logger.exception(e) raise
def create_seed(seed, name): seed_file_path = name + '_seed.svg' logger.debug('Seed file path: ' + seed_file_path) try: svg = SVG({'width': 5700, 'height': 5700}) svg.addChildElement('rect', { 'x': 0, 'y': 0, 'fill': 'none', 'stroke': 'black', 'stroke-width': 0.5 }) seed_words = seed.split(' ') seed_lines = [] for x in range(0, 12, 2): word_num = x + 1 line = seed_words[x] + ' ' + seed_words[x + 1] seed_lines.append(line) position = 750 for x in range(0, 6): svg.addChildElement( 'text', { 'x': 2850, 'y': position, 'font-family': 'Ubuntu', 'font-size': 600, 'text-anchor': 'middle' }, seed_lines[x]) position += 900 svg.write(seed_file_path) except Exception as e: logger.exception('Exception while creating seed file.') logger.exception(e) raise
from drawSVG.drawSVG import SVG import logging import sys logging.basicConfig(level=logging.DEBUG) logger = logging.getLogger(__name__) svg_file = 'test_justify.svg' svg = SVG() svg.addChildElement('rect', {'x':0, 'y':0, 'width':58, 'height':58, 'fill':'none', 'stroke':'black', 'stroke-width':0.5}) seed = 'leave mistake radar early head expand uncover stairs merge hazard swear dutch' seed_words = seed.split(' ') logger.debug(seed_words) position = 6.5 position_start = position for x in range(0, 6): svg.addChildElement('text', {'x':position_start, 'y':position, 'font-family':'Ubuntu', 'font-size':6, 'text-anchor':'start',
from drawSVG.drawSVG import SVG import logging import sys logging.basicConfig(level=logging.DEBUG) logger = logging.getLogger(__name__) svg_file = 'test.svg' svg = SVG() svg.addChildElement('rect', {'x':0, 'y':0, 'width':58, 'height':58, 'fill':'none', 'stroke':'black', 'stroke-width':0.5}) seed = 'leave mistake radar early head expand uncover stairs merge hazard swear dutch' seed_words = seed.split(' ') logger.debug(seed_words) seed_lines = [] for x in range(0, 12, 2): word_num = x + 1 #line = str(word_num) + ') ' + seed_words[x] + ' ' + str(word_num + 1) + ') ' + seed_words[x + 1] line = seed_words[x] + ' ' + seed_words[x + 1] seed_lines.append(line) logger.debug(seed_lines)