Beatmup
Beatmup::pixint1 Struct Reference

Monochromatic integer arithmetic. More...

#include <pixel_arithmetic.h>

Public Types

typedef int operating_type
 

Public Member Functions

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

Public Attributes

int x
 

Detailed Description

Monochromatic integer arithmetic.

Definition at line 42 of file pixel_arithmetic.h.

Member Typedef Documentation

◆ operating_type

Definition at line 43 of file pixel_arithmetic.h.

Member Function Documentation

◆ operator pixint3()

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

Definition at line 420 of file pixel_arithmetic.h.

420  {
421  return pixint3{ x, x, x };
422  }

◆ operator pixint4()

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

Definition at line 424 of file pixel_arithmetic.h.

424  {
425  return pixint4(x, x, x, 255);
426  }

◆ operator pixfloat1()

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

Definition at line 428 of file pixel_arithmetic.h.

428  {
429  return pixfloat1{ x / 255.0f };
430  }

◆ operator pixfloat3()

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

Definition at line 432 of file pixel_arithmetic.h.

432  {
433  float _ = x / 255.0f;
434  return pixfloat3{ _, _, _ };
435  }

◆ operator pixfloat4()

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

Definition at line 437 of file pixel_arithmetic.h.

437  {
438  float _ = x / 255.0f;
439  return pixfloat4{ _, _, _, 1 };
440  }

◆ operator==()

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

Definition at line 442 of file pixel_arithmetic.h.

442  {
443  return x == P.x;
444  }

◆ operator=() [1/6]

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

Definition at line 446 of file pixel_arithmetic.h.

446  {
447  x = P.x;
448  }

◆ operator=() [2/6]

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

Definition at line 458 of file pixel_arithmetic.h.

458  {
459  x = (int)roundf_fast(P.x * 255.0f);
460  }
#define roundf_fast(X)
rounding (nearest integer)
Definition: utils.hpp:22

◆ operator=() [3/6]

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

Definition at line 450 of file pixel_arithmetic.h.

450  {
451  x = (P.r + P.g + P.b) / 3;
452  }

◆ operator=() [4/6]

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

Definition at line 462 of file pixel_arithmetic.h.

462  {
463  x = (int)roundf_fast((P.r + P.g + P.b) * 255.0f / 3);
464  }

◆ operator=() [5/6]

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

Definition at line 454 of file pixel_arithmetic.h.

454  {
455  x = (P.r + P.g + P.b) / 3;
456  }

◆ operator=() [6/6]

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

Definition at line 466 of file pixel_arithmetic.h.

466  {
467  x = (int)roundf_fast((P.r + P.g + P.b) * 255.0f / 3);
468  }

◆ operator+() [1/8]

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

Definition at line 471 of file pixel_arithmetic.h.

471  {
472  return pixint1{ x + P };
473  }

◆ operator+() [2/8]

pixfloat1 Beatmup::pixint1::operator+ ( const float  P) const
inline

Definition at line 475 of file pixel_arithmetic.h.

475  {
476  return pixfloat1{ x / 255.0f + P };
477  }

◆ operator+() [3/8]

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

Definition at line 479 of file pixel_arithmetic.h.

479  {
480  return pixint1{ x + P.x };
481  }

◆ operator+() [4/8]

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

Definition at line 491 of file pixel_arithmetic.h.

491  {
492  return pixfloat1{ x / 255.0f + P.x };
493  }

◆ operator+() [5/8]

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

Definition at line 483 of file pixel_arithmetic.h.

483  {
484  return pixint3{ x + P.r, x + P.g, x + P.b };
485  }

◆ operator+() [6/8]

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

Definition at line 495 of file pixel_arithmetic.h.

495  {
496  return pixfloat3{ x / 255.0f + P.r, x / 255.0f + P.g, x / 255.0f + P.b };
497  }

◆ operator+() [7/8]

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

Definition at line 487 of file pixel_arithmetic.h.

487  {
488  return pixint4(x + P.r, x + P.g, x + P.b, 255 + P.a);
489  }

◆ operator+() [8/8]

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

Definition at line 499 of file pixel_arithmetic.h.

499  {
500  return pixfloat4(x / 255.0f + P.r, x / 255.0f + P.g, x / 255.0f + P.b, 1.0f + P.a);
501  }

◆ operator-() [1/8]

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

