OpenNefia icon indicating copy to clipboard operation
OpenNefia copied to clipboard

Remove color argument to calls to Draw and asset methods

Open Ruin0x11 opened this issue 5 years ago • 1 comments
trafficstars

They cause unnecessary table allocations, and you can just use Draw.set_color() instead for slight performance gains from not having to set the color between multiple assets each time. It would be better if we used Draw.set_color() as the blessed way of setting colors. Also we should remove the option of passing a table argument to Draw.set_color() as well.

This really needs to be done before the API gets too popular.

Ruin0x11 avatar Jul 27 '20 03:07 Ruin0x11

Actually, being able to pass a table to Draw.set_color() is very useful when used with the theme table returned by UiTheme.load(), so you could just do Draw.set_color(self.t.base.text_color). The real issue is with code that will allocate a table every frame because a table color constant was not bound to an upvalue outside :draw().

Ruin0x11 avatar Apr 29 '21 06:04 Ruin0x11