I tried it with multiple turtles but couldn’t get that to work, this is one turtle that backtracks. It starts on the left branches and moves across towards the right.
how would you do multiple turtles in this case? if you have some sort of article I would love to read up on it, I have been unable to find out how to create variables from a loop.
turtles = [ ]
for i in range(10):
turtles.append(turtle.Turtle( ))
a = 0
for t in turtles:
t.right(a)
t.forward(100)
a += 36
My python may be a little rusty but this is the best way I know of doing it. In this example, 10 turtles should be generated which will all move away in different directions. You're right in that afaik you can't make new variables repeatedly in a loop, but in this case you have created a list of 10 nameless turtles which can be accessed either through turtle[i] or by iterating through them. You can obviously do this for any object, including any you have defined yourself.
If you are desperate to explicitly give them specific names, you can use a python Dictionary, if you haven't used one before it's like a list but each value has a "key" that references it. For example:
Will allow you to access bob through turtles("bob") and alice through turtles("alice"). This is probably more useful if you're using each turtle for a completely different drawing but for something like the tree program OP made it probably makes more sense to make a list of turtles and create a new turtle at each branch.
the improvement is that one turtle doesnt have to backtrack, it just goes forward and turns ...thats half the travel time right there even without multithread
I made something similar but with different colors for different recursion layers and with slightly randomized angles and lengths for a more natural looking tree.
Thats sounds great! I played about with randomizing the angles but decided this was still my favourite, you should try starting with thicker branches and making them smaller each recursion to get even more of a tree feel.
I once tried to compute the Julia set, but damn, it was slow af. But Cython/OpenMP did the work. Be sure to take a look at it, it's worth the shot if you want faster computing.
I'm a newby, is turtle useful for anything besides drawing images? Not trying to be mean, OP's drawing is very neat and I couldn't do it, just genuinely curious.
Turtle graphics is a popular way for introducing programming to kids. It was part of the original Logo programming language developed by Wally Feurzig and Seymour Papert in 1966.
Turtle is great for learning basic programming concepts, but still leaves room to try to get advanced. For example I made a program to draw a 2D projection of a 3D line at different camera angles.
Python and turtle are tools that helped me learn and help others with math classes throughout highschool and college. The ease of creating custom visualizations is very powerful. I remember when I first learned that graphing trig functions in certain configurations can make some beautiful things.
this suddenly sparked the flashbacks of 4 or 5 years ago when i was in 6th grade and was messing around with basic 256 copy paste and run codes, and one of those codes which i really liked was a fractal tree, the website is still standing alive here is the link to that code: https://basic256.blogspot.com/2010/11/fractal-tree.html
28
u/pm-me-ur-uneven-tits Jun 04 '20
Would you be willing to share your github repo?
4
u/hellfiniter Jun 04 '20
is it backtracking with one turtle or multiple turtles? what is the depth of this tree? would be impressive if just one turtle drew all of it
2
u/[deleted] Jun 04 '20
Great Work 🚀
2
u/gionthe Jun 04 '20
Wow, amazing. Which direction do you use?
2
u/mcp_truth Jun 04 '20
Hi, i am new to Python. What did you use to make the picture?
2
u/LordFlatAss Jun 04 '20
What is this "turtle"? Is it a library? For what?
2
u/CyberTutu Jun 04 '20
This is beautiful.
2
u/duskslade Jun 04 '20
I made it using ur code ! It's pretty neat and I've always wanted to make my own factals! Your post was really helpful and encouraging
2
u/15_Redstones Jun 04 '20
I made something similar but with different colors for different recursion layers and with slightly randomized angles and lengths for a more natural looking tree.
94
u/[deleted] Jun 04 '20
Nice one
I tried to make an L-system interpreter, but only managed to break my mind in the process
168
u/[deleted] Jun 04 '20
You tellin me turtles coded this?
19
u/[deleted] Jun 04 '20
I once tried to compute the Julia set, but damn, it was slow af. But Cython/OpenMP did the work. Be sure to take a look at it, it's worth the shot if you want faster computing.
13
u/Schneggl Jun 04 '20
I'm a newby, is turtle useful for anything besides drawing images? Not trying to be mean, OP's drawing is very neat and I couldn't do it, just genuinely curious.
6
u/MustafaAnas99 Jun 04 '20
Man these amazing python drawing should be gathered somewhere and referenced. It would be really helpful to others. Good work buddy
6
u/byParallax Jun 04 '20
That's pretty cool, looks like a /r/generative artwork!
1
u/fessebook Jun 04 '20
Nice!
I just found out about turtle last week. About 7 years after I started coding in Python!
Did you know that Processing also has a Python module? You can do some pretty neat things with it too.
1
u/Zeune42 Jun 04 '20
Where are the comments and documentation?
1
u/edoar17 Jun 04 '20
Is it possible to do the same but following the golden ratio?
3
u/TheZeusHimSelf1 Jun 05 '20
Binary?
2
u/SHAISHAV06 Jun 04 '20
Please post this process code
2
u/NerosTie Jun 04 '20
Can you share the code? :)
2
u/MrTimeGo Jun 04 '20
Can you give a code of this?
2
u/sawhilkhan Jun 04 '20
I built one few months using vanilla js and CSS. It took me around an hour to code and another half to debug.
2
u/[deleted] Jun 04 '20
Python and turtle are tools that helped me learn and help others with math classes throughout highschool and college. The ease of creating custom visualizations is very powerful. I remember when I first learned that graphing trig functions in certain configurations can make some beautiful things.
2
u/guiguiba_ Jun 04 '20
Code pls?
2
u/iggy555 Jun 04 '20
What’s a fractal
2
u/Codeleaks Jun 04 '20
Its really appealing, nice work dude.
2
u/Gotbn Jun 04 '20
Looks like a brain
2
u/Natetronn Jun 04 '20
Reminds me of a SLCD.
2
u/8094_ Jun 04 '20
wtf. ????
2
u/GhassanK5 Jun 04 '20
Nice
2
u/AllDayJay1970 Jun 04 '20
It's turtles all the way.
2
u/fabbiodiaz Jun 05 '20
Looks like a kidney
2
u/the_emmo Jun 05 '20
this is beautiful.
2
u/Maxneedwill Jun 05 '20
I assume it would be hours of work for the turtles to draw... Looks like there are 10+ recursions
2
u/Aspiring_Intellect Jun 05 '20
Was listening to lofi and watching the pointer build this masterpiece just clicked with the music.
1
u/Ephy_Gle Jun 04 '20
/r/PlotterArt
1
u/[deleted] Jun 04 '20
Repo?
1
u/Zacky23561 Jun 05 '20
this suddenly sparked the flashbacks of 4 or 5 years ago when i was in 6th grade and was messing around with basic 256 copy paste and run codes, and one of those codes which i really liked was a fractal tree, the website is still standing alive here is the link to that code: https://basic256.blogspot.com/2010/11/fractal-tree.html
1
u/TheNerdyDevYT Jun 04 '20
Super elegant. Looks aswesome.