Definition at line 504 of file pixel_arithmetic.h.

504  {
505  return pixint1{ x - P };
506  }

◆ operator-() [2/8]

pixfloat1 Beatmup::pixint1::operator- ( const float  P) const
inline

Definition at line 508 of file pixel_arithmetic.h.

508  {
509  return pixfloat1{ x / 255.0f - P };
510  }

◆ operator-() [3/8]

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

Definition at line 512 of file pixel_arithmetic.h.

512  {
513  return pixint1{ x - P.x };
514  }

◆ operator-() [4/8]

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

Definition at line 524 of file pixel_arithmetic.h.

524  {
525  return pixfloat1{ x / 255.0f - P.x };
526  }

◆ operator-() [5/8]

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

Definition at line 516 of file pixel_arithmetic.h.

516  {
517  return pixint3{ x - P.r, x - P.g, x - P.b };
518  }

◆ operator-() [6/8]

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

Definition at line 528 of file pixel_arithmetic.h.

528  {
529  return pixfloat3{ x / 255.0f - P.r, x / 255.0f - P.g, x / 255.0f - P.b };
530  }

◆ operator-() [7/8]

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

Definition at line 520 of file pixel_arithmetic.h.

520  {
521  return pixint4(x - P.r, x - P.g, x - P.b, 255 - P.a);
522  }

◆ operator-() [8/8]

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

Definition at line 532 of file pixel_arithmetic.h.

532  {
533  return pixfloat4(x / 255.0f - P.r, x / 255.0f - P.g, x / 255.0f - P.b, 1.0f - P.a);
534  }

◆ operator*() [1/8]

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

Definition at line 537 of file pixel_arithmetic.h.

537  {
538  return pixint1{ x * P };
539  }

◆ operator*() [2/8]

pixfloat1 Beatmup::pixint1::operator* ( const float  P) const
inline

Definition at line 541 of file pixel_arithmetic.h.

541  {
542  return pixfloat1{ x * P / 255.0f };
543  }

◆ operator*() [3/8]

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

Definition at line 545 of file pixel_arithmetic.h.

545  {
546  return pixint1{ x * P.x };
547  }

◆ operator*() [4/8]

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

Definition at line 557 of file pixel_arithmetic.h.

557  {
558  return pixfloat1{ x * P.x / 255.0f };
559  }

◆ operator*() [5/8]

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

Definition at line 549 of file pixel_arithmetic.h.

549  {
550  return pixint3{ x * P.r, x * P.g, x * P.b };
551  }

◆ operator*() [6/8]

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

Definition at line 561 of file pixel_arithmetic.h.

561  {
562  return pixfloat3{ x * P.r / 255.0f, x * P.g / 255.0f, x * P.b / 255.0f };
563  }

◆ operator*() [7/8]

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

Definition at line 553 of file pixel_arithmetic.h.

553  {
554  return pixint4(x * P.r, x * P.g, x * P.b, P.a);
555  }

◆ operator*() [8/8]

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

Definition at line 565 of file pixel_arithmetic.h.

565  {
566  return pixfloat4(x * P.r / 255.0f, x * P.g / 255.0f, x * P.b / 255.0f, P.a);
567  }

◆ operator/()

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

Definition at line 570 of file pixel_arithmetic.h.

570  {
571  return pixint1{ x / P };
572  }

◆ makeFloat()

pixfloat1 Beatmup::pixint1::makeFloat ( ) const
inline

Definition at line 575 of file pixel_arithmetic.h.

575  {
576  return pixfloat1{ x / 255.0f };
577  }

◆ zero()

void Beatmup::pixint1::zero ( )
inline

Definition at line 83 of file pixel_arithmetic.h.

83 { x = 0; }

◆ sum()

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

Definition at line 84 of file pixel_arithmetic.h.

84 { return x; }

◆ mean()

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

Definition at line 85 of file pixel_arithmetic.h.

85 { return (float)x; }

◆ max()

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

Definition at line 86 of file pixel_arithmetic.h.

86 { return x; }

◆ abs()

pixint1 Beatmup::pixint1::abs ( ) const
inline

Definition at line 87 of file pixel_arithmetic.h.

87 { return pixint1{ x > 0 ? x : -x }; }

Member Data Documentation

◆ x

int Beatmup::pixint1::x

Definition at line 44 of file pixel_arithmetic.h.


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