cinder / Cinder

Cinder is a community-developed, free and open source library for professional-quality creative coding in C++.
http://libcinder.org
Other
5.34k stars 944 forks source link

Add missing ci::Color( vec3 ) overload. #2312

Closed richardeakin closed 1 year ago

richardeakin commented 1 year ago

ColorA( vec4 ) already exists, the analog was missing for 3-channel ColorT class. After this change, code like the following works:

vec3 col = { 1, 0, 0 };
ci::Color boneColor = col;

Some of my code gets shared with GLSL, so it's nice in some cases to use vec3 instead as an RGB color like you do in shaders, but then for other that use ci::Color, seemlessly convert to what you need. Without, you must do:

vec3 col = { 1, 0, 0 };
ci::Color boneColor( col.x, col.y, col.z );
// or:
ci::Color boneColor = {  col.x, col.y, col.z };

However as I first noted, there is already a constructor for the 4-channel version that allows for this:

vec4 col = { 1,  0, 0, 0.5f };
ci::ColorA boneColor = col;