From 82d2f60a8f79f3cf1eb00370fa07e1cd8c96145f Mon Sep 17 00:00:00 2001 From: Mika Date: Wed, 8 Nov 2023 15:26:08 +0100 Subject: [PATCH] =?UTF-8?q?Standardwerte=20angepasst,=20input=20auf=20floa?= =?UTF-8?q?t=20ge=C3=A4ndert,=20stroke=5Fwidth=20angepasst,=20Masseinheite?= =?UTF-8?q?n=20auf=20mm=20ge=C3=A4ndert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mustergenerator.py | 57 ++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/mustergenerator.py b/mustergenerator.py index edcb3f0..d4ba5d1 100644 --- a/mustergenerator.py +++ b/mustergenerator.py @@ -4,7 +4,7 @@ import math class Circle: - def __init__(self, name: str, filepath: str, length=472, height=472, radius=10, distance=60, offset=50): + def __init__(self, name: str, filepath: str, length=20, height=20, radius=2, distance=4.5, offset=50): assert length >= 0, "length can not be negative" assert height >= 0, "height can not be negative" assert radius >= 0, "radius can not be negative" @@ -61,14 +61,11 @@ class Circle: def offset_percentage(self): return self.__offset_percentage - @property - def offset(self): - return self.__offset - - @offset.setter - def offset(self, val): + @offset_percentage.setter + def offset_percentage(self, val): assert val >= 0, "offset can only be 0 - 100 %" assert val <= 100, "offset can only be 0 - 100 %" + self.__offset_percentage = val self.__offset = (self.__distance / 100) * val def circle_generation(self, filetype='svg'): @@ -81,7 +78,7 @@ class Circle: while y + self.__radius <= self.__height: while x + self.__radius <= self.__length: - canvas.append(draw.Circle(x, y, self.__radius, fill='none', stroke_width=1, stroke='black')) + canvas.append(draw.Circle(x, y, self.__radius, fill='none', stroke_width=0.1, stroke='black')) x = x + self.__distance if i % 2 == 0: @@ -99,7 +96,7 @@ class Circle: class Hexagon: - def __init__(self, name: str, filepath: str, length=472, height=472, key_width=50, bridge_width=10): + def __init__(self, name: str, filepath: str, length=50, height=50, key_width=2, bridge_width=0.5): assert length >= 0, "length can not be negative" assert height >= 0, "height can not be negative" assert key_width >= 0, "key width can not be negative" @@ -177,7 +174,7 @@ class Hexagon: 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') + fill='none', stroke='black', close='true', stroke_width=0.1) canvas.append(hexagon) x = x + distance @@ -197,7 +194,7 @@ class Hexagon: class Triangle: - def __init__(self, name: str, filepath: str, length=472, height=472, side_length=50, bridge_width=10): + def __init__(self, name: str, filepath: str, length=20, height=20, side_length=2, bridge_width=0.5): assert length >= 0, "length can not be negative" assert height >= 0, "height can not be negative" assert side_length >= 0, "side length can not be negative" @@ -265,7 +262,7 @@ class Triangle: triangle1_p3_y = y + math.cos(math.radians(30)) * self.__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') + triangle1_p3_y, close='true', stroke='black', fill='none', stroke_width=0.1) canvas.append(triangle) x = x + self.__side_length + distance @@ -278,7 +275,7 @@ class Triangle: 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') + triangle2_p3_y, close='true', stroke='black', fill='none', stroke_width=0.1) canvas.append(triangle2) x = x + distance @@ -308,7 +305,7 @@ if __name__ == '__main__': if shape == 1: circle = Circle(name, path) - print(f"\nStandardwerte\n1. Höhe: {circle.height} px\n2. Länge: {circle.length} px\n3. Radius: {circle.radius} px\n4. Abstand: {circle.distance} px\n5. Offset: {circle.offset_percentage} %\n6. Dateityp: svg\n") + print(f"\nStandardwerte\n1. Höhe: {circle.height} mm\n2. Länge: {circle.length} mm\n3. Radius: {circle.radius} mm\n4. Abstand: {circle.distance} mm\n5. Offset: {circle.offset_percentage} %\n6. Dateityp: svg\n") selection_flag = True while selection_flag: try: @@ -316,20 +313,20 @@ if __name__ == '__main__': if parameter_selection == 0: selection_flag = False elif parameter_selection == 1: - height = int(input("Höhe in Pixeln eingeben:")) + height = float(input("Höhe in mm eingeben:")) circle.height = height elif parameter_selection == 2: - length = int(input("Länge in Pixeln:")) + length = float(input("Länge in mm:")) circle.length = length elif parameter_selection == 3: - radius = int(input("Radius in Pixeln:")) + radius = float(input("Radius in mm:")) circle.radius = radius elif parameter_selection == 4: - distance = int(input("Abstand in Pixeln:")) + distance = float(input("Abstand in mm:")) circle.distance = distance elif parameter_selection == 5: - offset = int(input("Offset in %:")) - circle.offset = offset + offset = float(input("Offset in %:")) + circle.offset_percentage = offset elif parameter_selection == 6: filetype_selection = int(input(f"1: {name}.svg, 2: {name}.png:")) if filetype_selection == 1: @@ -350,7 +347,7 @@ if __name__ == '__main__': elif shape == 2: hexagon = Hexagon(name, path) print( - f"\nStandardwerte\n1. Höhe: {hexagon.height} px\n2. Länge: {hexagon.length} px\n3. Schlüsselweite: {hexagon.key_width} px\n4. Stegbreite: {hexagon.bridge_width} px\n5. Dateityp: svg\n") + f"\nStandardwerte\n1. Höhe: {hexagon.height} mm\n2. Länge: {hexagon.length} mm\n3. Schlüsselweite: {hexagon.key_width} mm\n4. Stegbreite: {hexagon.bridge_width} mm\n5. Dateityp: svg\n") selection_flag = True while selection_flag: try: @@ -358,16 +355,16 @@ if __name__ == '__main__': if parameter_selection == 0: selection_flag = False elif parameter_selection == 1: - height = int(input("Höhe in Pixeln eingeben:")) + height = float(input("Höhe in Pixeln eingeben:")) hexagon.height = height elif parameter_selection == 2: - length = int(input("Länge in Pixeln:")) + length = float(input("Länge in mm:")) hexagon.length = length elif parameter_selection == 3: - key_width = int(input("Schlüsselweite in Pixeln:")) + key_width = float(input("Schlüsselweite in mm:")) hexagon.key_width = key_width elif parameter_selection == 4: - bridge_width = int(input("Stegbreite in Pixeln:")) + bridge_width = float(input("Stegbreite in mm:")) hexagon.bridge_width = bridge_width elif parameter_selection == 5: filetype_selection = int(input(f"1: {name}.svg, 2: {name}.png:")) @@ -388,7 +385,7 @@ if __name__ == '__main__': elif shape == 3: triangle = Triangle(name, path) print( - f"\nStandardwerte\n1. Höhe: {triangle.height} px\n2. Länge: {triangle.length} px\n3. Seitenlänge: {triangle.side_length} px\n4. Stegbreite: {triangle.bridge_width} px\n5. Dateityp: svg\n") + f"\nStandardwerte\n1. Höhe: {triangle.height} mm\n2. Länge: {triangle.length} mm\n3. Seitenlänge: {triangle.side_length} mm\n4. Stegbreite: {triangle.bridge_width} mm\n5. Dateityp: svg\n") selection_flag = True while selection_flag: try: @@ -397,16 +394,16 @@ if __name__ == '__main__': if parameter_selection == 0: selection_flag = False elif parameter_selection == 1: - height = int(input("Höhe in Pixeln eingeben:")) + height = float(input("Höhe in mm eingeben:")) triangle.height = height elif parameter_selection == 2: - length = int(input("Länge in Pixeln:")) + length = float(input("Länge in mm:")) triangle.length = length elif parameter_selection == 3: - side_length = int(input("Seitenlänge in Pixeln:")) + side_length = float(input("Seitenlänge in mm:")) triangle.side_length = side_length elif parameter_selection == 4: - bridge_width = int(input("Stegbreite in Pixeln:")) + bridge_width = float(input("Stegbreite in mm:")) triangle.bridge_width = bridge_width elif parameter_selection == 5: filetype_selection = int(input(f"1: {name}.svg, 2: {name}.png:"))