def rev_path(x1, y1, x2, y2, txt=None): elements = [] # x1, y1 = r1.get_cx(), r1.get_cy() # x2, y2 = r2.get_cx(), r2.get_cy(), l = line(x1, y1, x2, y2) elements.append(l) style = 'stroke-width:{0};stroke:{1}'.format(16, ALUM_6) l.set_style(style) if txt: x, y = middle(x1, y1, x2, y2) style2 = StyleBuilder() #style2.setFontFamily('envy code r') style2.setFontFamily('arial') style2.setFontWeight('bold') style2.setFilling(ALUM_1) # shift text left and up by a bit # whole alphabet in this font is 167 px width per_char = 167. / 26 t = text(txt, -len(txt) / 2 * per_char, 4) t.set_style(style2.getStyle()) #import pdb; pdb.set_trace() group = rotate([t], slope_angle(x1, y1, x2, y2)) group = translate([group], x, y) elements.append(group) return elements
def rev_path(x1,y1, x2,y2, txt=None): elements = [] # x1, y1 = r1.get_cx(), r1.get_cy() # x2, y2 = r2.get_cx(), r2.get_cy(), l = line(x1, y1, x2, y2) elements.append(l) style = 'stroke-width:{0};stroke:{1}'.format(16, ALUM_6) l.set_style(style) if txt: x, y = middle(x1, y1, x2, y2) style2 = StyleBuilder() #style2.setFontFamily('envy code r') style2.setFontFamily('arial') style2.setFontWeight('bold') style2.setFilling(ALUM_1) # shift text left and up by a bit # whole alphabet in this font is 167 px width per_char = 167./26 t = text(txt, -len(txt)/2*per_char, 4) t.set_style(style2.getStyle()) #import pdb; pdb.set_trace() group = rotate([t], slope_angle(x1, y1, x2, y2)) group = translate([group], x, y) elements.append(group) return elements
def words(txt, family='arial', weight='bold', color=ALUM_1): style2 = StyleBuilder() #style2.setFontFamily('envy code r') style2.setFontFamily('arial') style2.setFontWeight('bold') style2.setFilling(ALUM_1) t = text(txt, 0, 0) t.set_style(style2.getStyle()) return t
def command(num_txt, cmd, explanation, color): x = 0 y = 0 elems = [scale(num(num_txt, color), 2)] cmd_txt = text(cmd, x + 40, y + 12) s = StyleBuilder() s.setFontWeight('bold') s.setFontFamily('Bitstream Vera Sans Mono') cmd_txt.set_style(s.getStyle()) elems.append(cmd_txt) exp_txt = text(explanation, x + 45, y + 27) s = StyleBuilder() #s.setFontWeight('bold') s.setFontFamily('Bitstream Vera Serif') s.setFontSize('10px') exp_txt.set_style(s.getStyle()) elems.append(exp_txt) return elems
def command(num_txt, cmd, explanation, color): x = 0 y = 0 elems = [scale(num(num_txt, color), 2)] cmd_txt = text(cmd, x+40, y+12) s = StyleBuilder() s.setFontWeight('bold') s.setFontFamily('Bitstream Vera Sans Mono') cmd_txt.set_style(s.getStyle()) elems.append(cmd_txt) exp_txt = text(explanation, x+45, y+27) s = StyleBuilder() #s.setFontWeight('bold') s.setFontFamily('Bitstream Vera Serif') s.setFontSize('10px') exp_txt.set_style(s.getStyle()) elems.append(exp_txt) return elems
def num(txt, color): txt = str(txt) elems = [] r = rect(0, 0, 16, 16) s = StyleBuilder() s.setFilling(color) r.set_style(s.getStyle()) elems.append(r) if txt: style2 = StyleBuilder() #style2.setFontFamily('envy code r') style2.setFontFamily('arial') style2.setFontWeight('bold') style2.setFilling(ALUM_1) # shift text left and up by a bit if len(txt) == 1: x = 5 elif len(txt) == 2: x = 1.5 t = text(txt, x, 12.5) t.set_style(style2.getStyle()) elems.append(t) return elems