Klasse Circle mit Methode circle_generation fertig gestellt

This commit is contained in:
Mika 2023-11-01 13:26:38 +01:00
parent edd13eafef
commit f29e72e3ae

View File

@ -3,10 +3,44 @@ import math
import random import random
class Hexagon: class Circle:
def __int__(self): def __init__(self, length=1000, height=1000, radius=10, distance=60, offset=30):
pass # run validations
assert length >= 0, "length can not be negative"
assert radius >= 0, "radius can not be negative"
assert distance >= 2*radius, "distance must be grater den two times the radius"
# Assign to self object
self.__length = length
self.__height = height
self.__radius = radius
self.__distance = distance
self.__offset = offset
def circle_generation(self):
x1 = 10
y1 = 10
y = y1
v = 1
g = 1
canvas = draw.Drawing(self.__length, self.__height, origin=(0, 0))
while y <= self.__height:
x = x1 + self.__offset * v
while x <= self.__length:
canvas.append(draw.Circle(x, y, self.__radius,
fill='none', stroke_width=1, stroke='black'))
x = x + self.__distance
y = y + self.__distance
v = -((1 - g) / 2)
g = -g
canvas.save_svg('example.svg')
if __name__ == '__main__': if __name__ == '__main__':
x = 1 circle = Circle()
circle.circle_generation()