added notes

This commit is contained in:
Sam
2022-03-14 15:41:16 +13:00
parent a71f0c97a2
commit a63bee2540
9 changed files with 22 additions and 20 deletions

27
Python/Tree fractal.py Normal file
View File

@@ -0,0 +1,27 @@
import turtle
MINIMUM_BRANCH_LENGTH = 5
def build_tree(t, branch_length, shorten_by, angle, c):
if branch_length > MINIMUM_BRANCH_LENGTH:
t.pendown()
t.color(c)
t.forward(branch_length)
new_length = branch_length - shorten_by
t.left(angle)
build_tree(t, new_length, shorten_by, angle, "#8a1cff")
t.right(angle * 2)
build_tree(t, new_length, shorten_by, angle, "#ff7e1c")
t.left(angle)
t.penup()
t.backward(branch_length)
tree = turtle.Turtle()
tree.hideturtle()
tree.speed(0)
tree.setheading(90)
tree.color('green')
turtle.bgcolor("black")
build_tree(tree, 40, 3, 15, "red")
turtle.mainloop()

73
Python/fib.py Normal file
View File

@@ -0,0 +1,73 @@
import turtle
import math
turtle.colormode(255)
fac = .01
a=0
b=1
sqr = math.sqrt(5)
c= 1/sqr
d= (1+sqr)/2
e = (1-sqr)/2
j = 10
j_max = 30
turtle.bgcolor("black")
def fibb(t, col):
global b
global j
global j_max
global c
global d
global e
coll = math.radians(col)
print(col)
print(255*coll)
print(round(255*coll))
if coll >1:
coll = 1
if coll <0:
coll = 0
t.pencolor((round(255* coll),0,192))
for j in range(10, j_max):
f=math.pi * b * fac /2
f /= 90
for i in range(90):
turt.forward(f)
turt.left(1)
b = c * ((d**j)- (e**j))
t.penup()
turt = turtle.Turtle()
turt.speed(0)
for ang in range(360):
turt.setx(0)
turt.sety(0)
turt.left(1)
turt.pendown()
a=0
b=1
print(ang)
if ang>179:
ang = ang - 179
fibb(turt, ang)
cv = turt.getcanvas()
cv.postscript(file="file_name.ps", colormode='color')
turtle.done()

2
Python/python notes.txt Normal file
View File

@@ -0,0 +1,2 @@
https://stackoverflow.com/questions/16119991/how-to-speed-up-pythons-turtle-function-and-stop-it-freezing-at-the-end
used to speed up image, but wont be able to see animation