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){}
|
||||||
|
@ -55,9 +62,9 @@ public:
|
||||||
bool operator==(const Color& c) const
|
bool operator==(const Color& c) const
|
||||||
{
|
{
|
||||||
return getPackedValue() == c.getPackedValue();
|
return getPackedValue() == c.getPackedValue();
|
||||||
//return (c.r==r && c.g==g && c.b==b && c.a==a);
|
//return (c.r==r && c.g==g && c.b==b && c.a==a);
|
||||||
}
|
}
|
||||||
bool operator!=(const Color& c) const
|
bool operator!=(const Color& c) const
|
||||||
{
|
{
|
||||||
return !operator==(c);
|
return !operator==(c);
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
};
|
};
|
||||||
|
@ -111,7 +125,7 @@ public:
|
||||||
class AppExport Material
|
class AppExport Material
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum MaterialType {
|
enum MaterialType {
|
||||||
BRASS,
|
BRASS,
|
||||||
BRONZE,
|
BRONZE,
|
||||||
COPPER,
|
COPPER,
|
||||||
|
@ -182,7 +196,7 @@ public:
|
||||||
*/
|
*/
|
||||||
void set(const char* MatName);
|
void set(const char* MatName);
|
||||||
/**
|
/**
|
||||||
* This method is provided for convenience which does basically the same as the method above unless that it accepts a MaterialType
|
* This method is provided for convenience which does basically the same as the method above unless that it accepts a MaterialType
|
||||||
* as argument.
|
* as argument.
|
||||||
*/
|
*/
|
||||||
void setType(const MaterialType MatType);
|
void setType(const MaterialType MatType);
|
||||||
|
@ -208,4 +222,4 @@ private:
|
||||||
|
|
||||||
} //namespace App
|
} //namespace App
|
||||||
|
|
||||||
#endif // APP_MATERIAL_H
|
#endif // APP_MATERIAL_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user