Upload files to ""

This commit is contained in:
LukasGro 2023-10-29 21:16:41 +00:00
parent 6c8d43b842
commit adebf2ddc3
2 changed files with 119 additions and 0 deletions

64
Dreieck.py Normal file
View File

@ -0,0 +1,64 @@
# -*- coding: utf-8 -*-
"""
Created on Sun Oct 29 21:51:09 2023
@author: Lukas
"""
import drawsvg as draw
import math
# Mittelpunkt X-Koordinate
x1=0
# Mittelpunkt Y-Koordinate
y1=0
# Schlüsselbreite
sb = 50.0000
#Breite Feld
length=10000
#Höhe Feld
height = 10000
#Abstand X
ax=20
#Abstand Y
ay=30
#Versatz der Spalten
versatz= 0
#höhe dreieck
h= 20
#breite dreieck
b = 30
#Def
v=0
g=-1
r=1
x=0
y=0
f=-1
size = sb/math.sqrt(3)
d = draw.Drawing(length, height, origin=(0, 0))
x =x1
y =y1
while y <= height:
x=x1+((versatz)*v)
while x <= length:
if f == -1:
d.append(draw.Lines(x, y, x+b, y, x+b/2, y+h,
fill='red', stroke='black', close='true'))
else:
d.append(draw.Lines(x, y+h, x+b, y+h, x+b/2, y,
fill='red', stroke='black', close='true'))
f=-f
x =x+ax
y =y+ay
v= -((1-g)/2)
g=-g
d.append(draw.Circle(0, 0, 40))
#plt.show()
d.save_svg('polygon.svg')

55
randomSquare.py Normal file
View File

@ -0,0 +1,55 @@
# -*- coding: utf-8 -*-
"""
Created on Sun Oct 29 21:26:14 2023
@author: Lukas
"""
import drawsvg as draw
import random
# Größe der Zeichenfläche
canvas_width = 400
canvas_height = 400
# Anzahl der zufällig erzeugten Rechtecke
num_rectangles = 100
# Mindestabstand zwischen den Rechtecken
min_spacing = 5
# Erstellen der Zeichenfläche
d = draw.Drawing(canvas_width, canvas_height, origin='center')
# Funktion zum Erzeugen eines zufälligen Rechtecks mit Abstand
def create_random_rectangle(rectangles):
while True:
x = random.uniform(-canvas_width / 2, canvas_width / 2)
y = random.uniform(-canvas_height / 2, canvas_height / 2)
width = random.uniform(10, 50)
height = random.uniform(10, 50)
# Überprüfen, ob das neue Rechteck mit den vorhandenen Rechtecken kollidiert
collides = False
for rect in rectangles:
x1, y1, w1, h1 = x, y, width, height
x2, y2, w2, h2 = rect
if (x1 + w1 + min_spacing < x2 or x2 + w2 + min_spacing < x1 or
y1 + h1 + min_spacing < y2 or y2 + h2 + min_spacing < y1):
continue
collides = True
break
if not collides:
rectangles.append((x, y, width, height))
return draw.Rectangle(x, y, width, height, fill='blue')
# Erzeugen der zufälligen Rechtecke und Hinzufügen zur Zeichenfläche
rectangles = []
for _ in range(num_rectangles):
random_rectangle = create_random_rectangle(rectangles)
d.append(random_rectangle)
# Speichern der SVG-Datei
d.save_svg('random_rectangles_with_spacing.svg')