import turtle
import math

class Star:
    
    def __init__(self, Point1,Point2,Point3,Point4,Point5,Point6,Point7,Point8,Point9,Point10):
        self.Point1 = Point1
        self.Point2 = Point2
        self.Point3 = Point3
        self.Point4 = Point4
        self.Point5 = Point5
        self.Point6 = Point6
        self.Point7 = Point7
        self.Point8 = Point8
        self.Point9 = Point9
        self.Point10 = Point10

myTurtle = turtle.Turtle()
#edit the scale to make the overall image bigger or smaller
scale = 800
#edit fractal count to increase or decrease the amount of transformations performed
fractalCount = 1

def DrawLine(Point1, Point2):
    myTurtle.penup()
    myTurtle.goto(ReturnX(Point1[0]),ReturnY(Point1[1]))
    myTurtle.pendown()
    myTurtle.goto(ReturnX(Point2[0]),ReturnY(Point2[1]))

def ReturnX(x):
    return (x - 1/2) * scale

def ReturnY(y):
    return y * scale - scale / 2

def Transformation1(Point):
    newX = (1/3)*Point[0]
    newY = (1/3)*Point[1] + (2/3)
    return (newX,newY)

def Transformation2(Point):
    newX = (1/3)*Point[0] + (1/3)
    newY = (1/3)*Point[1] + (2/3)
    return (newX,newY)

def Transformation3(Point):
    newX = (1/3)*Point[0] + (2/3)
    newY = (1/3)*Point[1] + (2/3)
    return (newX,newY)
def Transformation4(Point):
    newX = (1/3)*Point[0] + 0
    newY = (1/3)*Point[1] + (1/3)
    return (newX,newY)

def Transformation5(Point):
    newX = (1/3)*Point[0] + (2/3)
    newY = (1/3)*Point[1] + (1/3)
    return (newX,newY)

def Transformation6(Point):
    newX = (1/3)*Point[0]
    newY = (1/3)*Point[1]
    return (newX,newY)

def Transformation7(Point):
    newX = (1/3)*Point[0] + (1/3)
    newY = (1/3)*Point[1]
    return (newX,newY)

def Transformation8(Point):
    newX = (1/3)*Point[0] + (2/3)
    newY = (1/3)*Point[1]
    return (newX,newY)

turtle.tracer(0,0)
myTurtle.speed('fastest')
stars = [Star((0,8.5/14),(5/14,9/14),(7/14,14/14),(9/14,9/14),(1,8.5/14),(10.5/14,5/14),(12/14,0/14),(7/14,2.5/14),(2/14,0/14),(3.5/14,5/14))]
transformations = (Transformation1,Transformation2,Transformation3,Transformation4,Transformation5,Transformation6,Transformation7,Transformation8)

for x in range (fractalCount):
    newStars = []
    for star in stars:
        for Transformation in transformations:
            newStars.append(Star(Transformation(star.Point1),Transformation(star.Point2),Transformation(star.Point3),Transformation(star.Point4),Transformation(star.Point5),Transformation(star.Point6),
                                 Transformation(star.Point7),Transformation(star.Point8),Transformation(star.Point9),Transformation(star.Point10)))
    stars = newStars

myTurtle.color("red")
for star in stars:
    myTurtle.begin_fill()
    DrawLine(star.Point1,star.Point2)
    DrawLine(star.Point2,star.Point3)
    DrawLine(star.Point3,star.Point4)
    DrawLine(star.Point4,star.Point5)
    DrawLine(star.Point5,star.Point6)
    DrawLine(star.Point6,star.Point7)
    DrawLine(star.Point7,star.Point8)
    DrawLine(star.Point8,star.Point9)
    DrawLine(star.Point9,star.Point10)
    DrawLine(star.Point10,star.Point1)
    myTurtle.end_fill()
    

turtle.update()
turtle.exitonclick()
