Beatmup
Beatmup::pixint4 Struct Reference

4-channel integer arithmetic More...

#include <pixel_arithmetic.h>

Public Types

typedef int operating_type
 

Public Member Functions

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

Static Public Member Functions

static pixint4 fromColor (const color4i &_)
 

Public Attributes

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

Detailed Description

4-channel integer arithmetic

Definition at line 252 of file pixel_arithmetic.h.

Member Typedef Documentation

◆ operating_type

Definition at line 253 of file pixel_arithmetic.h.

Constructor & Destructor Documentation

◆ pixint4() [1/2]

Beatmup::pixint4::pixint4 ( )
inline

Definition at line 268 of file pixel_arithmetic.h.

◆ pixint4() [2/2]

Beatmup::pixint4::pixint4 ( int  r,
int  g,
int  b,
int  a 
)
inline

Definition at line 269 of file pixel_arithmetic.h.

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

Member Function Documentation

◆ fromColor()

static pixint4 Beatmup::pixint4::fromColor ( const color4i _)
inlinestatic

Definition at line 270 of file pixel_arithmetic.h.

270 { return pixint4(_.r, _.g, _.b, _.a); }

◆ operator pixint1()

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

Definition at line 1087 of file pixel_arithmetic.h.

1087  {
1088  return pixint1{ (r + g + b) / 4 };
1089  }

◆ operator pixint3()

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

Definition at line 1091 of file pixel_arithmetic.h.

1091  {
1092  return pixint3{ r, g, b };
1093  }

◆ operator pixfloat1()

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

Definition at line 1095 of file pixel_arithmetic.h.

1095  {
1096  return pixfloat1{ (r + g + b) / (4 * 255.0f) };
1097  }

◆ operator pixfloat3()

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

Definition at line 1099 of file pixel_arithmetic.h.

1099  {
1100  return pixfloat3{ r / 255.0f, g / 255.0f, b / 255.0f };
1101  }

◆ operator pixfloat4()

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

Definition at line 1103 of file pixel_arithmetic.h.

1103  {
1104  return pixfloat4{ r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f };
1105  }

◆ operator==()

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

Definition at line 1107 of file pixel_arithmetic.h.

1107  {
1108  return (r == P.r) && (g == P.g) && (b == P.b) && (a == P.a);
1109  }

◆ operator=() [1/6]

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

Definition at line 1111 of file pixel_arithmetic.h.

1111  {
1112  r = g = b = P.x;
1113  a = 255;
1114  }

◆ operator=() [2/6]

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

Definition at line 1116 of file pixel_arithmetic.h.

1116  {
1117  r = g = b = (int)roundf_fast(P.x * 255.0f);
1118  a = 255;
1119  }
#define roundf_fast(X)
rounding (nearest integer)
Definition: utils.hpp:22

◆ operator=() [3/6]

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

Definition at line 1121 of file pixel_arithmetic.h.

1121  {
1122  r = P.r;
1123  g = P.g;
1124  b = P.b;
1125  a = 255;
1126  }

◆ operator=() [4/6]

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

Definition at line 1128 of file pixel_arithmetic.h.

1128  {
1129  r = (int)roundf_fast(P.r * 255.0f);
1130  g = (int)roundf_fast(P.g * 255.0f);
1131  b = (int)roundf_fast(P.b * 255.0f);
1132  a = 255;
1133  }

◆ operator=() [5/6]

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

Definition at line 1135 of file pixel_arithmetic.h.

1135  {
1136  r = P.r;
1137  g = P.g;
1138  b = P.b;
1139  a = P.a;
1140  }

◆ operator=() [6/6]

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

Definition at line 1142 of file pixel_arithmetic.h.

1142  {
1143  r = (int)roundf_fast(P.r * 255.0f);
1144  g = (int)roundf_fast(P.g * 255.0f);
1145  b = (int)roundf_fast(P.b * 255.0f);
1146  a = (int)roundf_fast(P.a * 255.0f);
1147  }

◆ operator+() [1/8]

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

Definition at line 1150 of file pixel_arithmetic.h.

1150  {
1151  return pixint4(r + P, g + P, b + P, a + P);
1152  }

◆ operator+() [2/8]

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

Definition at line 1154 of file pixel_arithmetic.h.

1154  {
1155  return pixfloat4(r / 255.0f + P, g / 255.0f + P, b / 255.0f + P, a / 255.0f + P);
1156  }

◆ operator+() [3/8]

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

Definition at line 1158 of file pixel_arithmetic.h.

1158  {
1159  return pixint4(r + P.x, g + P.x, b + P.x, a + 255);
1160  }

◆ operator+() [4/8]

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

Definition at line 1170 of file pixel_arithmetic.h.

1170  {
1171  return pixfloat4(r / 255.0f + P.x, g / 255.0f + P.x, b / 255.0f + P.x, a / 255.0f + 1.0f);
1172  }

◆ operator+() [5/8]

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

Definition at line 1162 of file pixel_arithmetic.h.

1162  {
1163  return pixint4(r + P.r, g + P.g, b + P.b, a + 255);
1164  }

◆ operator+() [6/8]

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

Definition at line 1174 of file pixel_arithmetic.h.

1174  {
1175  return pixfloat4(r / 255.0f + P.r, g / 255.0f + P.g, b / 255.0f + P.b, a / 255.0f + 1.0f);
1176  }

◆ operator+() [7/8]

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

Definition at line 1166 of file pixel_arithmetic.h.

1166  {
1167  return pixint4(r + P.r, g + P.g, b + P.b, a + P.a);
1168  }

◆ operator+() [8/8]

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

