Beatmup
Beatmup::pixfloat1 Struct Reference

Monochromatic floating point arithmetic. More...

#include <pixel_arithmetic.h>

Public Types

typedef float operating_type
 

Public Member Functions

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

Public Attributes

pixfloat x
 

Detailed Description

Monochromatic floating point arithmetic.

Definition at line 93 of file pixel_arithmetic.h.

Member Typedef Documentation

◆ operating_type

Definition at line 94 of file pixel_arithmetic.h.

Member Function Documentation

◆ operator pixint1()

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

Definition at line 583 of file pixel_arithmetic.h.

583  {
584  return pixint1{ roundf_fast(x * 255) };
585  }
#define roundf_fast(X)
rounding (nearest integer)
Definition: utils.hpp:22

◆ operator pixint3()

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

Definition at line 587 of file pixel_arithmetic.h.

587  {
588  int _ = roundf_fast(x * 255);
589  return pixint3{ _, _, _ };
590  }

◆ operator pixint4()

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

Definition at line 592 of file pixel_arithmetic.h.

592  {
593  int _ = roundf_fast(x * 255);
594  return pixint4(_, _, _, 255);
595  }

◆ operator pixfloat3()

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

Definition at line 597 of file pixel_arithmetic.h.

597  {
598  return pixfloat3{ x, x, x };
599  }

◆ operator pixfloat4()

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

Definition at line 601 of file pixel_arithmetic.h.

601  {
602  return pixfloat4{ x, x, x, 1 };
603  }

◆ operator==()

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

Definition at line 605 of file pixel_arithmetic.h.

605  {
606  return x == P.x;
607  }

◆ operator=() [1/6]

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

Definition at line 609 of file pixel_arithmetic.h.

609  {
610  x = P.x / 255.0f;
611  }

◆ operator=() [2/6]

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

Definition at line 613 of file pixel_arithmetic.h.

613  {
614  x = P.x;
615  }

◆ operator=() [3/6]

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

Definition at line 617 of file pixel_arithmetic.h.

617  {
618  x = (P.r + P.g + P.b) / 765.0f;
619  }

◆ operator=() [4/6]

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

Definition at line 621 of file pixel_arithmetic.h.

621  {
622  x = (P.r + P.g + P.b) / 3;
623  }

◆ operator=() [5/6]

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

Definition at line 625 of file pixel_arithmetic.h.

625  {
626  x = (P.r + P.g + P.b) / 765.0f;
627  }

◆ operator=() [6/6]

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

Definition at line 629 of file pixel_arithmetic.h.

629  {
630  x = (P.r + P.g + P.b) / 3;
631  }

◆ operator+() [1/8]

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

Definition at line 634 of file pixel_arithmetic.h.

634  {
635  return pixfloat1{ x + P };
636  }

◆ operator+() [2/8]

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

Definition at line 638 of file pixel_arithmetic.h.

638  {
639  return pixfloat1{ x + P };
640  }

◆ operator+() [3/8]

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

Definition at line 642 of file pixel_arithmetic.h.

642  {
643  return pixfloat1{ x + P.x / 255.0f };
644  }

◆ operator+() [4/8]

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

Definition at line 654 of file pixel_arithmetic.h.

654  {
655  return pixfloat1{ x + P.x };
656  }

◆ operator+() [5/8]

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

Definition at line 646 of file pixel_arithmetic.h.

646  {
647  return pixfloat3{ x + P.r / 255.0f, x + P.g / 255.0f, x + P.b / 255.0f };
648  }

◆ operator+() [6/8]

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

Definition at line 658 of file pixel_arithmetic.h.

658  {
659  return pixfloat3{ x + P.r, x + P.g, x + P.b };
660  }

◆ operator+() [7/8]

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

Definition at line 650 of file pixel_arithmetic.h.

650  {
651  return pixfloat4(x + P.r / 255.0f, x + P.g / 255.0f, x + P.b / 255.0f, 1.0f + P.a / 255.0f);
652  }

◆ operator+() [8/8]

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

Definition at line 662 of file pixel_arithmetic.h.

662  {
663  return pixfloat4(x + P.r, x + P.g, x + P.b, 1.0f + P.a);
664  }

