Compare commits
No commits in common. "60e26fa21857c56a6629d3582e1da0351cf56856" and "b6d99796d1ae257be5edacdca1ca808182b1f164" have entirely different histories.
60e26fa218
...
b6d99796d1
|
@ -1,42 +0,0 @@
|
|||
import drawsvg as draw
|
||||
import tkinter as tk
|
||||
from tkinter.filedialog import askopenfilenames
|
||||
import os
|
||||
|
||||
|
||||
def get_image_path():
|
||||
filepath = askopenfilenames(filetypes=[("SVG-Datei wählen", "*.svg")])
|
||||
return filepath
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
root = tk.Tk()
|
||||
root.withdraw()
|
||||
|
||||
filename = input("Dateiname:")
|
||||
|
||||
selection_flag = True
|
||||
while selection_flag:
|
||||
paths = get_image_path()
|
||||
|
||||
if len(paths) != 8:
|
||||
print("Bitte wählen sie 8 *.svg-Datein aus")
|
||||
else:
|
||||
selection_flag = False
|
||||
|
||||
print(paths)
|
||||
|
||||
canvas = draw.Drawing(2480, 3508, origin=(0, 0))
|
||||
|
||||
image_1 = canvas.append(draw.Image(396, 591, 472, 472, paths[0]))
|
||||
image_2 = canvas.append(draw.Image(986, 591, 472, 472, paths[1]))
|
||||
image_3 = canvas.append(draw.Image(1576, 591, 472, 472, paths[2]))
|
||||
image_4 = canvas.append(draw.Image(2166, 591, 472, 472, paths[3]))
|
||||
image_5 = canvas.append(draw.Image(396, 1417, 472, 472, paths[4]))
|
||||
image_6 = canvas.append(draw.Image(986, 1417, 472, 472, paths[5]))
|
||||
image_7 = canvas.append(draw.Image(1576, 1417, 472, 472, paths[6]))
|
||||
image_8 = canvas.append(draw.Image(2166, 1417, 472, 472, paths[7]))
|
||||
|
||||
canvas.save_svg(f'{os.getcwd()}/{filename}.svg')
|
||||
|
||||
|
|
@ -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=1000, height=1000, radius=10, distance=60, 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"
|
||||
|
@ -71,8 +71,7 @@ class Circle:
|
|||
assert val <= 100, "offset can only be 0 - 100 %"
|
||||
self.__offset = (self.__distance / 100) * val
|
||||
|
||||
def circle_generation(self, filetype='svg'):
|
||||
assert filetype == 'svg' or 'png', "Dateityp mus svg oder png sein"
|
||||
def circle_generation(self):
|
||||
x = self.__radius
|
||||
y = self.__radius
|
||||
i = 1
|
||||
|
@ -91,15 +90,11 @@ class Circle:
|
|||
|
||||
y = y + self.__distance
|
||||
i = i + 1
|
||||
|
||||
if filetype == 'svg':
|
||||
canvas.save_svg(f'{self.__filepath}/{self.__name}.svg')
|
||||
if filetype == 'png':
|
||||
canvas.save_png(f'{self.__filepath}/{self.__name}.png')
|
||||
|
||||
|
||||
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=1000, height=1000, key_width=50, bridge_width=10):
|
||||
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"
|
||||
|
@ -148,9 +143,7 @@ class Hexagon:
|
|||
assert val >= 0, "bridge width can not be negative"
|
||||
self.__bridge_width = val
|
||||
|
||||
def hexagon_generation(self, filetype='svg'):
|
||||
assert filetype == 'svg' or 'png', "Dateityp mus svg oder png sein"
|
||||
|
||||
def hexagon_generation(self):
|
||||
i = 1
|
||||
x = 0
|
||||
y = 0
|
||||
|
@ -190,14 +183,11 @@ class Hexagon:
|
|||
y = y + distance_y
|
||||
i = i + 1
|
||||
|
||||
if filetype == 'svg':
|
||||
canvas.save_svg(f'{self.__filepath}/{self.__name}.svg')
|
||||
if filetype == 'png':
|
||||
canvas.save_png(f'{self.__filepath}/{self.__name}.png')
|
||||
|
||||
|
||||
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=1000, height=1000, side_length=50, bridge_width=10):
|
||||
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"
|
||||
|
@ -246,8 +236,7 @@ class Triangle:
|
|||
assert val >= 0, "bridge width can not be negative"
|
||||
self.__bridge_width = val
|
||||
|
||||
def triangle_generation(self, filetype='svg'):
|
||||
assert filetype == 'svg' or 'png', "Dateityp mus svg oder png sein"
|
||||
def triangle_generation(self):
|
||||
x = 0
|
||||
y = 0
|
||||
i = 1
|
||||
|
@ -289,10 +278,7 @@ class Triangle:
|
|||
y = y + self.__bridge_width + math.sqrt(3) / 2 * self.__side_length
|
||||
i = i + 1
|
||||
|
||||
if filetype == 'svg':
|
||||
canvas.save_svg(f'{self.__filepath}/{self.__name}.svg')
|
||||
if filetype == 'png':
|
||||
canvas.save_png(f'{self.__filepath}/{self.__name}.png')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -304,15 +290,13 @@ if __name__ == '__main__':
|
|||
|
||||
shape = int(input("Form (1: Kreis, 2: Hexagon, 3: Dreieck):"))
|
||||
|
||||
filetype = 'svg'
|
||||
|
||||
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\nHöhe: {circle.height} px\nLänge: {circle.length} px\nRadius: {circle.radius} px\nAbstand: {circle.distance} px\nOffset: {circle.offset_percentage} %\n")
|
||||
selection_flag = True
|
||||
while selection_flag:
|
||||
try:
|
||||
parameter_selection = int(input("Parameter ändern (0: keinen Parameter ändern, 1: Höhe, 2: Länge, 3: Radius, 4: Abstand, 5: Offste, 6: Dateityp):"))
|
||||
parameter_selection = int(input("Parameter ändern (0: keinen Parameter ändern, 1: Höhe, 2: Länge, 3: Radius, 4: Abstand, 5: Offste):"))
|
||||
if parameter_selection == 0:
|
||||
selection_flag = False
|
||||
elif parameter_selection == 1:
|
||||
|
@ -330,14 +314,6 @@ if __name__ == '__main__':
|
|||
elif parameter_selection == 5:
|
||||
offset = int(input("Offset in %:"))
|
||||
circle.offset = offset
|
||||
elif parameter_selection == 6:
|
||||
filetype_selection = int(input(f"1: {name}.svg, 2: {name}.png:"))
|
||||
if filetype_selection == 1:
|
||||
filetype = "svg"
|
||||
elif filetype_selection == 2:
|
||||
filetype = "png"
|
||||
else:
|
||||
raise ValueError
|
||||
else:
|
||||
print("ungültiger Wert")
|
||||
except ValueError:
|
||||
|
@ -345,16 +321,16 @@ if __name__ == '__main__':
|
|||
except AssertionError as error:
|
||||
print(error)
|
||||
|
||||
circle.circle_generation(filetype)
|
||||
circle.circle_generation()
|
||||
|
||||
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\nHöhe: {hexagon.height} px\nLänge: {hexagon.length} px\nSchlüsselweite: {hexagon.key_width} px\nStegbreite: {hexagon.bridge_width} px\n")
|
||||
selection_flag = True
|
||||
while selection_flag:
|
||||
try:
|
||||
parameter_selection = int(input("Parameter ändern (0: keinen Parameter ändern, 1: Höhe, 2: Länge, 3: Schlüsselweite, 4: Stegbreite, 5: Dateityp):"))
|
||||
parameter_selection = int(input("Parameter ändern (0: keinen Parameter ändern, 1: Höhe, 2: Länge, 3: Schlüsselweite, 4: Stegbreite):"))
|
||||
if parameter_selection == 0:
|
||||
selection_flag = False
|
||||
elif parameter_selection == 1:
|
||||
|
@ -369,14 +345,6 @@ if __name__ == '__main__':
|
|||
elif parameter_selection == 4:
|
||||
bridge_width = int(input("Stegbreite in Pixeln:"))
|
||||
hexagon.bridge_width = bridge_width
|
||||
elif parameter_selection == 5:
|
||||
filetype_selection = int(input(f"1: {name}.svg, 2: {name}.png:"))
|
||||
if filetype_selection == 1:
|
||||
filetype = "svg"
|
||||
elif filetype_selection == 2:
|
||||
filetype = "png"
|
||||
else:
|
||||
raise ValueError
|
||||
else:
|
||||
print("ungültiger Wert")
|
||||
except ValueError:
|
||||
|
@ -384,16 +352,16 @@ if __name__ == '__main__':
|
|||
except AssertionError as error:
|
||||
print(error)
|
||||
|
||||
hexagon.hexagon_generation(filetype)
|
||||
hexagon.hexagon_generation()
|
||||
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\nHöhe: {triangle.height} px\nLänge: {triangle.length} px\nSeitenlänge: {triangle.side_length} px\nStegbreite: {triangle.bridge_width} px\n")
|
||||
selection_flag = True
|
||||
while selection_flag:
|
||||
try:
|
||||
parameter_selection = int(input(
|
||||
"Parameter ändern (0: keinen Parameter ändern, 1: Höhe, 2: Länge, 3: Seitenlänge, 4: Stegbreite, 5: Dateityp):"))
|
||||
"Parameter ändern (0: keinen Parameter ändern, 1: Höhe, 2: Länge, 3: Seitenlänge, 4: Stegbreite):"))
|
||||
if parameter_selection == 0:
|
||||
selection_flag = False
|
||||
elif parameter_selection == 1:
|
||||
|
@ -408,14 +376,6 @@ if __name__ == '__main__':
|
|||
elif parameter_selection == 4:
|
||||
bridge_width = int(input("Stegbreite in Pixeln:"))
|
||||
triangle.bridge_width = bridge_width
|
||||
elif parameter_selection == 5:
|
||||
filetype_selection = int(input(f"1: {name}.svg, 2: {name}.png:"))
|
||||
if filetype_selection == 1:
|
||||
filetype = "svg"
|
||||
elif filetype_selection == 2:
|
||||
filetype = "png"
|
||||
else:
|
||||
raise ValueError
|
||||
else:
|
||||
print("ungültiger Wert")
|
||||
except ValueError:
|
||||
|
@ -423,6 +383,6 @@ if __name__ == '__main__':
|
|||
except AssertionError as error:
|
||||
print(error)
|
||||
|
||||
triangle.triangle_generation(filetype)
|
||||
triangle.triangle_generation()
|
||||
else:
|
||||
print("ungültiger Wert")
|
||||
|
|
Loading…
Reference in New Issue