Beatmup
Beatmup::pixfloat3 Struct Reference

Trichromatic floating point arithmetic. More...

#include <pixel_arithmetic.h>

Public Types

typedef float operating_type
 

Public Member Functions

 pixfloat3 ()
 
 pixfloat3 (const color3f &_)
 
 pixfloat3 (float r, float g, float b)
 
 operator pixint1 () const
 
 operator pixint3 () const
 
 operator pixint4 () const
 
 operator pixfloat1 () const
 
 operator pixfloat4 () const
 
bool operator== (const pixfloat3 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)
 
pixfloat3 operator+ (const int P) const
 
pixfloat3 operator+ (const float P) const
 
pixfloat3 operator+ (const pixint1 P) const
 
pixfloat3 operator+ (const pixfloat1 P) const
 
pixfloat3 operator+ (const pixint3 P) const
 
pixfloat3 operator+ (const pixfloat3 P) const
 
pixfloat4 operator+ (const pixint4 P) const
 
pixfloat4 operator+ (const pixfloat4 P) const
 
pixfloat3 operator- (const int P) const
 
pixfloat3 operator- (const float P) const
 
pixfloat3 operator- (const pixint1 P) const
 
pixfloat3 operator- (const pixfloat1 P) const
 
pixfloat3 operator- (const pixint3 P) const
 
pixfloat3 operator- (const pixfloat3 P) const
 
pixfloat4 operator- (const pixint4 P) const
 
pixfloat4 operator- (const pixfloat4 P) const
 
pixfloat3 operator* (const int P) const
 
pixfloat3 operator* (const float P) const
 
pixfloat3 operator* (const pixint1 P) const
 
pixfloat3 operator* (const pixfloat1 P) const
 
pixfloat3 operator* (const pixint3 P) const
 
pixfloat3 operator* (const pixfloat3 P) const
 
pixfloat4 operator* (const pixint4 P) const
 
pixfloat4 operator* (const pixfloat4 P) const
 
pixfloat3 operator/ (const int P) const
 
pixfloat3 makeFloat () const
 
void zero ()
 
float sum () const
 
float mean () const
 
float max () const
 
pixfloat3 abs () const
 

Public Attributes

pixfloat r
 
pixfloat g
 
pixfloat b
 

Detailed Description

Trichromatic floating point arithmetic.

Definition at line 198 of file pixel_arithmetic.h.

Member Typedef Documentation

◆ operating_type

Definition at line 199 of file pixel_arithmetic.h.

Constructor & Destructor Documentation

◆ pixfloat3() [1/3]

Beatmup::pixfloat3::pixfloat3 ( )
inline

Definition at line 201 of file pixel_arithmetic.h.

201 : r(0), g(0), b(0) {}

◆ pixfloat3() [2/3]

Beatmup::pixfloat3::pixfloat3 ( const color3f _)
inline

Definition at line 202 of file pixel_arithmetic.h.

202 : r(_.r), g(_.g), b(_.b) {}

◆ pixfloat3() [3/3]

Beatmup::pixfloat3::pixfloat3 ( float  r,
float  g,
float  b 
)
inline

Definition at line 203 of file pixel_arithmetic.h.

203 : r(r), g(g), b(b) {}

Member Function Documentation

◆ operator pixint1()

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

Definition at line 915 of file pixel_arithmetic.h.

915  {
916  return pixint1{ roundf_fast(255 * (r + g + b)) };
917  }
#define roundf_fast(X)
rounding (nearest integer)
Definition: utils.hpp:22

◆ operator pixint3()

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

Definition at line 919 of file pixel_arithmetic.h.

919  {
920  return pixint3{ roundf_fast(255 * r), roundf_fast(255 * g), roundf_fast(255 * b) };
921  }

◆ operator pixint4()

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

Definition at line 923 of file pixel_arithmetic.h.

923  {
924  return pixint4(roundf_fast(255 * r), roundf_fast(255 * g), roundf_fast(255 * b), 255);
925  }

◆ operator pixfloat1()

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

Definition at line 927 of file pixel_arithmetic.h.

927  {
928  return pixfloat1{ (r + g + b) / 3 };
929  }

