def zigzag(a, stepover, zig_unidirectional, zig_angle): if a.num_curves() == 0: return global rightward_for_zigs global curve_list_for_zigs global sin_angle_for_zigs global cos_angle_for_zigs global sin_minus_angle_for_zigs global cos_minus_angle_for_zigs global one_over_units radians_angle = zig_angle * math.pi / 180 sin_angle_for_zigs = math.sin(-radians_angle) cos_angle_for_zigs = math.cos(-radians_angle) sin_minus_angle_for_zigs = math.sin(radians_angle) cos_minus_angle_for_zigs = math.cos(radians_angle) one_over_units = 1 / area.get_units() a = rotated_area(a) b = area.Box() a.GetBox(b) x0 = b.MinX() - 1.0 x1 = b.MaxX() + 1.0 height = b.MaxY() - b.MinY() num_steps = int(height / stepover + 1) y = b.MinY() + 0.1 * one_over_units null_point = area.Point(0, 0) rightward_for_zigs = True curve_list_for_zigs = [] for i in range(0, num_steps): y0 = y y = y + stepover p0 = area.Point(x0, y0) p1 = area.Point(x0, y) p2 = area.Point(x1, y) p3 = area.Point(x1, y0) c = area.Curve() c.append(area.Vertex(0, p0, null_point, 0)) c.append(area.Vertex(0, p1, null_point, 0)) c.append(area.Vertex(0, p2, null_point, 1)) c.append(area.Vertex(0, p3, null_point, 0)) c.append(area.Vertex(0, p0, null_point, 1)) a2 = area.Area() a2.append(c) a2.Intersect(a) make_zig(a2, y0, y, zig_unidirectional) if zig_unidirectional == False: rightward_for_zigs = (rightward_for_zigs == False) reorder_zigs() return curve_list_for_zigs
def zigzag(a, stepover, zig_unidirectional): if a.num_curves() == 0: return global rightward_for_zigs global curve_list_for_zigs global sin_angle_for_zigs global cos_angle_for_zigs global sin_minus_angle_for_zigs global cos_minus_angle_for_zigs global one_over_units one_over_units = 1 / area.get_units() a = rotated_area(a) b = area.Box() a.GetBox(b) x0 = b.MinX() - 1.0 x1 = b.MaxX() + 1.0 height = b.MaxY() - b.MinY() num_steps = int(height / stepover + 1) y = b.MinY() + 0.1 * one_over_units null_point = area.Point(0, 0) rightward_for_zigs = True curve_list_for_zigs = [] for i in range(0, num_steps): y0 = y y = y + stepover p0 = area.Point(x0, y0) p1 = area.Point(x0, y) p2 = area.Point(x1, y) p3 = area.Point(x1, y0) c = area.Curve() c.append(area.Vertex(0, p0, null_point, 0)) c.append(area.Vertex(0, p1, null_point, 0)) c.append(area.Vertex(0, p2, null_point, 1)) c.append(area.Vertex(0, p3, null_point, 0)) c.append(area.Vertex(0, p0, null_point, 1)) a2 = area.Area() a2.append(c) a2.Intersect(a) make_zig(a2, y0, y, zig_unidirectional) if zig_unidirectional == False: rightward_for_zigs = (rightward_for_zigs == False) reorder_zigs()