Esempio n. 1
0
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)
Esempio n. 2
0
def rectangle(height, color_name):
    s_fmt = fmt.combine_tikz_strs([
        fmt.line_width(line_width),
        fmt.fill_color(color_name),
        fmt.rounded_corners(rectangle_roundness)
    ])
    return stz.rectangle_from_width_and_height([0, 0], height, width, s_fmt)
Esempio n. 3
0
def rectangle_with_latex(width,
                         expr,
                         rectangle_tikz_str="",
                         latex_tikz_str=""):
    r_fmt = fmt.combine_tikz_strs([
        # fmt.alignment("center"),
        fmt.rounded_corners(roundness_in_cm),
        fmt.line_width(line_width),
        rectangle_tikz_str
    ])
    l_fmt = fmt.combine_tikz_strs([latex_tikz_str])
    r = stz.rectangle_from_width_and_height([0, 0], square_side, width, r_fmt)
    l = stz.latex(stz.center_coords(r), expr, l_fmt)
    return [r, l]
Esempio n. 4
0
spacing_between_towers = 1.5
bbox_spacing = 0.45
bbox_roundness = 0.3

name2color = {
    "emb_color": (252, 224, 225),
    "multi_head_attention_color": (252, 226, 187),
    "add_norm_color": (242, 243, 193),
    "ff_color": (194, 232, 247),
    "softmax_color": (203, 231, 207),
    "linear_color": (220, 223, 240),
    "gray_bbox_color": (243, 243, 244)
}

s_arr = fmt.combine_tikz_strs(
    [fmt.line_width(line_width),
     fmt.arrow_heads("end")])

s_lw = fmt.combine_tikz_strs([fmt.line_width(line_width)])

s_con = s_bbox = fmt.combine_tikz_strs([
    fmt.arrow_heads("end"),
    fmt.line_width(line_width),
    fmt.rounded_corners(connector_roundness)
])

s_bbox = fmt.combine_tikz_strs([
    fmt.fill_color("gray_bbox_color"),
    fmt.line_width(line_width),
    fmt.rounded_corners(bbox_roundness)
])
Esempio n. 5
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([
    fmt.line_width(line_width),
Esempio n. 6
0
# reproduction of https://en.wikipedia.org/wiki/Binary_search_algorithm#/media/File:Binary_search_tree_search_4.svg

import sane_tikz as stz
import formatting as fmt

node_radius = 0.30
vertical_node_spacing = 1.4 * node_radius
first_level_horizontal_node_spacing = 1.8
arrow_angle = 30.0
bbox_spacing = 0.1
label_spacing = 0.4
line_width = 1.2 * fmt.standard_line_width

s_lw = fmt.line_width(line_width)

fn = lambda expr: [
    stz.circle([0, 0], node_radius, s_lw),
    stz.latex([0, 0], expr)
]


def place(e, lst):
    delta = 0.0
    for i, sign in enumerate(lst):
        delta += sign * (node_radius + first_level_horizontal_node_spacing /
                         (2 * (i + 1.0)))
    stz.translate_horizontally(e, delta)


def connect(e_from, e_to, color_name="black"):
    s_fmt = fmt.combine_tikz_strs(
Esempio n. 7
0
    "my_grey": (217, 217, 217),
    "my_yellow": (255, 212, 76),
    "my_blue": (1, 176, 240),
    "my_green": (50, 192, 115),
    "my_red": (255, 102, 102)
}

m_fmt = fmt.line_and_fill_colors("my_grey", "my_grey")
x1_fmt = fmt.line_and_fill_colors("my_yellow", "my_yellow")
x2_fmt = fmt.line_and_fill_colors("my_blue", "my_blue")
x3_fmt = fmt.line_and_fill_colors("my_green", "my_green")
x4_fmt = fmt.line_and_fill_colors("my_red", "my_red")
xs_fmt = [x1_fmt, x2_fmt, x3_fmt, x4_fmt]

h_green_rfmt = fmt.combine_tikz_strs(
    [fmt.line_width(2.0 * line_width),
     fmt.line_color("my_green")])
h_grey_rfmt = fmt.line_color("my_grey")
h_grey_lfmt = fmt.text_color("my_grey")


def rectangle_with_latex(width,
                         expr,
                         rectangle_tikz_str="",
                         latex_tikz_str=""):
    r_fmt = fmt.combine_tikz_strs([
        # fmt.alignment("center"),
        fmt.rounded_corners(roundness_in_cm),
        fmt.line_width(line_width),
        rectangle_tikz_str
    ])