◆ operator pixfloat4()

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

Definition at line 931 of file pixel_arithmetic.h.

931  {
932  return pixfloat4{ r, g, b, 1 };
933  }

◆ operator==()

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

Definition at line 935 of file pixel_arithmetic.h.

935  {
936  return (r == P.r) && (g == P.g) && (b == P.b);
937  }

◆ operator=() [1/6]

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

Definition at line 939 of file pixel_arithmetic.h.

939  {
940  r = g = b = P.x / 255.0f;
941  }

◆ operator=() [2/6]

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

Definition at line 943 of file pixel_arithmetic.h.

943  {
944  r = g = b = P.x;
945  }

◆ operator=() [3/6]

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

Definition at line 947 of file pixel_arithmetic.h.

947  {
948  r = P.r / 255.0f;
949  g = P.g / 255.0f;
950  b = P.b / 255.0f;
951  }

◆ operator=() [4/6]

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

Definition at line 953 of file pixel_arithmetic.h.

953  {
954  r = P.r;
955  g = P.g;
956  b = P.b;
957  }

◆ operator=() [5/6]

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

Definition at line 959 of file pixel_arithmetic.h.

959  {
960  r = P.r / 255.0f;
961  g = P.g / 255.0f;
962  b = P.b / 255.0f;
963  }

◆ operator=() [6/6]

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

Definition at line 965 of file pixel_arithmetic.h.

965  {
966  r = P.r;
967  g = P.g;
968  b = P.b;
969  }

◆ operator+() [1/8]

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

Definition at line 972 of file pixel_arithmetic.h.

972  {
973  return pixfloat3{ r + P, g + P, b + P };
974  }

◆ operator+() [2/8]

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

Definition at line 976 of file pixel_arithmetic.h.

976  {
977  return pixfloat3{ r + P, g + P, b + P };
978  }

◆ operator+() [3/8]

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

Definition at line 980 of file pixel_arithmetic.h.

980  {
981  pixfloat f = P.x / 255.0f;
982  return pixfloat3{ r + f, g + f, b + f };
983  }
float pixfloat
Definition: basic_types.h:35

◆ operator+() [4/8]

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

Definition at line 993 of file pixel_arithmetic.h.

993  {
994  return pixfloat3{ r + P.x, g + P.x, b + P.x };
995  }

◆ operator+() [5/8]

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

Definition at line 985 of file pixel_arithmetic.h.

985  {
986  return pixfloat3{ r + P.r / 255.0f, g + P.g / 255.0f, b + P.b / 255.0f };
987  }

◆ operator+() [6/8]

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

Definition at line 997 of file pixel_arithmetic.h.

997  {
998  return pixfloat3{ r + P.r, g + P.g, b + P.b };
999  }

◆ operator+() [7/8]

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

Definition at line 989 of file pixel_arithmetic.h.

989  {
990  return pixfloat4(r + P.r / 255.0f, g + P.g / 255.0f, b + P.b / 255.0f, 1.0f + P.a / 255.0f);
991  }

◆ operator+() [8/8]

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

Definition at line 1001 of file pixel_arithmetic.h.

1001  {
1002  return pixfloat4(r + P.r, g + P.g, b + P.b, 1.0f + P.a);
1003  }

◆ operator-() [1/8]

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

Definition at line 1006 of file pixel_arithmetic.h.

1006  {
1007  return pixfloat3{ r - P, g - P, b - P };
1008  }

◆ operator-() [2/8]

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

Definition at line 1010 of file pixel_arithmetic.h.

1010  {
1011  return pixfloat3{ r - P, g - P, b - P };
1012  }

◆ operator-() [3/8]

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

Definition at line 1014 of file pixel_arithmetic.h.

1014  {
1015  pixfloat f = P.x / 255.0f;
1016  return pixfloat3{ r - f, g - f, b - f };
1017  }

◆ operator-() [4/8]

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

Definition at line 1027 of file pixel_arithmetic.h.

1027  {
1028  return pixfloat3{ r - P.x, g - P.x, b - P.x };
1029  }

◆ operator-() [5/8]

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

Definition at line 1019 of file pixel_arithmetic.h.

