gagolews / gagolews/TurtleGraphics

Work inside google colab

Open
#33 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
HTML
Stars
23
Forks
10
PR merge metrics
No merged PRs in 30d

Description

Hi,

Would it be possible to make the package work correctly inside google colab? The problem I noticed (there may be others) is that `.turtle_undraw()` uses `grid.remove()`, which causes colab to create a new graphic area at every call. I tried to change `.turtle_undraw()`:

```
.turtle_undraw <- function()
{
grid.remove("turtle_head", redraw=FALSE)
grid.remove("turtle_body", redraw=FALSE)
grid.remove("turtle_leg1", redraw=FALSE)
grid.remove("turtle_leg2", redraw=FALSE)
grid.remove("turtle_leg3", redraw=FALSE)
grid.remove("turtle_leg4", redraw=FALSE)
invisible(NULL)
}
```

But this does not remove/undraw the turtle. Eliminating `redraw=FALSE` from just the last line does remove/undraw the turtle and reduces the number of bogus graphic areas, but that is not a solution.

As a workaround, I eliminated the turtle image completely:

```
library("TurtleGraphics")
fakedraw <- function() {invisible(NULL)}
environment(fakedraw) <- asNamespace('TurtleGraphics')
assignInNamespace(".turtle_draw",fakedraw, ns="TurtleGraphics")
assignInNamespace(".turtle_undraw",fakedraw, ns="TurtleGraphics")
turtle_init()
```

which is obviously not great but apparently works ok, at least for simple stuff.

Thanks!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.