[R] "Turtle world" graphics in R

Barry Rowlingson B.Rowlingson at lancaster.ac.uk
Tue Oct 14 16:27:59 CEST 2003


Gabriel Baud-Bovy wrote:

> I "erase" the turtle be 
> redrawing
> it with the same color as the background but that does not look good as it
> also erases everything ese. I tought of using large matrix (e.g 
> 1000x1000) as
> a representation of the turtle world and displaying it with contour() 
> but it is slow
> to update after each user command.
> 

  R's graphics aren't really designed for moving graphics, or undrawing 
things.

  Perhaps you can use the tcltk library, you could draw on a tk canvas. 
This would be much more suited to turtle graphics.

  If you want to get the turtle track back into R once the turtle has 
finished its wanderings then you can probably read the path from the Tk 
canvas widget into R using the tcltk library.

  Or you may want to use python, instead of R:
http://www.python.org/doc/current/lib/module-turtle.html

  Or you may want to use Perl instead or R:
http://home.hccnet.nl/kees.moerman/turtle.html

  Both these systems use Tk as their graphics output.

  I wrote some turtle-graphics subroutines for the ZX Spectrum about 20 
years ago :)

  Baz




More information about the R-help mailing list