def connect_diagonally(e_from, e_to): s_fmt = fmt.arrow_heads("end") from_center_cs = stz.center_coords(e_from) to_center_cs = stz.center_coords(e_to) return stz.line_segment_between_circles(from_center_cs, node_radius, -90.0, to_center_cs, node_radius, 180.0 - delta_angle, s_fmt)
def connect(e_from, e_to): cs_from = stz.coords_from_bbox_with_fn(e_from, stz.top_center_coords) cs_to = stz.coords_from_bbox_with_fn(e_to, stz.bottom_center_coords) s_fmt = fmt.combine_tikz_strs( [fmt.line_width(line_width), fmt.arrow_heads("end")]) return stz.line_segment(cs_from, cs_to, s_fmt)
def connect(e_from, e_to, color_name="black"): s_fmt = fmt.combine_tikz_strs( [fmt.arrow_heads("end"), fmt.line_color(color_name), s_lw]) from_cs = stz.center_coords(e_from) to_cs = stz.center_coords(e_to) out_angle = stz.vector_to_angle([from_cs, to_cs]) in_angle = out_angle + 180.0 return stz.line_segment_between_circles(from_cs, node_radius, out_angle, to_cs, node_radius, in_angle, s_fmt)
def connect_horizontally(e_from, e_to): s_fmt = fmt.arrow_heads("end") cs_from = stz.coords_from_bbox_with_fn(e_from, stz.right_center_coords) cs_to = stz.coords_from_bbox_with_fn(e_to, stz.left_center_coords) return stz.line_segment(cs_from, cs_to, s_fmt)
io_corner_roundness = 0.0 module_roundness = 0.0 line_width = 2.0 * fmt.standard_line_width module_inner_vertical_spacing = 0.1 delta_increment = 0.0 horizontal_module_spacing = 0.2 vertical_module_spacing = 0.2 spacing_between_module_and_hyperp = 0.8 spacing_between_hyperp_and_hyperp = 0.4 arrow_length = vertical_module_spacing name2color = fmt.google_slides_named_colors() connect_s_fmt = fmt.combine_tikz_strs( [fmt.arrow_heads("end"), fmt.line_width(line_width)]) input_s_fmt = fmt.combine_tikz_strs([ fmt.line_width(line_width), ]) output_s_fmt = fmt.combine_tikz_strs([ fmt.line_width(line_width), ]) property_s_fmt = fmt.combine_tikz_strs([ fmt.line_width(line_width), ]) module_s_fmt = fmt.combine_tikz_strs([
# answer to latex exchange question: https://tex.stackexchange.com/questions/528863/how-do-you-name-nodes-vertices-with-this-type-of-code/528885#528885 import sane_tikz.core as stz import sane_tikz.formatting as fmt label_spacing = 0.25 pentagon_radius = 1.2 x_axis_length = 4.0 y_axis_length = 3.0 extra_length = 0.4 a_circle_radius = 0.08 s_fmt = fmt.arrow_heads("end") f_fmt = fmt.line_and_fill_colors('black', 'black') cs = [ stz.coords_on_circle([0, 0], pentagon_radius, 90.0 + i * (360.0 / 5)) for i in range(5) ] e = stz.closed_path(cs) origin_cs = stz.translate_coords_horizontally(cs[2], -1.0) x_end_cs = stz.translate_coords_horizontally(origin_cs, x_axis_length) y_end_cs = stz.translate_coords_vertically(origin_cs, y_axis_length) x_start_cs = stz.translate_coords_horizontally(origin_cs, -extra_length) y_start_cs = stz.translate_coords_vertically(origin_cs, -extra_length) x_label_cs = stz.translate_coords_vertically(x_end_cs, -label_spacing) y_label_cs = stz.translate_coords_horizontally(y_end_cs, -label_spacing) origin_label_cs = stz.translate_coords_diagonally(origin_cs, -label_spacing) axes = [ stz.line_segment(x_start_cs, x_end_cs, s_fmt),