Beatmup
Beatmup::pixfloat4 Struct Reference

4-channel floating point arithmetic More...

#include <pixel_arithmetic.h>

Public Types

typedef float operating_type
 

Public Member Functions

 pixfloat4 ()
 
 pixfloat4 (const color4f &_)
 
 pixfloat4 (float r, float g, float b, float a)
 
pixfloatoperator[] (int i)
 
pixfloat operator[] (int i) const
 
 operator pixint1 () const
 
 operator pixint3 () const
 
 operator pixint4 () const
 
 operator pixfloat1 () const
 
 operator pixfloat3 () const
 
 operator color4i () const
 
 operator color4f () const
 
bool operator== (const pixfloat4 P) const
 
void operator= (const pixint1 P)
 
void operator= (const pixfloat1 P)
 
void operator= (const pixint3 P)
 
void operator= (const pixfloat3 P)
 
void operator= (const pixint4 P)
 
void operator= (const pixfloat4 P)
 
pixfloat4 operator+ (const int P) const
 
pixfloat4 operator+ (const float P) const
 
pixfloat4 operator+ (const pixint1 P) const
 
pixfloat4 operator+ (const pixfloat1 P) const
 
pixfloat4 operator+ (const pixint3 P) const
 
pixfloat4 operator+ (const pixfloat3 P) const
 
pixfloat4 operator+ (const pixint4 P) const
 
pixfloat4 operator+ (const pixfloat4 P) const
 
pixfloat4 operator- (const int P) const
 
pixfloat4 operator- (const float P) const
 
pixfloat4 operator- (const pixint1 P) const
 
pixfloat4 operator- (const pixfloat1 P) const
 
pixfloat4 operator- (const pixint3 P) const
 
pixfloat4 operator- (const pixfloat3 P) const
 
pixfloat4 operator- (const pixint4 P) const
 
pixfloat4 operator- (const pixfloat4 P) const
 
pixfloat4 operator* (const int P) const
 
pixfloat4 operator* (const float P) const
 
pixfloat4 operator* (const pixint1 P) const
 
pixfloat4 operator* (const pixfloat1 P) const
 
pixfloat4 operator* (const pixint3 P) const
 
pixfloat4 operator* (const pixfloat3 P) const
 
pixfloat4 operator* (const pixint4 P) const
 
pixfloat4 operator* (const pixfloat4 P) const
 
pixfloat4 operator/ (const int P) const
 
pixfloat4 makeFloat () const
 
void zero ()
 
float sum () const
 
float mean () const
 
float max () const
 
pixfloat4 abs () const
 

Public Attributes

union {
   struct {
      pixfloat   r
 
      pixfloat   g
 
      pixfloat   b
 
      pixfloat   a
 
   } 
 
   pixfloat   val [4]
 
}; 
 

Detailed Description

4-channel floating point arithmetic

Definition at line 319 of file pixel_arithmetic.h.

Member Typedef Documentation

◆ operating_type

Definition at line 320 of file pixel_arithmetic.h.

Constructor & Destructor Documentation

◆ pixfloat4() [1/3]

Beatmup::pixfloat4::pixfloat4 ( )
inline

Definition at line 335 of file pixel_arithmetic.h.

335 : r(0), g(0), b(0), a(0) {}

◆ pixfloat4() [2/3]

Beatmup::pixfloat4::pixfloat4 ( const color4f _)
inline

Definition at line 336 of file pixel_arithmetic.h.

336 : r(_.r), g(_.g), b(_.b), a(_.a) {}

◆ pixfloat4() [3/3]

Beatmup::pixfloat4::pixfloat4 ( float  r,
float  g,
float  b,
float  a 
)
inline

Definition at line 337 of file pixel_arithmetic.h.

337 : r(r), g(g), b(b), a(a) {}

Member Function Documentation

◆ operator[]() [1/2]

pixfloat& Beatmup::pixfloat4::operator[] ( int  i)
inline

Definition at line 338 of file pixel_arithmetic.h.

338 { return val[i]; }

◆ operator[]() [2/2]

pixfloat Beatmup::pixfloat4::operator[] ( int  i) const
inline

Definition at line 339 of file pixel_arithmetic.h.

339 { return val[i]; }

◆ operator pixint1()

Beatmup::pixfloat4::operator pixint1 ( ) const
inline

Definition at line 1262 of file pixel_arithmetic.h.

1262  {
1263  return pixint1{ roundf_fast(85 * (r + g + b)) };
1264  }
#define roundf_fast(X)
rounding (nearest integer)
Definition: utils.hpp:22

◆ operator pixint3()

