# Debug-Draw - Lines, boxes, circles, etc

**URL:** <https://forum.defold.com/t/debug-draw-lines-boxes-circles-etc/61393>\
**Category:** The Defoldmine\
**Created:** [August 27, 2019, 7:12pm UTC](https://forum.defold.com/t/debug-draw-lines-boxes-circles-etc/61393 "2019-08-27T19:12:13Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![ross.grams](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/r/cab0a1/32.png) [@ross.grams](https://forum.defold.com/u/ross.grams)\
**Post date:** [August 27, 2019, 7:12pm UTC](https://forum.defold.com/t/debug-draw-lines-boxes-circles-etc/61393/1 "2019-08-27T19:12:14Z")

</div>

I made a little module of convenience functions to help draw lines, shapes, and text for visual debugging. The render [“draw\_line”](https://www.defold.com/ref/render/#draw_line:start_point-end_point-color) and [“draw\_text”](https://www.defold.com/ref/render/#draw_text:position-text) messages are really long and cumbersome to type, so this wraps them up and makes things simple. It’s not an exhaustive shape-drawing library, just enough to draw a few different kinds of indicators and things.

 ![debug-draw_rabid-robots_screenshot](https://forum-defold.b-cdn.net/uploads/default/original/3X/9/8/98059b5a7086eebbfb2c9b50084f32fa64e2c0c8.png)

You can use it as a library dependency with the following link, or just grab the lua file and drop it in your project wherever suits you.

> [https://github.com/rgrams/debug-draw/archive/master.zip](https://github.com/rgrams/debug-draw/archive/master.zip)

See the Readme on github for documentation (though it’s all pretty straightforward).

> **[GitHub - rgrams/debug-draw: A set of convenience functions for drawing debug...](https://github.com/rgrams/debug-draw)**
>
> A set of convenience functions for drawing debug lines, shapes, and text with Defold.

---

<div class="post-metadata">

**Author:** ![Pawel](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pawel/32/24623_2.png) [@Pawel](https://forum.defold.com/u/Pawel)\
**Post date:** [August 29, 2019, 8:20am UTC](https://forum.defold.com/t/debug-draw-lines-boxes-circles-etc/61393/2 "2019-08-29T08:20:46Z")

</div>

Add it to our asset portal, it’s great and convenient 😃

---

<div class="post-metadata">

**Author:** ![ross.grams](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/r/cab0a1/32.png) [@ross.grams](https://forum.defold.com/u/ross.grams)\
**Post date:** [August 29, 2019, 10:16am UTC](https://forum.defold.com/t/debug-draw-lines-boxes-circles-etc/61393/3 "2019-08-29T10:16:12Z")

</div>

Yeah I know. 😛 Since the dashboard’s going to be removed and the asset portal shuffled around in a few weeks I figured I might as well wait.

---

<div class="post-metadata">

**Author:** ![Ragetto](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/ragetto/32/32785_2.png) [@Ragetto](https://forum.defold.com/u/Ragetto)\
**Post date:** [December 24, 2020, 12:20pm UTC](https://forum.defold.com/t/debug-draw-lines-boxes-circles-etc/61393/4 "2020-12-24T12:20:10Z")

</div>

Hello!

I just discovered your library, it looks soooo convenient!

I just followed the instructions here ([Working with library projects in Defold](https://defold.com/manuals/libraries/)), but… can’t make it work ☹

The library seems to be properly installed:  
 ![debugdraw001](https://forum-defold.b-cdn.net/uploads/default/original/3X/5/5/55e283a145e24566e5748749044dcb0b7bb4d501.png)

But this simple line…  
`debugdraw.circle(100,100,100)` (in the “update” function)

… generates an error message:  
 ![debugdraw002](https://forum-defold.b-cdn.net/uploads/default/original/3X/3/b/3b89d875b56dadd18e805f1b374f65558d4e8ea1.png)

Did I miss something?

Rag’

---

<div class="post-metadata">

**Author:** ![Mathias\_Westerdahl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mathias_westerdahl/32/228_2.png) [@Mathias\_Westerdahl](https://forum.defold.com/u/Mathias_Westerdahl)\
**Post date:** [December 24, 2020, 12:30pm UTC](https://forum.defold.com/t/debug-draw-lines-boxes-circles-etc/61393/5 "2020-12-24T12:30:43Z")

</div>

How do you “require” the Lua module?

---

<div class="post-metadata">

**Author:** ![Ragetto](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/ragetto/32/32785_2.png) [@Ragetto](https://forum.defold.com/u/Ragetto)\
**Post date:** [December 24, 2020, 1:29pm UTC](https://forum.defold.com/t/debug-draw-lines-boxes-circles-etc/61393/6 "2020-12-24T13:29:02Z")

</div>

`require "debug-draw.debug-draw"`

1st line of the same script

🤔

---

<div class="post-metadata">

**Author:** ![Mathias\_Westerdahl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mathias_westerdahl/32/228_2.png) [@Mathias\_Westerdahl](https://forum.defold.com/u/Mathias_Westerdahl)\
**Post date:** [December 24, 2020, 1:32pm UTC](https://forum.defold.com/t/debug-draw-lines-boxes-circles-etc/61393/7 "2020-12-24T13:32:49Z")

</div>

Then you’ll get the variable “debug-draw”, and not the “debugdraw” as you wrote.

Try this instead:

```lua
local debugdraw = require("debug-draw.debug-draw")

```

---

<div class="post-metadata">

**Author:** ![Ragetto](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/ragetto/32/32785_2.png) [@Ragetto](https://forum.defold.com/u/Ragetto)\
**Post date:** [December 24, 2020, 1:48pm UTC](https://forum.defold.com/t/debug-draw-lines-boxes-circles-etc/61393/8 "2020-12-24T13:48:59Z")

</div>

Oh ok… As you expected, it works 🙂

Thank you very much Ross for this super useful library, and Mathias for the help!

---

<div class="post-metadata">

**Author:** ![ross.grams](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/r/cab0a1/32.png) [@ross.grams](https://forum.defold.com/u/ross.grams)\
**Post date:** [December 25, 2020, 6:08pm UTC](https://forum.defold.com/t/debug-draw-lines-boxes-circles-etc/61393/9 "2020-12-25T18:08:56Z")

</div>

Thanks Mathias for helping out. I’ve added a line about this to the readme.

---

<div class="post-metadata">

**Author:** ![Pkeod](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pkeod/32/606_2.png) [@Pkeod](https://forum.defold.com/u/Pkeod)\
**Post date:** [January 20, 2026, 10:55pm UTC](https://forum.defold.com/t/debug-draw-lines-boxes-circles-etc/61393/10 "2026-01-20T22:55:47Z")

</div>

[debug-draw.zip](https://forum.defold.com/uploads/short-url/hPvb5Hr0oOljBdKZBaaAcJxsKsm.zip) (12.6 KB)

Updated version with more features and a nice animated demo! @ross.grams If you’re interested in updating the main repo version still please do.

 ![debug-draw](https://forum-defold-uploads.b-cdn.net/original/3X/3/7/3722dbdb01c9eecb29f71246b53292b0e8163dfa.png)

---

<div class="post-metadata">

**Author:** ![roccosaienz](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/roccosaienz/32/19991_2.png) [@roccosaienz](https://forum.defold.com/u/roccosaienz)\
**Post date:** [February 28, 2026, 2:01pm UTC](https://forum.defold.com/t/debug-draw-lines-boxes-circles-etc/61393/11 "2026-02-28T14:01:54Z")

</div>

First of all, thanks for the demo! Really nice!

I don’t know if this is a known issue or it is an issue only on my mac. But text is not aligned with the other graphic elements. It seems like text is not behaving well with window size changing. Here is a screenshot:

 ![Screenshot 2026-02-28 alle 15.01.06](https://forum-defold-uploads.b-cdn.net/original/3X/2/0/20ad2b17c4ee5950466eb5e0cdd728556ddb527a.png)

---

<div class="post-metadata">

**Author:** ![Pkeod](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pkeod/32/606_2.png) [@Pkeod](https://forum.defold.com/u/Pkeod)\
**Post date:** [February 28, 2026, 2:40pm UTC](https://forum.defold.com/t/debug-draw-lines-boxes-circles-etc/61393/12 "2026-02-28T14:40:00Z")

</div>

Demo is meant for demonstration so not really an issue. You can position debug draw text however you want but for a real game you want to use labels / gui text anyway.

---

<div class="post-metadata">

**Author:** ![roccosaienz](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/roccosaienz/32/19991_2.png) [@roccosaienz](https://forum.defold.com/u/roccosaienz)\
**Post date:** [February 28, 2026, 3:13pm UTC](https://forum.defold.com/t/debug-draw-lines-boxes-circles-etc/61393/13 "2026-02-28T15:13:21Z")

</div>

Yes, of course, this is only for debug.

I like this demo so much and, in my opinion, it is a pity that the labels haven’t the correct positions. Just this.

Thanks again!

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [March 1, 2026, 1:48pm UTC](https://forum.defold.com/t/debug-draw-lines-boxes-circles-etc/61393/14 "2026-03-01T13:48:02Z")

</div>

> [@roccosaienz](#):
>
> I like this demo so much and, in my opinion, it is a pity that the labels haven’t the correct positions. Just this.

The fix is to apply the display scale:

```lua
function M.text(text, x, y, color)
	local scale = window.get_display_scale()
	color = color or M.default_color
	if M.COLORS[color] then color = M.COLORS[color] end
	V1.x, V1.y = x * scale, y * scale
	TEXTMSGDATA.text, TEXTMSGDATA.position, TEXTMSGDATA.color = text, V1, color
	msg.post("@render:", "draw_debug_text", TEXTMSGDATA)
end

```

The display scale should obviously be cached and not called every time.
