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() fraction = 1/3 #edit the scale to make the overall image bigger or smaller scale = 500 #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 = fraction*Point[0] + (1/4) newY = fraction*Point[1] + (27/80) return (newX,newY) def Transformation2(Point): newX = fraction*Point[0] - (3/28) newY = fraction* -1 * Point[1] + (17/80) return (newX, newY) def Transformation3(Point): newX = fraction*Point[0] - (1/4) newY = fraction* -1 * Point[1] + (459/560) return (newX, newY) def Transformation4(Point): newX = fraction*Point[0] + (1/4) newY = fraction* -1 * Point[1] + (97/80) return (newX, newY) def Transformation5(Point): newX = fraction*Point[0] + (3/4) newY = fraction* -1 * Point[1] + (459/560) return (newX, newY) def Transformation6(Point): newX = fraction*Point[0] + (17/28) newY = fraction* -1 * Point[1] + (17/80) 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) 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("blue") 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()