Beatmup::pixfloat4::operator pixint3 ( ) const
inline

Definition at line 1266 of file pixel_arithmetic.h.

1266  {
1267  return pixint3{ roundf_fast(255 * r), roundf_fast(255 * g), roundf_fast(255 * b) };
1268  }

◆ operator pixint4()

Beatmup::pixfloat4::operator pixint4 ( ) const
inline

Definition at line 1270 of file pixel_arithmetic.h.

1270  {
1271  return pixint4(roundf_fast(255 * r), roundf_fast(255 * g), roundf_fast(255 * b), roundf_fast(255 * a));
1272  }

◆ operator pixfloat1()

Beatmup::pixfloat4::operator pixfloat1 ( ) const
inline

Definition at line 1273 of file pixel_arithmetic.h.

1273  {
1274  return pixfloat1{ (r + g + b) / 3 };
1275  }

◆ operator pixfloat3()

Beatmup::pixfloat4::operator pixfloat3 ( ) const
inline

Definition at line 1277 of file pixel_arithmetic.h.

1277  {
1278  return pixfloat3{ r, g, b };
1279  }

◆ operator color4i()

Beatmup::pixfloat4::operator color4i ( ) const
inline

Definition at line 1285 of file pixel_arithmetic.h.

1285  {
1287  }
pixbyte pixfloat2pixbyte(pixfloat x)
Converts a floating point pixel value to a 0..255 integer.

◆ operator color4f()

Beatmup::pixfloat4::operator color4f ( ) const
inline

Definition at line 1281 of file pixel_arithmetic.h.

1281  {
1282  return color4f{ r, g, b, a };
1283  }

◆ operator==()

bool Beatmup::pixfloat4::operator== ( const pixfloat4  P) const
inline

Definition at line 1289 of file pixel_arithmetic.h.

1289  {
1290  return (r == P.r) && (g == P.g) && (b == P.b) && (a == P.a);
1291  }

◆ operator=() [1/6]

void Beatmup::pixfloat4::operator= ( const pixint1  P)
inline

Definition at line 1293 of file pixel_arithmetic.h.

1293  {
1294  r = g = b = P.x / 255.0f;
1295  a = 1.0f;
1296  }

◆ operator=() [2/6]

void Beatmup::pixfloat4::operator= ( const pixfloat1  P)
inline

Definition at line 1298 of file pixel_arithmetic.h.

1298  {
1299  r = g = b = P.x;
1300  a = 1.0f;
1301  }

◆ operator=() [3/6]

void Beatmup::pixfloat4::operator= ( const pixint3  P)
inline

Definition at line 1303 of file pixel_arithmetic.h.

1303  {
1304  r = P.r / 255.0f;
1305  g = P.g / 255.0f;
1306  b = P.b / 255.0f;
1307  a = 1.0f;
1308  }

◆ operator=() [4/6]

void Beatmup::pixfloat4::operator= ( const pixfloat3  P)
inline

Definition at line 1310 of file pixel_arithmetic.h.

1310  {
1311  r = P.r;
1312  g = P.g;
1313  b = P.b;
1314  a = 1.0f;
1315  }

◆ operator=() [5/6]

void Beatmup::pixfloat4::operator= ( const pixint4  P)
inline

Definition at line 1317 of file pixel_arithmetic.h.

1317  {
1318  r = P.r / 255.0f;
1319  g = P.g / 255.0f;
1320  b = P.b / 255.0f;
1321  a = P.a / 255.0f;
1322  }

◆ operator=() [6/6]

void Beatmup::pixfloat4::operator= ( const pixfloat4  P)
inline

Definition at line 1324 of file pixel_arithmetic.h.

1324  {
1325  r = P.r;
1326  g = P.g;
1327  b = P.b;
1328  a = P.a;
1329  }

◆ operator+() [1/8]

pixfloat4 Beatmup::pixfloat4::operator+ ( const int  P) const
inline

Definition at line 1332 of file pixel_arithmetic.h.

1332  {
1333  return pixfloat4(r + P, g + P, b + P, a + P);
1334  }

◆ operator+() [2/8]

pixfloat4 Beatmup::pixfloat4::operator+ ( const float  P) const
inline

Definition at line 1336 of file pixel_arithmetic.h.

1336  {
1337  return pixfloat4(r + P, g + P, b + P, a + P);
1338  }

◆ operator+() [3/8]

pixfloat4 Beatmup::pixfloat4::operator+ ( const pixint1  P) const
inline

Definition at line 1340 of file pixel_arithmetic.h.