1019  {
1020  return pixfloat3{ r - P.r / 255.0f, g - P.g / 255.0f, b - P.b / 255.0f };
1021  }

◆ operator-() [6/8]

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

Definition at line 1031 of file pixel_arithmetic.h.

1031  {
1032  return pixfloat3{ r - P.r, g - P.g, b - P.b };
1033  }

◆ operator-() [7/8]

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

Definition at line 1023 of file pixel_arithmetic.h.

1023  {
1024  return pixfloat4(r - P.r / 255.0f, g - P.g / 255.0f, b - P.b / 255.0f, 1.0f - P.a / 255.0f);
1025  }

◆ operator-() [8/8]

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

Definition at line 1035 of file pixel_arithmetic.h.

1035  {
1036  return pixfloat4(r - P.r, g - P.g, b - P.b, 1.0f - P.a);
1037  }

◆ operator*() [1/8]

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

Definition at line 1040 of file pixel_arithmetic.h.

1040  {
1041  return pixfloat3{ r * P, g * P, b * P };
1042  }

◆ operator*() [2/8]

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

Definition at line 1044 of file pixel_arithmetic.h.

1044  {
1045  return pixfloat3{ r * P, g * P, b * P };
1046  }

◆ operator*() [3/8]

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

Definition at line 1048 of file pixel_arithmetic.h.

1048  {
1049  float f = P.x / 255.0f;
1050  return pixfloat3{ r * f, g * f, b * f };
1051  }

◆ operator*() [4/8]

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

Definition at line 1061 of file pixel_arithmetic.h.

1061  {
1062  return pixfloat3{ r * P.x, g * P.x, b * P.x };
1063  }

◆ operator*() [5/8]

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

Definition at line 1053 of file pixel_arithmetic.h.

1053  {
1054  return pixfloat3{ r * P.r / 255.0f, g * P.g / 255.0f, b * P.b / 255.0f };
1055  }

◆ operator*() [6/8]

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

Definition at line 1065 of file pixel_arithmetic.h.

1065  {
1066  return pixfloat3{ r * P.r, g * P.g, b * P.b };
1067  }

◆ operator*() [7/8]

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

Definition at line 1057 of file pixel_arithmetic.h.

1057  {
1058  return pixfloat4(r * P.r / 255.0f, g * P.g / 255.0f, b * P.b / 255.0f, P.a / 255.0f);
1059  }

◆ operator*() [8/8]

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

Definition at line 1069 of file pixel_arithmetic.h.

1069  {
1070  return pixfloat4(r * P.r, g * P.g, b * P.b, P.a);
1071  }

◆ operator/()

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

Definition at line 1074 of file pixel_arithmetic.h.

1074  {
1075  return pixfloat3{ r / P, g / P, b / P };
1076  }

◆ makeFloat()

pixfloat3 Beatmup::pixfloat3::makeFloat ( ) const
inline

Definition at line 1079 of file pixel_arithmetic.h.

1079  {
1080  return *this;
1081  }

◆ zero()

void Beatmup::pixfloat3::zero ( )
inline

Definition at line 242 of file pixel_arithmetic.h.

242 { r = g = b = 0; }

◆ sum()

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

Definition at line 243 of file pixel_arithmetic.h.

243 { return r + g + b; }

◆ mean()

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

Definition at line 244 of file pixel_arithmetic.h.

244 { return (r + g + b) / 3; }

◆ max()

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

Definition at line 245 of file pixel_arithmetic.h.

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

◆ abs()

pixfloat3 Beatmup::pixfloat3::abs ( ) const
inline

Definition at line 246 of file pixel_arithmetic.h.

246 { return pixfloat3{ r > 0 ? r : -r, g > 0 ? g : -g, b > 0 ? b : -b }; }

Member Data Documentation

◆ r

pixfloat Beatmup::pixfloat3::r

Definition at line 200 of file pixel_arithmetic.h.

◆ g

pixfloat Beatmup::pixfloat3::g

Definition at line 200 of file pixel_arithmetic.h.

◆ b

pixfloat Beatmup::pixfloat3::b

Definition at line 200 of file pixel_arithmetic.h.


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