Standardwerte angepasst, input auf float geändert, stroke_width angepasst, Masseinheiten auf mm geändert
This commit is contained in:
parent
60e26fa218
commit
82d2f60a8f
|
@ -4,7 +4,7 @@ import math
|
||||||
|
|
||||||
|
|
||||||
class Circle:
|
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 length >= 0, "length can not be negative"
|
||||||
assert height >= 0, "height can not be negative"
|
assert height >= 0, "height can not be negative"
|
||||||
assert radius >= 0, "radius can not be negative"
|
assert radius >= 0, "radius can not be negative"
|
||||||
|
@ -61,14 +61,11 @@ class Circle:
|
||||||
def offset_percentage(self):
|
def offset_percentage(self):
|
||||||
return self.__offset_percentage
|
return self.__offset_percentage
|
||||||
|
|
||||||
@property
|
@offset_percentage.setter
|
||||||
def offset(self):
|
def offset_percentage(self, val):
|
||||||
return self.__offset
|
|
||||||
|
|
||||||
@offset.setter
|
|
||||||
def offset(self, val):
|
|
||||||
assert val >= 0, "offset can only be 0 - 100 %"
|
assert val >= 0, "offset can only be 0 - 100 %"
|
||||||
assert val <= 100, "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
|
self.__offset = (self.__distance / 100) * val
|
||||||
|
|
||||||
def circle_generation(self, filetype='svg'):
|
def circle_generation(self, filetype='svg'):
|
||||||
|
@ -81,7 +78,7 @@ class Circle:
|
||||||
|
|
||||||
while y + self.__radius <= self.__height:
|
while y + self.__radius <= self.__height:
|
||||||
while x + self.__radius <= self.__length:
|
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
|
x = x + self.__distance
|
||||||
|
|
||||||
if i % 2 == 0:
|
if i % 2 == 0:
|
||||||
|
@ -99,7 +96,7 @@ class Circle:
|
||||||
|
|
||||||
|
|
||||||
class Hexagon:
|
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 length >= 0, "length can not be negative"
|
||||||
assert height >= 0, "height can not be negative"
|
assert height >= 0, "height can not be negative"
|
||||||
assert key_width >= 0, "key width 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
|
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,
|
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)
|
canvas.append(hexagon)
|
||||||
|
|
||||||
x = x + distance
|
x = x + distance
|
||||||
|
@ -197,7 +194,7 @@ class Hexagon:
|
||||||
|
|
||||||
|
|
||||||
class Triangle:
|
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 length >= 0, "length can not be negative"
|
||||||
assert height >= 0, "height can not be negative"
|
assert height >= 0, "height can not be negative"
|
||||||
assert side_length >= 0, "side length 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
|
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,
|
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)
|
canvas.append(triangle)
|
||||||
|
|
||||||
x = x + self.__side_length + distance
|
x = x + self.__side_length + distance
|
||||||
|
@ -278,7 +275,7 @@ class Triangle:
|
||||||
triangle2_p3_y = triangle2_p2_y
|
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 = 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)
|
canvas.append(triangle2)
|
||||||
|
|
||||||
x = x + distance
|
x = x + distance
|
||||||
|
@ -308,7 +305,7 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
if shape == 1:
|
if shape == 1:
|
||||||
circle = Circle(name, path)
|
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
|
selection_flag = True
|
||||||
while selection_flag:
|
while selection_flag:
|
||||||
try:
|
try:
|
||||||
|
@ -316,20 +313,20 @@ if __name__ == '__main__':
|
||||||
if parameter_selection == 0:
|
if parameter_selection == 0:
|
||||||
selection_flag = False
|
selection_flag = False
|
||||||
elif parameter_selection == 1:
|
elif parameter_selection == 1:
|
||||||
height = int(input("Höhe in Pixeln eingeben:"))
|
height = float(input("Höhe in mm eingeben:"))
|
||||||
circle.height = height
|
circle.height = height
|
||||||
elif parameter_selection == 2:
|
elif parameter_selection == 2:
|
||||||
length = int(input("Länge in Pixeln:"))
|
length = float(input("Länge in mm:"))
|
||||||
circle.length = length
|
circle.length = length
|
||||||
elif parameter_selection == 3:
|
elif parameter_selection == 3:
|
||||||
radius = int(input("Radius in Pixeln:"))
|
radius = float(input("Radius in mm:"))
|
||||||
circle.radius = radius
|
circle.radius = radius
|
||||||
elif parameter_selection == 4:
|
elif parameter_selection == 4:
|
||||||
distance = int(input("Abstand in Pixeln:"))
|
distance = float(input("Abstand in mm:"))
|
||||||
circle.distance = distance
|
circle.distance = distance
|
||||||
elif parameter_selection == 5:
|
elif parameter_selection == 5:
|
||||||
offset = int(input("Offset in %:"))
|
offset = float(input("Offset in %:"))
|
||||||
circle.offset = offset
|
circle.offset_percentage = offset
|
||||||
elif parameter_selection == 6:
|
elif parameter_selection == 6:
|
||||||
filetype_selection = int(input(f"1: {name}.svg, 2: {name}.png:"))
|
filetype_selection = int(input(f"1: {name}.svg, 2: {name}.png:"))
|
||||||
if filetype_selection == 1:
|
if filetype_selection == 1:
|
||||||
|
@ -350,7 +347,7 @@ if __name__ == '__main__':
|
||||||
elif shape == 2:
|
elif shape == 2:
|
||||||
hexagon = Hexagon(name, path)
|
hexagon = Hexagon(name, path)
|
||||||
print(
|
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
|
selection_flag = True
|
||||||
while selection_flag:
|
while selection_flag:
|
||||||
try:
|
try:
|
||||||
|
@ -358,16 +355,16 @@ if __name__ == '__main__':
|
||||||
if parameter_selection == 0:
|
if parameter_selection == 0:
|
||||||
selection_flag = False
|
selection_flag = False
|
||||||
elif parameter_selection == 1:
|
elif parameter_selection == 1:
|
||||||
height = int(input("Höhe in Pixeln eingeben:"))
|
height = float(input("Höhe in Pixeln eingeben:"))
|
||||||
hexagon.height = height
|
hexagon.height = height
|
||||||
elif parameter_selection == 2:
|
elif parameter_selection == 2:
|
||||||
length = int(input("Länge in Pixeln:"))
|
length = float(input("Länge in mm:"))
|
||||||
hexagon.length = length
|
hexagon.length = length
|
||||||
elif parameter_selection == 3:
|
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
|
hexagon.key_width = key_width
|
||||||
elif parameter_selection == 4:
|
elif parameter_selection == 4:
|
||||||
bridge_width = int(input("Stegbreite in Pixeln:"))
|
bridge_width = float(input("Stegbreite in mm:"))
|
||||||
hexagon.bridge_width = bridge_width
|
hexagon.bridge_width = bridge_width
|
||||||
elif parameter_selection == 5:
|
elif parameter_selection == 5:
|
||||||
filetype_selection = int(input(f"1: {name}.svg, 2: {name}.png:"))
|
filetype_selection = int(input(f"1: {name}.svg, 2: {name}.png:"))
|
||||||
|
@ -388,7 +385,7 @@ if __name__ == '__main__':
|
||||||
elif shape == 3:
|
elif shape == 3:
|
||||||
triangle = Triangle(name, path)
|
triangle = Triangle(name, path)
|
||||||
print(
|
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
|
selection_flag = True
|
||||||
while selection_flag:
|
while selection_flag:
|
||||||
try:
|
try:
|
||||||
|
@ -397,16 +394,16 @@ if __name__ == '__main__':
|
||||||
if parameter_selection == 0:
|
if parameter_selection == 0:
|
||||||
selection_flag = False
|
selection_flag = False
|
||||||
elif parameter_selection == 1:
|
elif parameter_selection == 1:
|
||||||
height = int(input("Höhe in Pixeln eingeben:"))
|
height = float(input("Höhe in mm eingeben:"))
|
||||||
triangle.height = height
|
triangle.height = height
|
||||||
elif parameter_selection == 2:
|
elif parameter_selection == 2:
|
||||||
length = int(input("Länge in Pixeln:"))
|
length = float(input("Länge in mm:"))
|
||||||
triangle.length = length
|
triangle.length = length
|
||||||
elif parameter_selection == 3:
|
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
|
triangle.side_length = side_length
|
||||||
elif parameter_selection == 4:
|
elif parameter_selection == 4:
|
||||||
bridge_width = int(input("Stegbreite in Pixeln:"))
|
bridge_width = float(input("Stegbreite in mm:"))
|
||||||
triangle.bridge_width = bridge_width
|
triangle.bridge_width = bridge_width
|
||||||
elif parameter_selection == 5:
|
elif parameter_selection == 5:
|
||||||
filetype_selection = int(input(f"1: {name}.svg, 2: {name}.png:"))
|
filetype_selection = int(input(f"1: {name}.svg, 2: {name}.png:"))
|
||||||
|
|
Loading…
Reference in New Issue