Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
agg::rgba32 Struct Reference

#include <src/agg/agg_color_rgba.h>

Public Types

typedef float value_type
 
typedef double calc_type
 
typedef double long_type
 
typedef rgba32 self_type
 

Public Member Functions

 rgba32 ()
 
 rgba32 (value_type r_, value_type g_, value_type b_, value_type a_=1)
 
 rgba32 (const self_type &c, float a_)
 
 rgba32 (const rgba &c)
 
 rgba32 (const rgba8 &c)
 
 rgba32 (const srgba8 &c)
 
 rgba32 (const rgba16 &c)
 
 operator rgba () const
 
 operator rgba8 () const
 
 operator srgba8 () const
 
 operator rgba16 () const
 
AGG_INLINE bool is_transparent () const
 
AGG_INLINE bool is_opaque () const
 
self_typeclear ()
 
self_typetransparent ()
 
AGG_INLINE self_typeopacity (double a_)
 
double opacity () const
 
AGG_INLINE self_typepremultiply ()
 
AGG_INLINE self_typedemultiply ()
 
AGG_INLINE self_type gradient (const self_type &c, double k) const
 
AGG_INLINE void add (const self_type &c, unsigned cover)
 
template<class GammaLUT >
AGG_INLINE void apply_gamma_dir (const GammaLUT &gamma)
 
template<class GammaLUT >
AGG_INLINE void apply_gamma_inv (const GammaLUT &gamma)
 

Static Public Member Functions

static AGG_INLINE double to_double (value_type a)
 
static AGG_INLINE value_type from_double (double a)
 
static AGG_INLINE value_type empty_value ()
 
static AGG_INLINE value_type full_value ()
 
static AGG_INLINE value_type invert (value_type x)
 
static AGG_INLINE value_type multiply (value_type a, value_type b)
 
static AGG_INLINE value_type demultiply (value_type a, value_type b)
 
template<typename T >
static AGG_INLINEdownscale (T a)
 
template<typename T >
static AGG_INLINEdownshift (T a, unsigned n)
 
static AGG_INLINE value_type mult_cover (value_type a, cover_type b)
 
static AGG_INLINE cover_type scale_cover (cover_type a, value_type b)
 
static AGG_INLINE value_type prelerp (value_type p, value_type q, value_type a)
 
static AGG_INLINE value_type lerp (value_type p, value_type q, value_type a)
 
static self_type no_color ()
 
static self_type from_wavelength (double wl, double gamma=1)
 

Public Attributes

value_type r
 
value_type g
 
value_type b
 
value_type a
 

Detailed Description

Member Typedef Documentation

◆ calc_type

typedef double agg::rgba32::calc_type

◆ long_type

typedef double agg::rgba32::long_type

◆ self_type

◆ value_type

typedef float agg::rgba32::value_type

Constructor & Destructor Documentation

◆ rgba32() [1/7]

agg::rgba32::rgba32 ( )
inline
1044{}

◆ rgba32() [2/7]

agg::rgba32::rgba32 ( value_type  r_,
value_type  g_,
value_type  b_,
value_type  a_ = 1 
)
inline
1047 :
1048 r(r_), g(g_), b(b_), a(a_) {}
value_type r
Definition agg_color_rgba.h:1038
value_type a
Definition agg_color_rgba.h:1041
value_type b
Definition agg_color_rgba.h:1040
value_type g
Definition agg_color_rgba.h:1039

◆ rgba32() [3/7]

agg::rgba32::rgba32 ( const self_type c,
float  a_ 
)
inline
1051 :
1052 r(c.r), g(c.g), b(c.b), a(a_) {}

◆ rgba32() [4/7]

agg::rgba32::rgba32 ( const rgba c)
inline
1055 :
1056 r(value_type(c.r)), g(value_type(c.g)), b(value_type(c.b)), a(value_type(c.a)) {}
float value_type
Definition agg_color_rgba.h:1033

◆ rgba32() [5/7]

agg::rgba32::rgba32 ( const rgba8 c)
inline
1059 :
1060 r(value_type(c.r / 255.0)),
1061 g(value_type(c.g / 255.0)),
1062 b(value_type(c.b / 255.0)),
1063 a(value_type(c.a / 255.0)) {}

◆ rgba32() [6/7]

agg::rgba32::rgba32 ( const srgba8 c)
inline
1066 :
1067 r(sRGB_conv<value_type>::rgb_from_sRGB(c.r)),
1068 g(sRGB_conv<value_type>::rgb_from_sRGB(c.g)),
1069 b(sRGB_conv<value_type>::rgb_from_sRGB(c.b)),
1070 a(sRGB_conv<value_type>::alpha_from_sRGB(c.a)) {}

◆ rgba32() [7/7]

agg::rgba32::rgba32 ( const rgba16 c)
inline
1073 :
1074 r(value_type(c.r / 65535.0)),
1075 g(value_type(c.g / 65535.0)),
1076 b(value_type(c.b / 65535.0)),
1077 a(value_type(c.a / 65535.0)) {}

