Allow developers to draw 2D Polygons with UI Instances

Currently as a developer its hard to draw a UI polygon, whilst one can do this using triangle images it’ll lead to weird gaps. One could also do a trick with UI Stroke, but that’s limited to perfectly square triangles so its very limited in what it can be used for.

UI Polygons would be useful for making maps, like interior maps like in fallout 4:


Although I doubt most devs would be rendering maps as detailed as Fallout 4’s. UI polygons would still be useful for rendering rooms that dont have all their walls at 90 degrees.
More specifically they’d be useful for rendering the floors of the rooms, as the walls can be easily handled currently via Path2D.

Some questions on this feature request:

  • I assume you mean filled polygons, for the most part - since otherwise Path2D should handle this in theory?

  • Do you expect anti-aliasing on those polygons, or is hard edges sufficient.

  • Do you have any opinions on the API? See Path2D for an example of how we might support it.

  • Do you have any requirements for winding rules (nonzero, even odd) or multi-contour support (holes/cutouts)

Thanks!

Yes.

Hard edges would suffice for my uses in mind, but I’d imagine others would want anti aliasing especially if they’re looking to do more high detail things like 2D water.

Path2D’s API is nice, except requiring control points to be given for everything is annoying when you want to just draw straight lines. So it’d be nice to have APIs that wrap around the creation of control points for drawing straight lines:

-- index argument would be optional similar to table.insert()
Polygon:InsertPoint(vector.one, index)
Polygon:InsertPath(points, index)

Additionally having separate ‘angular’ and ‘smooth’ polygon instances would be nice, considering I would imagine there being a much higher allowance for points if the points aren’t control points, and are just regular points with the engine drawing straight lines between them. As the Pipboy map for example, would have far more than just 50 points in the polygon used to make up the floor. If you could zoom out, and see the entirety of the level.
So it’d require multiple instances for a polygon with straight edges, if there was a cap of 50 points like there is with Path2D.

Don’t have any requirements for winding or holes, but I’d imagine others would want holes.
Which could be done by proving an API that will take a polygon and then an array of polygons that represent holes, that returns an array of polygons which would represent the first polygon except with the holes cut into it.

Thanks for the details! I’m very interested in expanding the vector rendering capabilities of the engine, though no ETA at this point

SVG support would be nice! if we could paste a string of SVG html code into a gui object and have it pre-render as a texture it would be pretty cool!!!

The SVG specification is more than 800 pages long, so its probably not coming to Roblox as-is anytime soon :sweat_smile: . If there are particular features from SVG that you’d like though…

It would be good if at least path2d already allowed us to fill

Filled polygons are just enough for what I need this for, the SVG files I’m trying to render use almost none of the SVG spec, so I’d really just need a XML parser (which i have), and a way to render shapes with a background.