psf/black code formatting (#1277)

This commit is contained in:
William Zhang
2019-10-05 01:14:13 -04:00
committed by Christian Clauss
parent 07f04a2e55
commit 9eac17a408
291 changed files with 6014 additions and 4571 deletions

View File

@ -1,7 +1,7 @@
#!/usr/bin/python
# encoding=utf8
'''Author Anurag Kumar | anuragkumarak95@gmail.com | git/anuragkumarak95
"""Author Anurag Kumar | anuragkumarak95@gmail.com | git/anuragkumarak95
Simple example of Fractal generation using recursive function.
@ -23,46 +23,51 @@ Usage:
Credits: This code was written by editing the code from http://www.riannetrujillo.com/blog/python-fractal/
'''
"""
import turtle
import sys
PROGNAME = 'Sierpinski Triangle'
points = [[-175,-125],[0,175],[175,-125]] #size of triangle
PROGNAME = "Sierpinski Triangle"
def getMid(p1,p2):
return ( (p1[0]+p2[0]) / 2, (p1[1] + p2[1]) / 2) #find midpoint
points = [[-175, -125], [0, 175], [175, -125]] # size of triangle
def triangle(points,depth):
def getMid(p1, p2):
return ((p1[0] + p2[0]) / 2, (p1[1] + p2[1]) / 2) # find midpoint
def triangle(points, depth):
myPen.up()
myPen.goto(points[0][0],points[0][1])
myPen.goto(points[0][0], points[0][1])
myPen.down()
myPen.goto(points[1][0],points[1][1])
myPen.goto(points[2][0],points[2][1])
myPen.goto(points[0][0],points[0][1])
myPen.goto(points[1][0], points[1][1])
myPen.goto(points[2][0], points[2][1])
myPen.goto(points[0][0], points[0][1])
if depth>0:
triangle([points[0],
getMid(points[0], points[1]),
getMid(points[0], points[2])],
depth-1)
triangle([points[1],
getMid(points[0], points[1]),
getMid(points[1], points[2])],
depth-1)
triangle([points[2],
getMid(points[2], points[1]),
getMid(points[0], points[2])],
depth-1)
if depth > 0:
triangle(
[points[0], getMid(points[0], points[1]), getMid(points[0], points[2])],
depth - 1,
)
triangle(
[points[1], getMid(points[0], points[1]), getMid(points[1], points[2])],
depth - 1,
)
triangle(
[points[2], getMid(points[2], points[1]), getMid(points[0], points[2])],
depth - 1,
)
if __name__ == '__main__':
if len(sys.argv) !=2:
raise ValueError('right format for using this script: '
'$python fractals.py <int:depth_for_fractal>')
if __name__ == "__main__":
if len(sys.argv) != 2:
raise ValueError(
"right format for using this script: "
"$python fractals.py <int:depth_for_fractal>"
)
myPen = turtle.Turtle()
myPen.ht()
myPen.speed(5)
myPen.pencolor('red')
triangle(points,int(sys.argv[1]))
myPen.pencolor("red")
triangle(points, int(sys.argv[1]))