Mustergenerator/mustergenerator.py

47 lines
1.2 KiB
Python

import drawsvg as draw
import math
import random
class Circle:
def __init__(self, length=1000, height=1000, radius=10, distance=60, offset=30):
# 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__':
circle = Circle()
circle.circle_generation()