From a140a86424114461d2d32ef43201c9ed0e724deb Mon Sep 17 00:00:00 2001 From: Mika Date: Fri, 3 Nov 2023 16:07:39 +0100 Subject: [PATCH] DreickeGen2.py erstellt --- DreickeGen2.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 DreickeGen2.py diff --git a/DreickeGen2.py b/DreickeGen2.py new file mode 100644 index 0000000..af676e5 --- /dev/null +++ b/DreickeGen2.py @@ -0,0 +1,48 @@ +import drawsvg as draw +import math + +height = 1000 +length = 1000 +side_length = 80 +bridge_width = 5 + +distance = bridge_width / math.sin(math.radians(60)) +x = 0 +y = 0 +i = 1 + +canvas = draw.Drawing(length, height, origin=(0, 0)) + +while y + math.sqrt(3) / 2 * side_length <= height: + while x + 1.5 * side_length + distance <= length: + triangle1_p1_x = x + triangle1_p1_y = y + triangle1_p2_x = x + side_length + triangle1_p2_y = y + triangle1_p3_x = x + math.sin(math.radians(30)) * side_length + triangle1_p3_y = y + math.cos(math.radians(30)) * side_length + + triangle = draw.Lines(triangle1_p1_x, triangle1_p1_y, triangle1_p2_x, triangle1_p2_y, triangle1_p3_x, triangle1_p3_y, close='true', stroke='black', fill='none') + canvas.append(triangle) + + x = x + side_length + distance + + triangle2_p1_x = x + triangle2_p1_y = y + triangle2_p2_x = x - side_length / 2 + triangle2_p2_y = y + math.sqrt(3) / 2 * side_length + triangle2_p3_x = x + side_length / 2 + triangle2_p3_y = triangle2_p2_y + + triangle2 = draw.Lines(triangle2_p1_x, triangle2_p1_y, triangle2_p2_x, triangle2_p2_y, triangle2_p3_x, triangle2_p3_y, close='true', stroke='black', fill='none') + canvas.append(triangle2) + + x = x + distance + if i % 2 == 0: + x = 0 + else: + x = side_length / 2 + distance + y = y + bridge_width + math.sqrt(3) / 2 * side_length + i = i + 1 + +canvas.save_svg('dreieck.svg') \ No newline at end of file