Send Close Add comments: (status displays here)
Got it!  This site "robinsnyder.com" uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.  Note: This appears on each machine/browser from which this site is accessed.
Python: Turtle graphics and rsTurtle module
by RS  admin@robinsnyder.com : 1024 x 640


1. Python: Turtle graphics and rsTurtle module
I have always found it useful, in addition to creating a custom class for canvas drawing, to create a set of turtle graphics commands.

For simplicity, there are no routines provided for viewport, scale, transform, rotate, or pushing or popping transformation matrices.

2. rsTurtle module
The rsTurtle module contains the turtle class that subclasses the canvas class in the rsCanvas module.

The various methods of the turtle class are now presented and discussed.

3. Initializer
The initializer calls the super class canvas and then sets some instance variables.


4. Up



5. Down



6. Absolute turn



7. Relative turn



8. Move



9. Draw
The draw method draws the current points, if needed.


10. rsTurtle module
Here is a code module in Python [module rsTurtle in rsTurtle.py].


11. Fractal routine
Here is a fractal routine to draw a Koch coastline.


12. Degrees
Here is the code to draw 6 levels of Koch coastline.


13. Setup code
Here is the setup code.

The stub is set in the main code.

14. Program
Here is the Python code [#12]


15. Output
Here is the output of the Python code.


16. Image #1
Fractal

17. Image #2
Fractal

18. Image #3
Fractal

19. Image #4
Fractal

20. Image #5
Fractal

21. Image #6
Fractal

22. End of page

by RS  admin@robinsnyder.com : 1024 x 640