thesadrogue / TheSadRogue.Primitives

A collection of primitive data structures for working with a 2-dimensional grid.
MIT License
21 stars 6 forks source link

Inconsistent Exception Behavior in Gradient #94

Open Chris3606 opened 1 year ago

Chris3606 commented 1 year ago

Currently, var gradient = new Gradient() will produce an exception. Arguably, this makes sense since an empty gradient doesn't really represent anything; but it is possible to create an empty gradient by passing two empty IEnumerable object to the constructor with 2 parameters.

The behavior between these two should, I think, be consistent. If it doesn't make sense to allow an empty Gradient, then disallow it in all constructors. If it does make sense, enable it as applicable in all constructors.

Additionally, it is possible to construct a 1-color Gradient, but only using the constructor with 2 parameters (like var gradient = new Gradient(new[]{Color.Aqua}, new[] {0f}). The one that can take only a single color will turn it into 2 colors. This is also a case where consistency would be of benefit.