Allow conversion between FC Color and QColor
This commit is contained in:
parent
cb25c494de
commit
008a19d89f
|
@ -28,6 +28,8 @@
|
||||||
# include <stdint.h>
|
# include <stdint.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <QColor>
|
||||||
|
|
||||||
namespace App
|
namespace App
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -48,6 +50,11 @@ public:
|
||||||
*/
|
*/
|
||||||
Color(uint32_t rgba)
|
Color(uint32_t rgba)
|
||||||
{ setPackedValue( rgba ); }
|
{ setPackedValue( rgba ); }
|
||||||
|
/**
|
||||||
|
* creates FC Color from Qt QColor
|
||||||
|
*/
|
||||||
|
Color(QColor q)
|
||||||
|
{ set(q.redF(),q.greenF(),q.blueF()); }
|
||||||
/** Copy constructor. */
|
/** Copy constructor. */
|
||||||
Color(const Color& c)
|
Color(const Color& c)
|
||||||
:r(c.r),g(c.g),b(c.b),a(c.a){}
|
:r(c.r),g(c.g),b(c.b),a(c.a){}
|
||||||
|
@ -101,7 +108,14 @@ public:
|
||||||
(uint32_t)(b*255.0f + 0.5f) << 8 |
|
(uint32_t)(b*255.0f + 0.5f) << 8 |
|
||||||
(uint32_t)(a*255.0f + 0.5f));
|
(uint32_t)(a*255.0f + 0.5f));
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* returns Qt color equivalent to FC color
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
QColor asQColor()
|
||||||
|
{
|
||||||
|
return(QColor(int(r*255.0),int(g*255.0),int(b*255.0)));
|
||||||
|
}
|
||||||
/// color values, public accesible
|
/// color values, public accesible
|
||||||
float r,g,b,a;
|
float r,g,b,a;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user