# Turtle graphics and world boundaries

**URL:** <https://forum.netlogo.org/t/turtle-graphics-and-world-boundaries/895>\
**Category:** Programming Q&A\
**Created:** [November 12, 2026, 1:53pm UTC](https://forum.netlogo.org/t/turtle-graphics-and-world-boundaries/895 "2026-11-12T13:53:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrkramer\_wageningen](https://forum.netlogo.org/letter_avatar_proxy/v4/letter/m/f4b2a3/32.png) [@mrkramer\_wageningen](https://forum.netlogo.org/u/mrkramer_wageningen)\
**Post date:** [November 12, 2026, 1:53pm UTC](https://forum.netlogo.org/t/turtle-graphics-and-world-boundaries/895/1 "2026-11-12T13:53:54Z")

</div>

While cleaning up old code in Python, I found some examples using turtle graphics.

Naturally, I thought I could redo these in NetLogo.  
It turns out that NetLogo is orders of magnitude faster than Pythons `turtle` module.  
However, there is a problem with boundaries of the drawing.

When turtle graphics in Python (and other languages) moves out of the visible area, it just does not draw as long as the turtle is outside boundaries.  
I would like to see the same – or similar – behavior in NetLogo. However, with world wrapping on, the drawing wraps (what else?). When world wrapping is off, the turtle bumps into the world boundaries and any structure of the drawing is lost.

See this small example, converted from a Python example.

[koch-curve.nlogox](https://forum.netlogo.org/uploads/short-url/kBk684WeLNYnxoQ0Zj60mc6BL74.nlogox) (3.9 KB)

Now the question is: how could we let NetLogo turtles draw only when (non-wrapped) in the visible area?  
Probably, we would need world wrapping on and suppress drawing (`penup`) while its coordinates are wrapped.  
Any ideas, even ignoring special cases, are welcome.

---

<div class="post-metadata">

**Author:** ![ERSUCC](https://forum.netlogo.org/letter_avatar_proxy/v4/letter/e/bbe5ce/32.png) [@ERSUCC](https://forum.netlogo.org/u/ERSUCC)\
**Post date:** [November 12, 2026, 4:29pm UTC](https://forum.netlogo.org/t/turtle-graphics-and-world-boundaries/895/2 "2026-11-12T16:29:00Z")

</div>

I agree that this functionality could be useful. I can think of a way to do this currently, although it’s a bit hacky. If you keep track of each turtle’s “real” unwrapped coordinates by manually calculating turtle positions, you can then have a check like this each tick:

```netlogo
if-else real-x < min-pxcor or real-y < min-pycor or real-x > max-pxcor or real-y > max-pycor [
  hide-turtle
  pen-up
] [
  show-turtle
  pen-down
]

```

The problem with this method is that you would need to manually replicate the behavior of primitives like `fd` and `bk` to ensure that your `real-x` and `real-y` values are properly synced with the turtle’s wrapped coordinates. I would definitely be in favor of a built-in unwrapped and unbounded world mode, but we’ll see what other people think. It would probably make the logic for drawing trails a bit more complex, but I don’t think it would be undoable.

---

<div class="post-metadata">

**Author:** ![jzkelter](https://forum.netlogo.org/letter_avatar_proxy/v4/letter/j/a5b964/32.png) [@jzkelter](https://forum.netlogo.org/u/jzkelter)\
**Post date:** [November 12, 2026, 8:51pm UTC](https://forum.netlogo.org/t/turtle-graphics-and-world-boundaries/895/3 "2026-11-12T20:51:12Z")

</div>

I think this extension could be used for this, but would need to look further and it probably needs to be updated for NetLogo 7: [GitHub - qiemem/inf-extension: An infinite topology extension for NetLogo · GitHub](https://github.com/qiemem/inf-extension)

---

<div class="post-metadata">

**Author:** ![ERSUCC](https://forum.netlogo.org/letter_avatar_proxy/v4/letter/e/bbe5ce/32.png) [@ERSUCC](https://forum.netlogo.org/u/ERSUCC)\
**Post date:** [November 12, 2026, 10:46pm UTC](https://forum.netlogo.org/t/turtle-graphics-and-world-boundaries/895/4 "2026-11-12T22:46:09Z")

</div>

@mrkramer_wageningen I updated the Inf extension mentioned above to work with the latest version of NetLogo, and it appears to solve your problem very effectively! It will be available in the extension manager along with the upcoming release of NetLogo 7.1. You can also download the alpha release of 7.1 [here](https://www.netlogo.org/preview), which should give you access to the extension now.

---

<div class="post-metadata">

**Author:** ![mrkramer\_wageningen](https://forum.netlogo.org/letter_avatar_proxy/v4/letter/m/f4b2a3/32.png) [@mrkramer\_wageningen](https://forum.netlogo.org/u/mrkramer_wageningen)\
**Post date:** [November 13, 2026, 10:21am UTC](https://forum.netlogo.org/t/turtle-graphics-and-world-boundaries/895/5 "2026-11-13T10:21:19Z")

</div>

Well, this is more than I expected. I am going to check it.

Thank you Jacob and Isaac!

---

<div class="post-metadata">

**Author:** ![mrkramer\_wageningen](https://forum.netlogo.org/letter_avatar_proxy/v4/letter/m/f4b2a3/32.png) [@mrkramer\_wageningen](https://forum.netlogo.org/u/mrkramer_wageningen)\
**Post date:** [November 13, 2026, 11:35am UTC](https://forum.netlogo.org/t/turtle-graphics-and-world-boundaries/895/6 "2026-11-13T11:35:10Z")

</div>

Marvelous!

Just a few changes and it works!  
Even regardless of world wrapping.

[koch-curve-inf.nlogox](https://forum.netlogo.org/uploads/short-url/93hTQ5abvoNkTyRw5xlbAOA0uZC.nlogox) (3.8 KB)

Thank you
