Expose debug line, curve, and circle rendering

Post Reply
Posts: 27
Joined: Sun Feb 11, 2018 7:10 pm

Expose debug line, curve, and circle rendering

Post by Boodals » Thu Aug 02, 2018 5:33 am

I would like access to the rendering of lines, curves, and circles that are visible in the various debug options.

(on a closer look, it seems like the curves/circles may actually just be multiple lines. Ideally i'd want to be able to draw perfect curves/circles, but it isn't super important)

I want to use this to draw a solar system, with filled in circles for each planet/moon/asteroid, and empty circles for the orbital path.
My work around at the moment is generating around 500 circle sprite prototypes, each with a slightly different scale, and every frame checking if they are the correct size, and if not deleting and replacing them. Needless to say, this is incredibly inefficient, ugly, and stupid. There may be ways to optimize this, but it is still a bad work around.

The GUI has a camera onto a surface with out-of-map tiles. I do not use camera.zoom because that would also scale the line thickness, and prevent me doing things like having a minimum size for the planet icons. If I had the functions requested, I could use camera.zoom, because the debug lines are fixed width in screen space, and I would have more control over the size of the icons.
Ok, it's a pretty janky use case, but this request would make it 10x less janky.
Another mod that does something similar is the Underground Indicators mod. It creates a bunch of sprites to show the possible end points of underground belts/pipes.
Additional uses: Debugging positions/vectors visually, indicating areas to players, custom highlighting of entities. idk, there's a lot of uses.

Rseding said on stream that the main difficulty would be how to expose these in a useful way. He said they would need to be called every tick. I would personally be fine with this, because I need to update every tick anyway. But an optional time parameter could be used so that you could call it every on_nth_tick to improve performance.

Function proposals:
surface.DrawLine(startPosition, endPosition, color=white, thickness=1, time=1 (in ticks))
surface.DrawCurve(startPosition, endPosition, angle (degrees or radians), color=white, thickness=1, time=1 (in ticks))
surface.DrawCircle(centerPosition, radius, lineColor=white, lineThickness=1, fillColor=transparent, time=1 (in ticks))
The various optional parameters could be included in a table so that you can omit any of them if you wanted to use the defaults.

Similar functions that exist in a GUI (instead of on a surface) would also be useful, so that I don't have to have a camera in the GUI. Could be used for indicating certain GUI elements, like a tutorial? idk.
Last edited by Boodals on Sun Nov 25, 2018 9:38 pm, edited 1 time in total.

Factorio Staff
Factorio Staff
Posts: 8207
Joined: Wed Jun 11, 2014 5:23 am

Re: Expose debug line, curve, and circle rendering

Post by Rseding91 » Sat Aug 11, 2018 7:09 am

If I find time I'll look into adding support for this at least drawing them in the world.
If you want to get ahold of me I'm almost always on Discord.

User avatar
Factorio Staff
Factorio Staff
Posts: 1161
Joined: Sat Aug 13, 2016 9:20 am

Re: Expose debug line, curve, and circle rendering

Post by Bilka » Fri Jan 04, 2019 6:09 pm

I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Post Reply

Return to “Implemented mod requests”

Who is online

Users browsing this forum: No registered users and 0 guests