Member Function Documentation

◆ add()

AGG_INLINE void agg::rgba32::add ( const self_type c,
unsigned  cover 
)
inline
1293 {
1294 if (cover == cover_mask)
1295 {
1296 if (c.is_opaque())
1297 {
1298 *this = c;
1299 return;
1300 }
1301 else
1302 {
1303 r += c.r;
1304 g += c.g;
1305 b += c.b;
1306 a += c.a;
1307 }
1308 }
1309 else
1310 {
1311 r += mult_cover(c.r, cover);
1312 g += mult_cover(c.g, cover);
1313 b += mult_cover(c.b, cover);
1314 a += mult_cover(c.a, cover);
1315 }
1316 if (a > 1) a = 1;
1317 if (r > a) r = a;
1318 if (g > a) g = a;
1319 if (b > a) b = a;
1320 }
@ cover_mask
Definition agg_basics.h:242
static AGG_INLINE value_type mult_cover(value_type a, cover_type b)
Definition agg_color_rgba.h:1184

References a, b, agg::cover_mask, g, mult_cover(), and r.

+ Here is the call graph for this function:

◆ apply_gamma_dir()

template<class GammaLUT >
AGG_INLINE void agg::rgba32::apply_gamma_dir ( const GammaLUT &  gamma)
inline
1325 {
1326 r = gamma.dir(r);
1327 g = gamma.dir(g);
1328 b = gamma.dir(b);
1329 }

References b, g, and r.

◆ apply_gamma_inv()

template<class GammaLUT >
AGG_INLINE void agg::rgba32::apply_gamma_inv ( const GammaLUT &  gamma)
inline
1334 {
1335 r = gamma.inv(r);
1336 g = gamma.inv(g);
1337 b = gamma.inv(b);
1338 }

References b, g, and r.

◆ clear()

self_type & agg::rgba32::clear ( )
inline
1215 {
1216 r = g = b = a = 0;
1217 return *this;
1218 }

References a, b, g, and r.

◆ demultiply() [1/2]

AGG_INLINE self_type & agg::rgba32::demultiply ( )
inline
1263 {
1264 if (a < 1)
1265 {
1266 if (a <= 0)
1267 {
1268 r = g = b = 0;
1269 }
1270 else
1271 {
1272 r /= a;
1273 g /= a;
1274 b /= a;
1275 }
1276 }
1277 return *this;
1278 }

References a, b, g, and r.

◆ demultiply() [2/2]

static AGG_INLINE value_type agg::rgba32::demultiply ( value_type  a,
value_type  b 
)
inlinestatic
1165 {
1166 return (b == 0) ? 0 : value_type(a / b);
1167 }

References a, and b.

◆ downscale()

template<typename T >
static AGG_INLINE T agg::rgba32::downscale ( a)
inlinestatic
1172 {
1173 return a;
1174 }

References a.

◆ downshift()

template<typename T >
static AGG_INLINE T agg::rgba32::downshift ( a,
unsigned  n 
)
inlinestatic
1179 {
1180 return n > 0 ? a / (1 << n) : a;
1181 }

References a.

◆ empty_value()

static AGG_INLINE value_type agg::rgba32::empty_value ( )
inlinestatic
1129 {
1130 return 0;
1131 }

◆ from_double()

static AGG_INLINE value_type agg::rgba32::from_double ( double  a)
inlinestatic
1123 {
1124 return value_type(a);
1125 }

References a.

◆ from_wavelength()

static self_type agg::rgba32::from_wavelength ( double  wl,
double  gamma = 1 
)
inlinestatic
1345 {
1346 return self_type(rgba::from_wavelength(wl, gamma));
1347 }
rgba32 self_type
Definition agg_color_rgba.h:1036
static rgba from_wavelength(double wl, double gamma=1.0)
Definition agg_color_rgba.h:194

References agg::rgba::from_wavelength().

+ Here is the call graph for this function:

◆ full_value()

static AGG_INLINE value_type agg::rgba32::full_value ( )
inlinestatic
1135 {
1136 return 1;
1137 }

◆ gradient()

AGG_INLINE self_type agg::rgba32::gradient ( const self_type c,
double  k 
) const
inline
1282 {
1283 self_type ret;
1284 ret.r = value_type(r + (c.r - r) * k);
1285 ret.g = value_type(g + (c.g - g) * k);
1286 ret.b = value_type(b + (c.b - b) * k);
1287 ret.a = value_type(a + (c.a - a) * k);
1288 return ret;
1289 }

References a, b, g, and r.

◆ invert()

static AGG_INLINE value_type agg::rgba32::invert ( value_type  x)
inlinestatic
1153 {
1154 return 1 - x;
1155 }
TCoord< P > x(const P &p)
Definition geometry_traits.hpp:297

◆ is_opaque()

AGG_INLINE bool agg::rgba32::is_opaque ( ) const
inline
1147 {
1148 return a >= 1;
1149 }

