Open kortschak opened 7 years ago
Makes sense to me.
On this topic, additionally, I'm somewhat confused regarding what the purpose of the palette.Palette interface is. It only has one method, and the method doesn't take any arguments, so anything that is being used as a palette has to know ahead of time what colors it is going to return. Given that, would it make more sense to do type Palette []color.Color
or just delete the Palette type altogether and use []color.Color
instead?
I suppose one reason is that without a Palette interface we couldn't have a DivergingPalette. That may be enough to justify it, but it still feels to me like a lot of complexity just for that.
palette.Palette is justified by the same argument as fmt.Stringer.
The functions in fmt are set up so they can take either a string or a fmt.Stringer (or anything else). So the existence of fmt.Stringer doesn't prevent people from using plain strings in the functions. In this case, though, we have to choose between accepting []color.Color or palette.Palette; there doesn't seem to be a good way to accept both. I agree, though, that on balance palette.Palette is probably the better choice.
I am troubled by the size of the
ColorMap
interface. It can be reduced in size toand
The
Set
methods are required because the concrete types are not exported. This can be fixed with minor name juggling on the field names of the concrete types. For example: