Beatmup
Beatmup::pixint3 Struct Reference

Trichromatic integer arithmetic. More...

#include <pixel_arithmetic.h>

Public Types

typedef int operating_type
 

Public Member Functions

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

Public Attributes

int r
 
int g
 
int b
 

Detailed Description

Trichromatic integer arithmetic.

Definition at line 144 of file pixel_arithmetic.h.

Member Typedef Documentation

◆ operating_type

Definition at line 145 of file pixel_arithmetic.h.

Constructor & Destructor Documentation

◆ pixint3() [1/3]

Beatmup::pixint3::pixint3 ( )
inline

Definition at line 147 of file pixel_arithmetic.h.

◆ pixint3() [2/3]

Beatmup::pixint3::pixint3 ( const color3i _)
inline

Definition at line 148 of file pixel_arithmetic.h.

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

◆ pixint3() [3/3]

Beatmup::pixint3::pixint3 ( int  r,
int  g,
int  b 
)
inline

Definition at line 149 of file pixel_arithmetic.h.

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

Member Function Documentation

◆ operator pixint1()

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

Definition at line 746 of file pixel_arithmetic.h.

746  {
747  return pixint1{(r + g + b) / 3};
748  }

◆ operator pixint4()

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

Definition at line 750 of file pixel_arithmetic.h.

750  {
751  return pixint4(r, g, b, 255);
752  }

◆ operator pixfloat1()

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

Definition at line 754 of file pixel_arithmetic.h.

754  {
755  return pixfloat1{ (r + g + b) / (3 * 255.0f) };
756  }

◆ operator pixfloat3()

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

Definition at line 758 of file pixel_arithmetic.h.

758  {
759  return pixfloat3{ r / 255.0f, g / 255.0f, b / 255.0f };
760  }

◆ operator pixfloat4()

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

Definition at line 762 of file pixel_arithmetic.h.

762  {
763  return pixfloat4{ r / 255.0f, g / 255.0f, b / 255.0f, 1 };
764  }

◆ operator==()

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

Definition at line 766 of file pixel_arithmetic.h.

766  {
767  return (r == P.r) && (g == P.g) && (b == P.b);
768  }

◆ operator=() [1/6]

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

Definition at line 770 of file pixel_arithmetic.h.

770  {
771  r = g = b = P.x;
772  }

◆ operator=() [2/6]

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

Definition at line 774 of file pixel_arithmetic.h.

774  {
775  r = g = b = (int)roundf_fast(P.x * 255.0f);
776  }
#define roundf_fast(X)
rounding (nearest integer)
Definition: utils.hpp:22

◆ operator=() [3/6]

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

Definition at line 778 of file pixel_arithmetic.h.

778  {
779  r = P.r;
780  g = P.g;
781  b = P.b;
782  }

◆ operator=() [4/6]

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

Definition at line 784 of file pixel_arithmetic.h.

784  {
785  r = (int)roundf_fast(P.r * 255.0f);
786  g = (int)roundf_fast(P.g * 255.0f);
787  b = (int)roundf_fast(P.b * 255.0f);
788  }

◆ operator=() [5/6]

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

Definition at line 790 of file pixel_arithmetic.h.

790  {
791  r = P.r;
792  g = P.g;
793  b = P.b;
794  }

◆ operator=() [6/6]

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

Definition at line 796 of file pixel_arithmetic.h.

796  {
797  r = (int)roundf_fast(P.r * 255.0f);
798  g = (int)roundf_fast(P.g * 255.0f);
799  b = (int)roundf_fast(P.b * 255.0f);
800  }

◆ operator+() [1/8]

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

Definition at line 803 of file pixel_arithmetic.h.

803  {
804  return pixint3{ r + P, g + P, b + P };
805  }

◆ operator+() [2/8]

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

Definition at line 807 of file pixel_arithmetic.h.

807  {
808  return pixfloat3{ r / 255.0f + P, g / 255.0f + P, b / 255.0f + P };
809  }

◆ operator+() [3/8]

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

Definition at line 811 of file pixel_arithmetic.h.

811  {
812  return pixint3{ r + P.x, g + P.x, b + P.x };
813  }

◆ operator+() [4/8]

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

Definition at line 823 of file pixel_arithmetic.h.

823  {
824  return pixfloat3{ r / 255.0f + P.x, g / 255.0f + P.x, b / 255.0f + P.x };
825  }

◆ operator+() [5/8]

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

Definition at line 815 of file pixel_arithmetic.h.

815  {
816  return pixint3{ r + P.r, g + P.g, b + P.b };
817  }

◆ operator+() [6/8]

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

Definition at line 827 of file pixel_arithmetic.h.

827  {
828  return pixfloat3{ r / 255.0f + P.r, g / 255.0f + P.g, b / 255.0f + P.b };
829  }

◆ operator+() [7/8]

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

Definition at line 819 of file pixel_arithmetic.h.

819  {
820  return pixint4(r + P.r, g + P.g, b + P.b, 255 + P.a);
821  }

◆ operator+() [8/8]

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

Definition at line 831 of file pixel_arithmetic.h.

831  {
832  return pixfloat4(r / 255.0f + P.r, g / 255.0f + P.g, b / 255.0f + P.b, 1.0f + P.a);
833  }

◆ operator-() [1/8]

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

Definition at line 836 of file pixel_arithmetic.h.

836  {
837  return pixint3{ r - P, g - P, b - P };
838  }

◆ operator-() [2/8]

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

Definition at line 840 of file pixel_arithmetic.h.

840  {
841  return pixfloat3{ r / 255.0f - P, g / 255.0f - P, b / 255.0f - P };
842  }

◆ operator-() [3/8]

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

Definition at line 844 of file pixel_arithmetic.h.

844  {
845  return pixint3{ r - P.x, g - P.x, b - P.x };
846  }

◆ operator-() [4/8]

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

Definition at line 856 of file pixel_arithmetic.h.

856  {
857  return pixfloat3{ r / 255.0f - P.x, g / 255.0f - P.x, b / 255.0f - P.x };
858  }

◆ operator-() [5/8]

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

Definition at line 848 of file pixel_arithmetic.h.

848  {
849  return pixint3{ r - P.r, g - P.g, b - P.b };
850  }

◆ operator-() [6/8]

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

Definition at line 860 of file pixel_arithmetic.h.

860  {
861  return pixfloat3{ r / 255.0f - P.r, g / 255.0f - P.g, b / 255.0f - P.b };
862  }

◆ operator-() [7/8]

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

Definition at line 852 of file pixel_arithmetic.h.

852  {
853  return pixint4(r - P.r, g - P.g, b - P.b, 255 - P.a);
854  }

◆ operator-() [8/8]

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

Definition at line 864 of file pixel_arithmetic.h.

864  {
865  return pixfloat4(r / 255.0f - P.r, g / 255.0f - P.g, b / 255.0f - P.b, 1.0f - P.a);
866  }

◆ operator*() [1/8]

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

Definition at line 869 of file pixel_arithmetic.h.

869  {
870  return pixint3{ r * P, g * P, b * P };
871  }

◆ operator*() [2/8]

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

Definition at line 873 of file pixel_arithmetic.h.

873  {
874  return pixfloat3{ r * P / 255.0f, g * P / 255.0f, b * P / 255.0f };
875  }

◆ operator*() [3/8]

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

Definition at line 877 of file pixel_arithmetic.h.

877  {
878  return pixint3{ r * P.x / 255, g * P.x / 255, b * P.x / 255 };
879  }

◆ operator*() [4/8]

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

Definition at line 889 of file pixel_arithmetic.h.

889  {
890  return pixfloat3{ r * P.x / 255.0f, g * P.x / 255.0f, b * P.x / 255.0f };
891  }

◆ operator*() [5/8]

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

Definition at line 881 of file pixel_arithmetic.h.

881  {
882  return pixint3{ r * P.r / 255, g * P.g / 255, b * P.b / 255 };
883  }

◆ operator*() [6/8]

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

Definition at line 893 of file pixel_arithmetic.h.

893  {
894  return pixfloat3{ r * P.r / 255.0f, g * P.g / 255.0f, b * P.b / 255.0f };
895  }

◆ operator*() [7/8]

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

Definition at line 885 of file pixel_arithmetic.h.

885  {
886  return pixint4(r * P.r / 255, g * P.g / 255, b * P.b / 255, P.a);
887  }

◆ operator*() [8/8]

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

Definition at line 897 of file pixel_arithmetic.h.

897  {
898  return pixfloat4(r * P.r / 255.0f, g * P.g / 255.0f, b * P.b / 255.0f, P.a);
899  }

◆ operator/()

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

Definition at line 902 of file pixel_arithmetic.h.

902  {
903  return pixint3{ r / P, g / P, b / P };
904  }

◆ makeFloat()

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

Definition at line 907 of file pixel_arithmetic.h.

907  {
908  return pixfloat3{ r / 255.0f, g / 255.0f, b / 255.0f };
909  }

◆ zero()

void Beatmup::pixint3::zero ( )
inline

Definition at line 188 of file pixel_arithmetic.h.

188 { r = g = b = 0; }

◆ sum()

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

Definition at line 189 of file pixel_arithmetic.h.

189 { return r + g + b; }

◆ mean()

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

Definition at line 190 of file pixel_arithmetic.h.

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

◆ max()

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

Definition at line 191 of file pixel_arithmetic.h.

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

◆ abs()

pixint3 Beatmup::pixint3::abs ( ) const
inline

Definition at line 192 of file pixel_arithmetic.h.

192 { return pixint3(r > 0 ? r : -r, g > 0 ? g : -g, b > 0 ? b : -b); }

Member Data Documentation

◆ r

int Beatmup::pixint3::r

Definition at line 146 of file pixel_arithmetic.h.

◆ g

int Beatmup::pixint3::g

Definition at line 146 of file pixel_arithmetic.h.

◆ b

int Beatmup::pixint3::b

Definition at line 146 of file pixel_arithmetic.h.


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