References a.

◆ is_transparent()

AGG_INLINE bool agg::rgba32::is_transparent ( ) const
inline
1141 {
1142 return a <= 0;
1143 }

References a.

◆ lerp()

static AGG_INLINE value_type agg::rgba32::lerp ( value_type  p,
value_type  q,
value_type  a 
)
inlinestatic
1205 {
1206 // The form "p + a * (q - p)" avoids a multiplication, but may produce an
1207 // inaccurate result. For example, "p + (q - p)" may not be exactly equal
1208 // to q. Therefore, stick to the basic expression, which at least produces
1209 // the correct result at either extreme.
1210 return (1 - a) * p + a * q;
1211 }

References a.

◆ mult_cover()

static AGG_INLINE value_type agg::rgba32::mult_cover ( value_type  a,
cover_type  b 
)
inlinestatic
1185 {
1186 return value_type(a * b / cover_mask);
1187 }

References a, b, and agg::cover_mask.

Referenced by add().

+ Here is the caller graph for this function:

◆ multiply()

static AGG_INLINE value_type agg::rgba32::multiply ( value_type  a,
value_type  b 
)
inlinestatic
1159 {
1160 return value_type(a * b);
1161 }

References a, and b.

◆ no_color()

static self_type agg::rgba32::no_color ( )
inlinestatic
1341{ return self_type(0,0,0,0); }

◆ opacity() [1/2]

double agg::rgba32::opacity ( ) const
inline
1238 {
1239 return a;
1240 }

References a.

◆ opacity() [2/2]

AGG_INLINE self_type & agg::rgba32::opacity ( double  a_)
inline
1229 {
1230 if (a_ < 0) a = 0;
1231 else if (a_ > 1) a = 1;
1232 else a = value_type(a_);
1233 return *this;
1234 }

References a.

◆ operator rgba()

agg::rgba32::operator rgba ( ) const
inline
1081 {
1082 return rgba(r, g, b, a);
1083 }

References a, b, g, and r.

◆ operator rgba16()

agg::rgba32::operator rgba16 ( ) const
inline
1107 {
1108 return rgba8(
1109 uround(r * 65535.0),
1110 uround(g * 65535.0),
1111 uround(b * 65535.0),
1112 uround(a * 65535.0));
1113 }
AGG_INLINE int uround(double v)
Definition agg_basics.h:192
rgba8T< linear > rgba8
Definition agg_color_rgba.h:623

References a, b, g, r, and agg::uround().

+ Here is the call graph for this function:

◆ operator rgba8()

agg::rgba32::operator rgba8 ( ) const
inline
1087 {
1088 return rgba8(
1089 uround(r * 255.0),
1090 uround(g * 255.0),
1091 uround(b * 255.0),
1092 uround(a * 255.0));
1093 }

References a, b, g, r, and agg::uround().

+ Here is the call graph for this function:

◆ operator srgba8()

agg::rgba32::operator srgba8 ( ) const
inline
1097 {
1098 return srgba8(
1099 sRGB_conv<value_type>::rgb_to_sRGB(r),
1100 sRGB_conv<value_type>::rgb_to_sRGB(g),
1101 sRGB_conv<value_type>::rgb_to_sRGB(b),
1102 sRGB_conv<value_type>::alpha_to_sRGB(a));
1103 }
rgba8T< sRGB > srgba8
Definition agg_color_rgba.h:624

References a, b, g, and r.

◆ prelerp()

static AGG_INLINE value_type agg::rgba32::prelerp ( value_type  p,
value_type  q,
value_type  a 
)
inlinestatic
1198 {
1199 return (1 - a) * p + q; // more accurate than "p + q - p * a"
1200 }

References a.

◆ premultiply()

AGG_INLINE self_type & agg::rgba32::premultiply ( )
inline
1244 {
1245 if (a < 1)
1246 {
1247 if (a <= 0)
1248 {
1249 r = g = b = 0;
1250 }
1251 else
1252 {
1253 r *= a;
1254 g *= a;
1255 b *= a;
1256 }
1257 }
1258 return *this;
1259 }

References a, b, g, and r.

◆ scale_cover()

static AGG_INLINE cover_type agg::rgba32::scale_cover ( cover_type  a,
value_type  b 
)
inlinestatic
1191 {
1192 return cover_type(uround(a * b));
1193 }
unsigned char cover_type
Definition agg_basics.h:237

References a, b, and agg::uround().

+ Here is the call graph for this function:

◆ to_double()

static AGG_INLINE double agg::rgba32::to_double ( value_type  a)
inlinestatic
1117 {
1118 return a;
1119 }

References a.

◆ transparent()

self_type & agg::rgba32::transparent ( )
inline
1222 {
1223 a = 0;
1224 return *this;
1225 }

References a.

Member Data Documentation

◆ a

◆ b

◆ g

◆ r


The documentation for this struct was generated from the following file: