def circle_with_plus(): r = plus_circle_radius circle = stz.circle([0, 0], r, s_lw) plus = [ stz.centered_horizontal_line_segment([0, 0], 1.6 * r, s_lw), stz.centered_vertical_line_segment([0, 0], 1.6 * r, s_lw), ] return [circle, plus]
def circle_with_sine(): r = sine_circle_radius alpha = 0.6 * r delta = 0.02 circle = stz.circle([0, 0], r, s_lw) k = 2.0 * math.pi xs = np.linspace(0.0, k) ys = np.sin(xs) cs_lst = [] for x, y in zip(xs, ys): cs_lst.append([ stz.axis_value_to_canvas_value(-r + delta, 0.0, r - delta, k, x), stz.axis_value_to_canvas_value(-r + delta, -r / alpha, r - delta, r / alpha, y) ]) sine = stz.open_path(cs_lst, s_lw) return [circle, sine]
cs = stz.translate_coords_horizontally(cs_ref, label_spacing) return stz.latex(cs, expr) def plate(e_lst, expr): top_left_cs, bottom_right_cs = stz.bbox(e_lst) r = stz.rectangle_from_additive_resizing(top_left_cs, bottom_right_cs, 2.0 * horizontal_plate_spacing, 2.0 * vertical_plate_spacing) l_cs = stz.translate_coords_antidiagonally( stz.bbox(r)[1], -plate_label_spacing) l = stz.latex(l_cs, expr) return [r, l] alpha_c = stz.circle([0, 0], node_radius) theta_c = stz.circle([0, 0], node_radius) z_c = stz.circle([0, 0], node_radius) w_c = stz.circle([0, 0], node_radius) eta_c = stz.circle([0, 0], node_radius) beta_c = stz.circle([0, 0], node_radius) w_c["tikz_str"] = fmt.combine_tikz_strs( [w_c["tikz_str"], fmt.fill_color("gray")]) stz.distribute_horizontally_with_spacing([alpha_c, theta_c, z_c, w_c], node_spacing) stz.distribute_horizontally_with_spacing([eta_c, beta_c], node_spacing) stz.place_above_and_align_to_the_center( [eta_c, beta_c], [alpha_c, theta_c, z_c, w_c], node_spacing)
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), stz.line_segment(y_start_cs, y_end_cs, s_fmt) ] labels = [ stz.latex([cs[0][0], cs[0][1] + label_spacing], "$C$"), stz.latex([cs[1][0] - label_spacing, cs[1][1]], "$B$"), stz.latex([cs[2][0], cs[2][1] - a_circle_radius - label_spacing], "$A(1, 0)$"), stz.latex([cs[3][0], cs[3][1] - label_spacing], "$E$"), stz.latex([cs[4][0] + label_spacing, cs[4][1]], "$D$"), stz.circle(cs[2], a_circle_radius, f_fmt), stz.latex(x_label_cs, "$x$"), stz.latex(y_label_cs, "$y$"), stz.latex(origin_label_cs, "$O$"), ] stz.draw_to_tikz_standalone([e, labels, axes], "pentagon.tex")
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( [fmt.arrow_heads("end"),
def small_node(cs): s_fmt = fmt.fill_color('black') return stz.circle(cs, filled_node_radius, s_fmt)
def node(label): return [stz.circle([0, 0], node_radius), stz.latex([0, 0], label)]