import drawsvg as draw import math # Veränderbare Parameter height = 500 length = 500 key_width = 80 bridge_width = 20 # Feste und berechnete Parameter i = 1 x = 0 y = 0 side_length = key_width / math.sqrt(3) sin_expression = math.sin(math.radians(30))*side_length distance = key_width + bridge_width distance_y = (math.sqrt(3) / 2) * distance canvas = draw.Drawing(length, height, origin=(0, 0)) while y + (2 * side_length) < height: while x + key_width < length: p1_x = x + key_width / 2 p1_y = y p2_x = x p2_y = y + sin_expression p3_x = x p3_y = y + sin_expression + side_length p4_x = x + key_width / 2 p4_y = y + 2 * side_length p5_x = x + key_width p5_y = y + sin_expression + side_length p6_x = x + key_width p6_y = y + sin_expression hexagon = draw.Lines(p1_x, p1_y, p2_x, p2_y, p3_x, p3_y, p4_x, p4_y, p5_x, p5_y, p6_x, p6_y, fill='none', stroke='black', close='true') canvas.append(hexagon) x = x + distance if i % 2 == 0: x = 0 else: x = distance / 2 y = y + distance_y i = i + 1 canvas.save_svg('hex.svg')