1340  {
1341  pixfloat f = P.x / 255.0f;
1342  return pixfloat4(r + f, g + f, b + f, a + 1.0f);
1343  }
float pixfloat
Definition: basic_types.h:35

◆ operator+() [4/8]

pixfloat4 Beatmup::pixfloat4::operator+ ( const pixfloat1  P) const
inline

Definition at line 1353 of file pixel_arithmetic.h.

1353  {
1354  return pixfloat4(r + P.x, g + P.x, b + P.x, a + 1.0f);
1355  }

◆ operator+() [5/8]

pixfloat4 Beatmup::pixfloat4::operator+ ( const pixint3  P) const
inline

Definition at line 1345 of file pixel_arithmetic.h.

1345  {
1346  return pixfloat4(r + P.r / 255.0f, g + P.g / 255.0f, b + P.b / 255.0f, a + 1.0f);
1347  }

◆ operator+() [6/8]

pixfloat4 Beatmup::pixfloat4::operator+ ( const pixfloat3  P) const
inline

Definition at line 1357 of file pixel_arithmetic.h.

1357  {
1358  return pixfloat4(r + P.r, g + P.g, b + P.b, a + 1.0f);
1359  }

◆ operator+() [7/8]

pixfloat4 Beatmup::pixfloat4::operator+ ( const pixint4  P) const
inline

Definition at line 1349 of file pixel_arithmetic.h.

1349  {
1350  return pixfloat4(r + P.r / 255.0f, g + P.g / 255.0f, b + P.b / 255.0f, a + P.a / 255.0f);
1351  }

◆ operator+() [8/8]

pixfloat4 Beatmup::pixfloat4::operator+ ( const pixfloat4  P) const
inline

Definition at line 1361 of file pixel_arithmetic.h.

1361  {
1362  return pixfloat4(r + P.r, g + P.g, b + P.b, a + P.a);
1363  }

◆ operator-() [1/8]

pixfloat4 Beatmup::pixfloat4::operator- ( const int  P) const
inline

Definition at line 1366 of file pixel_arithmetic.h.

1366  {
1367  return pixfloat4(r - P, g - P, b - P, a - P);
1368  }

◆ operator-() [2/8]

pixfloat4 Beatmup::pixfloat4::operator- ( const float  P) const
inline

Definition at line 1370 of file pixel_arithmetic.h.

1370  {
1371  return pixfloat4(r - P, g - P, b - P, a - P);
1372  }

◆ operator-() [3/8]

pixfloat4 Beatmup::pixfloat4::operator- ( const pixint1  P) const
inline

Definition at line 1374 of file pixel_arithmetic.h.

1374  {
1375  pixfloat f = P.x / 255.0f;
1376  return pixfloat4(r - f, g - f, b - f, a - 1.0f);
1377  }

◆ operator-() [4/8]

pixfloat4 Beatmup::pixfloat4::operator- ( const pixfloat1  P) const
inline

Definition at line 1387 of file pixel_arithmetic.h.

1387  {
1388  return pixfloat4(r - P.x, g - P.x, b - P.x, a - 1.0f);
1389  }

◆ operator-() [5/8]

pixfloat4 Beatmup::pixfloat4::operator- ( const pixint3  P) const
inline

Definition at line 1379 of file pixel_arithmetic.h.

1379  {
1380  return pixfloat4(r - P.r / 255.0f, g - P.g / 255.0f, b - P.b / 255.0f, a - 1.0f);
1381  }

◆ operator-() [6/8]

pixfloat4 Beatmup::pixfloat4::operator- ( const pixfloat3  P) const
inline

Definition at line 1391 of file pixel_arithmetic.h.

1391  {
1392  return pixfloat4(r - P.r, g - P.g, b - P.b, a - 1.0f);
1393  }

◆ operator-() [7/8]

pixfloat4 Beatmup::pixfloat4::operator- ( const pixint4  P) const
inline

Definition at line 1383 of file pixel_arithmetic.h.

1383  {
1384  return pixfloat4(r - P.r / 255.0f, g - P.g / 255.0f, b - P.b / 255.0f, a - P.a / 255.0f - 1.0f);
1385  }

◆ operator-() [8/8]

pixfloat4 Beatmup::pixfloat4::operator- ( const pixfloat4  P) const
inline

Definition at line 1395 of file pixel_arithmetic.h.

1395  {
1396  return pixfloat4(r - P.r, g - P.g, b - P.b, a - P.a);
1397  }

◆ operator*() [1/8]

pixfloat4 Beatmup::pixfloat4::operator* ( const int  P) const
inline

Definition at line 1400 of file pixel_arithmetic.h.

