1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
5 * Copyright 2007 Novell, Inc. (http://www.novell.com)
7 * See the LICENSE file included with the distribution for details.
11 #ifndef __MOON_COLOR_H__
12 #define __MOON_COLOR_H__
18 /* @Namespace=System.Windows.Media */
22 Color () : r(0.0), g(0.0), b(0.0), a(0.0) {}
26 a
= (argb
>> 24) / 255.0f
;
27 r
= ((argb
>> 16) & 0xFF) / 255.0f
;
28 g
= ((argb
>> 8) & 0xFF) / 255.0f
;
29 b
= (argb
& 0xFF) / 255.0f
;
32 Color (double r
, double g
, double b
, double a
)
40 Color
operator+ (const Color
&color
)
42 return Color (r
+ color
.r
,
48 Color
operator- (const Color
&color
)
50 return Color (r
- color
.r
,
56 Color
operator* (double v
)
64 bool operator!= (const Color
&v
) const
66 return (r
!= v
.r
|| g
!= v
.g
|| b
!= v
.b
|| a
!= v
.a
);
69 bool operator== (const Color
&v
) const
71 return (fabs (r
-v
.r
) < DBL_EPSILON
&& fabs (g
-v
.g
) < DBL_EPSILON
&& fabs (b
-v
.b
) < DBL_EPSILON
&& fabs (a
-v
.a
) < DBL_EPSILON
);
77 const char *color_to_string (Color
*color
);
79 Color
*color_from_str (const char *name
);
83 #endif /* __MOON_COLOR_H__ */