Closed JoseRFJuniorLLMs closed 3 years ago
Hi,
The Wikipedia example uses the native Turtle library of Python. This turtle library that I created have few differences from the native library. I checked the code on Wikipedia link that you shared and adapted it to work with this library. The code would go as follows:
from ColabTurtle.Turtle import *
import random
initializeTurtle()
speed(8)
color("green")
width(2)
penup()
x = 0
y = 0
for n in range(110000):
goto(65 * x + 350, -37 * y + 410)
pendown()
forward(0.2)
backward(0.2)
penup()
r = random.random()
r = r * 100
xn = x
yn = y
if r < 1:
x = 0
y = 0.16 * yn
elif r < 86:
x = 0.85 * xn + 0.04 * yn
y = -0.04 * xn + 0.85 * yn + 1.6
elif r < 93:
x = 0.20 * xn - 0.26 * yn
y = 0.23 * xn + 0.22 * yn + 1.6
else:
x = -0.15 * xn + 0.28 * yn
y = 0.26 * xn + 0.24 * yn + 0.44
I tried this and could create the fractal; however, the network started to be a bottleneck where 110000 points had to be displayed, and the browser started to hang. but it at least works to some extend :)
This library does not have dot()
function, so I accomplished the same effect with going forward and backward.
Alternatively, you can use write('•', align="center")
rather than forward and backward, this could work faster because it will use one network call to draw one dot.
https://en.wikipedia.org/wiki/Barnsley_fern https://colab.research.google.com/drive/1U54ZMdpNDzMP39m1xT2tDAPdiBpz59_1?usp=sharing
Estou tentando fazer funcionar esse exemplo da wikipidia no colab, porem mudou as funcoes da biblioteca, pode ajudar ?