Work inside google colab

未关闭
#33 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
r

调研方向

在 Google Colab 中通过反复调用 .turtle_undraw() 重现该行为,然后阅读 .turtle_undraw() 和 .turtle_draw() 的实现,并比较 grid.remove() 如何处理 redraw=FALSE。完成的标准是:移除 turtle 时不会在每次调用时创建新的图形区域,即使在反复绘制和取消绘制之后也是如此。

由索引模型根据 Issue 内容生成。

描述

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!

主要语言
HTML
星标
23
派生
10
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

gagolews/TurtleGraphics 的其他 Issue

查看 gagolews/TurtleGraphics 的全部 Issue

相似的 Issue

更多 Computer Graphics Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。