microsoft / DirectXMath

DirectXMath is an all inline SIMD C++ linear algebra library for use in games and graphics apps
https://walbourn.github.io/introducing-directxmath/
MIT License
1.54k stars 238 forks source link

Add linear color constants for .NET colors to DirectXColors.h #143

Closed walbourn closed 2 years ago

walbourn commented 2 years ago

DirectXMath has always included constants for the .NET colors, but that meant having to do conversions at runtime to get them into linear space or using a different header set.

This PR adds the same .NET colors in Linear colorspace in the ColorsLinear C++ namespace.

This PR also does some minor cleanup of the original .NET color constants: 0 and 1 float literals were shortened, and LightGray was in the wrong line for sort order.

walbourn commented 2 years ago

Note this content was generated using the attach program. I verified that it reproduces the original DirectXColors.h values

colors.cpp.txt .

walbourn commented 2 years ago

The only open question for me is if I need to provide an opt-in preprocessor define like _XM_DEFINE_LINEAR_COLORS to get these, or if it's fine to just take the minor object bloat even when clients aren't using these.