◆ operator-() [1/8]

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

Definition at line 667 of file pixel_arithmetic.h.

667  {
668  return pixfloat1{ x - P / 255.0f };
669  }

◆ operator-() [2/8]

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

Definition at line 671 of file pixel_arithmetic.h.

671  {
672  return pixfloat1{ x - P };
673  }

◆ operator-() [3/8]

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

Definition at line 675 of file pixel_arithmetic.h.

675  {
676  return pixfloat1{ x - P.x / 255.0f };
677  }

◆ operator-() [4/8]

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

Definition at line 687 of file pixel_arithmetic.h.

687  {
688  return pixfloat1{ x - P.x };
689  }

◆ operator-() [5/8]

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

Definition at line 679 of file pixel_arithmetic.h.

679  {
680  return pixfloat3{ x - P.r / 255.0f, x - P.g / 255.0f, x - P.b / 255.0f };
681  }

◆ operator-() [6/8]

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

Definition at line 691 of file pixel_arithmetic.h.

691  {
692  return pixfloat3{ x - P.r, x - P.g, x - P.b };
693  }

◆ operator-() [7/8]

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

Definition at line 683 of file pixel_arithmetic.h.

683  {
684  return pixfloat4(x - P.r / 255.0f, x - P.g / 255.0f, x - P.b / 255.0f, 1.0f - P.a / 255.0f);
685  }

◆ operator-() [8/8]

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

Definition at line 695 of file pixel_arithmetic.h.

695  {
696  return pixfloat4(x - P.r, x - P.g, x - P.b, 1.0f - P.a);
697  }

◆ operator*() [1/8]

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

Definition at line 700 of file pixel_arithmetic.h.

700  {
701  return pixfloat1{ x * P };
702  }

◆ operator*() [2/8]

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

Definition at line 704 of file pixel_arithmetic.h.

704  {
705  return pixfloat1{ x * P };
706  }

◆ operator*() [3/8]

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

Definition at line 708 of file pixel_arithmetic.h.

708  {
709  return pixfloat1{ x * P.x / 255.0f };
710  }

◆ operator*() [4/8]

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

Definition at line 720 of file pixel_arithmetic.h.

720  {
721  return pixfloat1{ x * P.x };
722  }

◆ operator*() [5/8]

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

Definition at line 712 of file pixel_arithmetic.h.

712  {
713  return pixfloat3{ x * P.r / 255.0f, x * P.g / 255.0f, x * P.b / 255.0f };
714  }

◆ operator*() [6/8]

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

Definition at line 724 of file pixel_arithmetic.h.

724  {
725  return pixfloat3{ x * P.r, x * P.g, x * P.b };
726  }

◆ operator*() [7/8]

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

Definition at line 716 of file pixel_arithmetic.h.

716  {
717  return pixfloat4(x * P.r / 255.0f, x * P.g / 255.0f, x * P.b / 255.0f, P.a / 255.0f);
718  }

◆ operator*() [8/8]

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

Definition at line 728 of file pixel_arithmetic.h.

728  {
729  return pixfloat4(x * P.r, x * P.g, x * P.b, P.a);
730  }

◆ operator/()

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

Definition at line 733 of file pixel_arithmetic.h.

733  {
734  return pixfloat1{ x / P };
735  }

◆ makeFloat()

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

Definition at line 738 of file pixel_arithmetic.h.

738  {
739  return *this;
740  }

◆ zero()

void Beatmup::pixfloat1::zero ( )
inline

Definition at line 134 of file pixel_arithmetic.h.

134 { x = 0; }

◆ sum()

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

Definition at line 135 of file pixel_arithmetic.h.

135 { return x; }

◆ mean()

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

Definition at line 136 of file pixel_arithmetic.h.

136 { return x; }

◆ max()

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

Definition at line 137 of file pixel_arithmetic.h.

137 { return x; }

◆ abs()

pixfloat1 Beatmup::pixfloat1::abs ( ) const
inline

Definition at line 138 of file pixel_arithmetic.h.

138 { return pixfloat1{ x > 0 ? x : -x }; }

Member Data Documentation

◆ x

pixfloat Beatmup::pixfloat1::x

Definition at line 95 of file pixel_arithmetic.h.


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