Added nvgRGBf and nvgRGBAf constructor functions.
This commit is contained in:
parent
466ab4b19a
commit
a83913bc87
11
src/nanovg.c
11
src/nanovg.c
@ -283,12 +283,23 @@ struct NVGcolor nvgRGB(unsigned char r, unsigned char g, unsigned char b)
|
||||
return nvgRGBA(r,g,b,255);
|
||||
}
|
||||
|
||||
struct NVGcolor nvgRGBf(float r, float g, float b)
|
||||
{
|
||||
return nvgRGBA(r,g,b,1.0f);
|
||||
}
|
||||
|
||||
struct NVGcolor nvgRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
|
||||
{
|
||||
struct NVGcolor color = {r/255.0f, g/255.0f, b/255.0f, a/255.0f};
|
||||
return color;
|
||||
}
|
||||
|
||||
struct NVGcolor nvgRGBAf(float r, float g, float b, float a)
|
||||
{
|
||||
struct NVGcolor color = {r, g, b, a};
|
||||
return color;
|
||||
}
|
||||
|
||||
struct NVGcolor nvgTransRGBA(struct NVGcolor c, unsigned char a)
|
||||
{
|
||||
c.a = a / 255.0f;
|
||||
|
10
src/nanovg.h
10
src/nanovg.h
@ -113,12 +113,20 @@ void nvgEndFrame(struct NVGcontext* ctx);
|
||||
//
|
||||
// Colors in NanoVG are stored as unsigned ints in ABGR format.
|
||||
|
||||
// Returns a color value from red, green, blue values. Alpha will be set to 255.
|
||||
// Returns a color value from red, green, blue values. Alpha will be set to 255 (1.0f).
|
||||
struct NVGcolor nvgRGB(unsigned char r, unsigned char g, unsigned char b);
|
||||
|
||||
// Returns a color value from red, green, blue values. Alpha will be set to 1.0f.
|
||||
struct NVGcolor nvgRGBf(float r, float g, float b);
|
||||
|
||||
|
||||
// Returns a color value from red, green, blue and alpha values.
|
||||
struct NVGcolor nvgRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
|
||||
|
||||
// Returns a color value from red, green, blue and alpha values.
|
||||
struct NVGcolor nvgRGBAf(float r, float g, float b, float a);
|
||||
|
||||
|
||||
// Linearly interpoaltes from color c0 to c1, and returns resulting color value.
|
||||
struct NVGcolor nvgLerpRGBA(struct NVGcolor c0, struct NVGcolor c1, float u);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user