Nice addition. noLoop() should save it from being overdrawn which was the main reason I was using recursion. A simple loop is less code and appears to work just as well. Thanks for telling us.
TG has two tasks called circle
and oval
that can be used to draw polygons. This sketch shows TG creating six polygons with 3-8 sides.
You can see the code here
To see my collection of TG examples click here
Shouldn’t this turtle library be in the “Gallery” category instead like others before?
Nice work on this project!
I did something similar here in my effort to draw a Fractal tree one line at a time:
:)
@glv I saw your fractal tree example and gave it a at the time. It was your post that gave me the idea of trying my hand at creating a turtle graphics library.
The original turtle graphics was created in the late 1960s and included into the Logo programming language. It was designed to control an actual robot that held a pen. I wanted something that showed the turtle’s path as it moved.
I first learned about Turtle Graphics when @winterchan inquired about the Harriss spiral:Generate the Harriss Fractal in this forum. When I researched it TurtleGraphics was one of the ways it was first drawn and I was impressed at how something so complicated could be drawn by something so simple. That technique inspired the work that I have posted here and has been ported to other languages: https://rosettacode.org/wiki/Harriss_Spiral , which brings me to my next question: Would you be able to draw a Harriss Fractal with your new creation?
To be honest I am not certain.
I did see the discussion about the Harriss spiral . The example in the first link (gif image) and the code examples in the second link all create and display the spiral as a single step. The animation in the gif is due to changing the initial starting values and the depth of recursion.
Using TG would require the spiral gradually ‘grow’ from nothing which is a much more challenging problem.
I will have to give it more thought
The code sample is incomplete - I found this at https://wiki.secretgeek.net/harriss-spiral
I’d be interested to know if you can find a non web based, stand-alone editor that will run this code. In my experience it usually has to be modified a little to run in more recent editors. The website has a ‘run’ button, but it has a few problems at the ‘slow’ speed (‘faster’ speeds look ok). Nonetheless if you have a few minutes to watch the turtle draw in slow motion it gives insight into the technique used. The turtle advances in a straight line in successively shorter distances after heading changes and ninety degree arcs are drawn in reverse, ie endPt to startPt for that segment.
Output for reference slow speed:
I have moved this discussion because it doesn’t really fit any single p5js category. Unfortunately the category descriptions are simple one liners that don’t give real guidance.
I started this topic to give users a chance to play with the library and highlight any issues or enhancements or ideas that might improve the library or its documentation. I am happy with the way the discussion is going because the feedback shows how users might want to use the library, I am already thinking about adding a spiral
task
The examples I have provided are not really gallery items, I created them to test different features of the library and I included them to encourage users to try it out so I could get feedback.
Testing has not revealed any bugs so far but I am still working on the github documentation. When it is complete I will make a formal release announcement in the library topic and submit it to Processing to be accepted as a contributed library.
As for the Harriss spiral, I will have a go at recreating it using this library and if I succeed then it will be posted as a gallery item.
Thanks for all your posts and keep them coming.
There’s also sub-category “Development” for asking about howtos & tips to develop 3rd-party libraries and addons for Processing.
Here are the three categories and their descriptions
p5.js
- Discussions about p5.js programs and development
p5.js >> Development
- How to develop p5.js and p5.js Libraries
p5.js >> libraries
- Questions and discussions about p5.js Libraries
It seems to me that there is justification to have this discussion in any of these categories >> sub-categories. It all depends on what is meant by “p5.js Libraries” (notice the capital L). The description for the development sub category makes me think that it relates only those libraries approved by p5js for inclusion on the website.
Turtle Graphics is already a library, the only thing lacking is in the area of documentation and examples so hasn’t yet been submitted to p5.js
It seems to me that the current category, p5.js is just fine for this discussion and that we have moved seriously off-topic so can we drop this please.
For those reading this discussion I am hoping you might try out Turtle Graphics and let me know how you got on with it…
Thanks in advance for any comments, ideas … related turtle graphics in general and this library in particular.
Any way to make that UserGuide a .pdf?
Does the library have ‘arc’; I couldn’t find it.
An arc is simply a part of the circumference of a circle or ellipse. The circle(...)
and oval('...')
both have a parameter called extent
which specifies the length of arc in degrees.
A very good question - there are tools out there to convert html to pdf I will investigate when I get a chance.
There are many tools to convert the html to pdf but the best ones and not free. The best free option is html2pdf but for such a large web page the pdf created was huge (65Mb) and the text size was massive for the page.
I had to add a small additional feature to the library to make it possible - but now I have solved it
You can see it here