Thanks, great function. Will come in handy when I need it.

Holy shit, did I read that a few boxes reduce your fps by 6!?
That’s one quarter of my frames per second :smith:

I think I’ll stick to making my gradient shapes in microsoft powerpoint, then export them to paint.NET, then convert them to a texture.

Thanks for the great script!

You know, there are gradient textures for this. It’s a lot faster than drawing 500 lines.

^ this. Since colors range in the 0-255 range, a single greyscale gradient texture 256 pixels wide and 1 pixel tall that you can colorize will get the job done at any resolution you could possibly use it in, in most cases. In the case you want to make a multicolor combination of gradients, or some kind of alpha-blended gradient you might have to tool around with things like vertex color or use a custom gradient texture, but still.

Drawing a gradient with a bunch of rectangles through lua every frame (keep in mind a single rectangle is two polygons) is really introducing a lot of unnecessary drawing calls which will contribute to a drop in framerate. Using a single rectangle and a texture is better because it only draws two polygons and just maps a texture to it (at the expense of a little bit of video memory, but the time saved each frame is worth it).

That’s what I said :colbert: