Any one have any ideas on how to convert ccc3 to ccc4 or even just a macro! I am currently using CCMotion streak and it requires me to use ccc4 but i dont know what combination makes what color! Please any help would be appreciated! Thanks
from ccTypes.h
typedef struct _ccColor4B
{
GLubyte r;
GLubyte g;
GLubyte b;
GLubyte a;
} ccColor4B;
//! helper macro that creates an ccColor4B type
static inline ccColor4B
ccc4(const GLubyte r, const GLubyte g, const GLubyte b, const GLubyte o)
{
ccColor4B c = {r, g, b, o};
return c;
}
For exampe:
ccColor4b myColor = ccc4(255, 0, 0, 255);
creates a solid red color
Again from ccTypes.h
/** Returns a ccColor4F from a ccColor3B. Alpha will be 1.
@since v0.99.1
*/
static inline ccColor4F ccc4FFromccc3B(ccColor3B c)
{
return (ccColor4F){c.r/255.f, c.g/255.f, c.b/255.f, 1.f};
}
If it's not enough for your write your own converter like the last one
EDIT:
If you have ccColor3B myColor3B
and you want to have ccColor4F myColor4F
simply use the converter:
myColor4F c = ccc4FFromccc3B(myColor3B);
If you want to have ccColor4B write your own converter:
static inline ccColor4B ccc4BFromccc3B(ccColor3B c)
{
return (ccColor4F){c.r, c.g, c.b, 255};
}
and use it like this:
ccColor4B c = ccc4BFromccc3B(myColor);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With