Exemplo n.º 1
0
 def tikz_command(cls, matching, with_env=False, colour_factors=False):
   if colour_factors and cls.direct_norm(matching) > 1:
     fst, snd = cls.factorise(matching)
     fst_size, snd_size = len(fst)*2, len(snd)*2
     shifted_snd = ((src+fst_size+1, tar+fst_size+1) for (src,tar) in snd)
     command = wrap_tikz_command('factoredArches', fst_size, to_tikz_pair_loop(fst), snd_size, to_tikz_pair_loop(shifted_snd))
   else:
     command = wrap_tikz_command('arches', 2*len(matching), to_tikz_pair_loop(matching))
   return wrap_tikz_env('tikzpicture', command) if with_env else command
Exemplo n.º 2
0
 def tikz_command(cls, triangulation, with_env=False, colour_factors=False):
     num_vertices = cls.direct_norm(triangulation) + 1
     if colour_factors and triangulation != cls.generator():
         split = cls.direct_norm(cls.factorise(triangulation)[0]) + 1
         red_chords_tex = to_tikz_pair_loop(chord for chord in triangulation
                                            if max(chord) <= split)
         blue_chords_tex = to_tikz_pair_loop(chord
                                             for chord in triangulation
                                             if split <= min(chord))
         command = wrap_tikz_command('factoredTriangulation', num_vertices,
                                     split, red_chords_tex, blue_chords_tex)
     else:
         chords_tex_format = to_tikz_pair_loop(
             chord for chord in triangulation
             if (min(chord), max(chord)) != (1, num_vertices))
         command = wrap_tikz_command('triangulation', num_vertices,
                                     chords_tex_format)
     if with_env:
         return wrap_tikz_env('tikzpicture', command)
     else:
         return command
Exemplo n.º 3
0
 def tikz_full(cls,
               triangulation,
               radius='2',
               vertex_radius='3pt',
               label_offset='.5'):
     with open(TEX_TEMPLATES_PATH + '/triangulation-full.tex') as template:
         num_vertices = cls.direct_norm(triangulation)
         chords_tex_format = to_tikz_pair_loop(
             chord for chord in triangulation
             if (min(chord), max(chord)) != (1, num_vertices))
         output = (template.read().replace(
             'SUB_RADIUS', str(radius)).replace(
                 'SUB_VERTEX_RADIUS', str(vertex_radius)).replace(
                     'SUB_LABEL_OFFSET',
                     str(label_offset)).replace('SUB_NUM_VERTICES',
                                                str(num_vertices)).replace(
                                                    'SUB_CHORDS',
                                                    chords_tex_format))
     return output
Exemplo n.º 4
0
  def tikz_command(cls, dyck_path, with_env=False, colour_factors=False):
    if colour_factors:
      command =  cls.coloured_factors_tikz_command(dyck_path)
    else:
      x,y = (0,0)

      step_dir = {'E': (1,0), 'N': (0,1)}

      path = []

      for step in dyck_path:
        dx,dy = step_dir[step]
        x += dx
        y += dy
        path.append((x,y))

      command = wrap_tikz_command('dyckPath', to_tikz_pair_loop(path))

    return wrap_tikz_env('tikzpicture', command) if with_env else command
Exemplo n.º 5
0
 def tikz_command(cls, chords, radius=2, with_env=False):
   command = wrap_tikz_command('nonCrossingChords', radius, 2*len(chords), to_tikz_pair_loop(chords))
   return wrap_tikz_env('tikzpicture', command) if with_env else command