1400  {
1401  return pixfloat4(r * P, g * P, b * P, a * P);
1402  }

◆ operator*() [2/8]

pixfloat4 Beatmup::pixfloat4::operator* ( const float  P) const
inline

Definition at line 1404 of file pixel_arithmetic.h.

1404  {
1405  return pixfloat4(r * P, g * P, b * P, a * P);
1406  }

◆ operator*() [3/8]

pixfloat4 Beatmup::pixfloat4::operator* ( const pixint1  P) const
inline

Definition at line 1408 of file pixel_arithmetic.h.

1408  {
1409  float f = P.x / 255.0f;
1410  return pixfloat4(r * f, g * f, b * f, a);
1411  }

◆ operator*() [4/8]

pixfloat4 Beatmup::pixfloat4::operator* ( const pixfloat1  P) const
inline

Definition at line 1421 of file pixel_arithmetic.h.

1421  {
1422  return pixfloat4(r * P.x, g * P.x, b * P.x, a);
1423  }

◆ operator*() [5/8]

pixfloat4 Beatmup::pixfloat4::operator* ( const pixint3  P) const
inline

Definition at line 1413 of file pixel_arithmetic.h.

1413  {
1414  return pixfloat4(r * P.r / 255.0f, g * P.g / 255.0f, b * P.b / 255.0f, a);
1415  }

◆ operator*() [6/8]

pixfloat4 Beatmup::pixfloat4::operator* ( const pixfloat3  P) const
inline

Definition at line 1425 of file pixel_arithmetic.h.

1425  {
1426  return pixfloat4(r * P.r, g * P.g, b * P.b, a);
1427  }

◆ operator*() [7/8]

pixfloat4 Beatmup::pixfloat4::operator* ( const pixint4  P) const
inline

Definition at line 1417 of file pixel_arithmetic.h.

1417  {
1418  return pixfloat4(r * P.r / 255.0f, g * P.g / 255.0f, b * P.b / 255.0f, a * P.a / 255.0f);
1419  }

◆ operator*() [8/8]

pixfloat4 Beatmup::pixfloat4::operator* ( const pixfloat4  P) const
inline

Definition at line 1429 of file pixel_arithmetic.h.

1429  {
1430  return pixfloat4(r * P.r, g * P.g, b * P.b, a * P.a);
1431  }

◆ operator/()

pixfloat4 Beatmup::pixfloat4::operator/ ( const int  P) const
inline

Definition at line 1434 of file pixel_arithmetic.h.

1434  {
1435  return pixfloat4(r / P, g / P, b / P, a / P);
1436  }

◆ makeFloat()

pixfloat4 Beatmup::pixfloat4::makeFloat ( ) const
inline

Definition at line 1439 of file pixel_arithmetic.h.

1439  {
1440  return *this;
1441  }

◆ zero()

void Beatmup::pixfloat4::zero ( )
inline

Definition at line 380 of file pixel_arithmetic.h.

380 { r = g = b = a = 0; }

◆ sum()

float Beatmup::pixfloat4::sum ( ) const
inline

Definition at line 381 of file pixel_arithmetic.h.

381 { return r + g + b + a; }

◆ mean()

float Beatmup::pixfloat4::mean ( ) const
inline

Definition at line 382 of file pixel_arithmetic.h.

382 { return (r + g + b + a) / 4; }

◆ max()

float Beatmup::pixfloat4::max ( ) const
inline

Definition at line 383 of file pixel_arithmetic.h.

383 { return std::max(std::max(r, g), std::max(b, a)); }
CustomPoint< numeric > max(const CustomPoint< numeric > &a, const CustomPoint< numeric > &b)
Definition: geometry.h:728

◆ abs()

pixfloat4 Beatmup::pixfloat4::abs ( ) const
inline

Definition at line 384 of file pixel_arithmetic.h.

384 { return pixfloat4(r > 0 ? r : -r, g > 0 ? g : -g, b > 0 ? b : -b, a > 0 ? a : -a); }

Member Data Documentation

◆ r

pixfloat Beatmup::pixfloat4::r

Definition at line 329 of file pixel_arithmetic.h.

◆ g

pixfloat Beatmup::pixfloat4::g

Definition at line 329 of file pixel_arithmetic.h.

◆ b

pixfloat Beatmup::pixfloat4::b

Definition at line 329 of file pixel_arithmetic.h.

◆ a

pixfloat Beatmup::pixfloat4::a

Definition at line 329 of file pixel_arithmetic.h.

◆ val

pixfloat Beatmup::pixfloat4::val[4]

Definition at line 332 of file pixel_arithmetic.h.

◆ 

union { ... }

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