Definition at line 1178 of file pixel_arithmetic.h.

1178  {
1179  return pixfloat4(r / 255.0f + P.r, g / 255.0f + P.g, b / 255.0f + P.b, a / 255.0f + P.a);
1180  }

◆ operator-() [1/8]

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

Definition at line 1183 of file pixel_arithmetic.h.

1183  {
1184  return pixint4(r - P, g - P, b - P, a - P);
1185  }

◆ operator-() [2/8]

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

Definition at line 1187 of file pixel_arithmetic.h.

1187  {
1188  return pixfloat4(r / 255.0f - P, g / 255.0f - P, b / 255.0f - P, a / 255.0f - P);
1189  }

◆ operator-() [3/8]

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

Definition at line 1191 of file pixel_arithmetic.h.

1191  {
1192  return pixint4(r - P.x, g - P.x, b - P.x, a - 255);
1193  }

◆ operator-() [4/8]

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

Definition at line 1203 of file pixel_arithmetic.h.

1203  {
1204  return pixfloat4(r / 255.0f - P.x, g / 255.0f - P.x, b / 255.0f - P.x, a / 255.0f - 1.0f);
1205  }

◆ operator-() [5/8]

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

Definition at line 1195 of file pixel_arithmetic.h.

1195  {
1196  return pixint4(r - P.r, g - P.g, b - P.b, a - 255);
1197  }

◆ operator-() [6/8]

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

Definition at line 1207 of file pixel_arithmetic.h.

1207  {
1208  return pixfloat4(r / 255.0f - P.r, g / 255.0f - P.g, b / 255.0f - P.b, a / 255.0f - 1.0f);
1209  }

◆ operator-() [7/8]

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

Definition at line 1199 of file pixel_arithmetic.h.

1199  {
1200  return pixint4(r - P.r, g - P.g, b - P.b, a - P.a);
1201  }

◆ operator-() [8/8]

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

Definition at line 1211 of file pixel_arithmetic.h.

1211  {
1212  return pixfloat4(r / 255.0f - P.r, g / 255.0f - P.g, b / 255.0f - P.b, a / 255.0f - P.a);
1213  }

◆ operator*() [1/8]

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

Definition at line 1216 of file pixel_arithmetic.h.

1216  {
1217  return pixint4(r * P, g * P, b * P, a * P);
1218  }

◆ operator*() [2/8]

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

Definition at line 1220 of file pixel_arithmetic.h.

1220  {
1221  return pixfloat4(r * P / 255.0f, g * P / 255.0f, b * P / 255.0f, a * P / 255.0f);
1222  }

◆ operator*() [3/8]

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

Definition at line 1224 of file pixel_arithmetic.h.

1224  {
1225  return pixint4(r * P.x / 255, g * P.x / 255, b * P.x / 255, a);
1226  }

◆ operator*() [4/8]

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

Definition at line 1236 of file pixel_arithmetic.h.

1236  {
1237  return pixfloat4(r * P.x / 255.0f, g * P.x / 255.0f, b * P.x / 255.0f, a / 255.0f);
1238  }

◆ operator*() [5/8]

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

Definition at line 1228 of file pixel_arithmetic.h.

1228  {
1229  return pixint4(r * P.r / 255, g * P.g / 255, b * P.b / 255, a);
1230  }

◆ operator*() [6/8]

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

Definition at line 1240 of file pixel_arithmetic.h.

1240  {
1241  return pixfloat4(r * P.r / 255.0f, g * P.g / 255.0f, b * P.b / 255.0f, a / 255.0f);
1242  }

◆ operator*() [7/8]

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

Definition at line 1232 of file pixel_arithmetic.h.

1232  {
1233  return pixint4(r * P.r / 255, g * P.g / 255, b * P.b / 255, a * P.a / 255);
1234  }

◆ operator*() [8/8]

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

Definition at line 1244 of file pixel_arithmetic.h.

1244  {
1245  return pixfloat4(r * P.r / 255.0f, g * P.g / 255.0f, b * P.b / 255.0f, a * P.a / 255.0f);
1246  }

◆ operator/()

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

Definition at line 1249 of file pixel_arithmetic.h.

1249  {
1250  return pixint4(r / P, g / P, b / P, a / P);
1251  }

◆ makeFloat()

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

Definition at line 1254 of file pixel_arithmetic.h.

1254  {
1255  return pixfloat4(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f);
1256  }

◆ zero()

void Beatmup::pixint4::zero ( )
inline

Definition at line 309 of file pixel_arithmetic.h.

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

◆ sum()

int Beatmup::pixint4::sum ( ) const
inline

Definition at line 310 of file pixel_arithmetic.h.

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

◆ mean()

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

Definition at line 311 of file pixel_arithmetic.h.

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

◆ max()

int Beatmup::pixint4::max ( ) const
inline

Definition at line 312 of file pixel_arithmetic.h.

312 { 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()

pixint4 Beatmup::pixint4::abs ( ) const
inline

Definition at line 313 of file pixel_arithmetic.h.

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

Member Data Documentation

◆ r

int Beatmup::pixint4::r

Definition at line 262 of file pixel_arithmetic.h.

◆ g

int Beatmup::pixint4::g

Definition at line 262 of file pixel_arithmetic.h.

◆ b

int Beatmup::pixint4::b

Definition at line 262 of file pixel_arithmetic.h.

◆ a

int Beatmup::pixint4::a

Definition at line 262 of file pixel_arithmetic.h.

◆ val

int Beatmup::pixint4::val[4]

Definition at line 265 of file pixel_arithmetic.h.

◆ 

union { ... }

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