Beatmup
Beatmup::Color::hsva_t Struct Reference

HSVA quad (for hue, saturation, value and alpha) More...

#include <color_spaces.h>

Public Member Functions

 hsva_t (pixfloat r, pixfloat g, pixfloat b)
 Constructs an HSVA quad from r, g, b, a values. More...
 
 operator pixfloat4 () const
 Conversion to pixfloat. More...
 
 hsva_t ()
 
 hsva_t (const color3i &_)
 
 hsva_t (const color4i &_)
 
 hsva_t (const color3f &_)
 
 hsva_t (const color4f &_)
 
 hsva_t (const pixfloat1 &_)
 
 hsva_t (const pixfloat3 &_)
 
 hsva_t (const pixfloat4 &_)
 
 hsva_t (const pixint1 &_)
 
 hsva_t (const pixint3 &_)
 
 hsva_t (const pixint4 &_)
 

Public Attributes

pixfloat h
 
pixfloat s
 
pixfloat v
 

Detailed Description

HSVA quad (for hue, saturation, value and alpha)

Definition at line 34 of file color_spaces.h.

Constructor & Destructor Documentation

◆ hsva_t() [1/12]

Beatmup::Color::hsva_t::hsva_t ( pixfloat  r,
pixfloat  g,
pixfloat  b 
)
inline

Constructs an HSVA quad from r, g, b, a values.

Definition at line 40 of file color_spaces.h.

40  {
41  v = std::max(std::max(r, g), b);
42  float C = v - std::min(std::min(r, g), b);
43  if (C == 0)
44  h = 0;
45  else if (v == r)
46  h = modf((g - b) / C, 6) / 6;
47  else if (v == g)
48  h = ((b - r) / C + 2) / 6;
49  else if (v == b)
50  h = ((r - g) / C + 4) / 6;
51  s = v > 0 ? C / v : 0;
52  }
CustomPoint< numeric > min(const CustomPoint< numeric > &a, const CustomPoint< numeric > &b)
Definition: geometry.h:724
CustomPoint< numeric > max(const CustomPoint< numeric > &a, const CustomPoint< numeric > &b)
Definition: geometry.h:728
float modf(float x, float y)
Definition: utils.hpp:32
jobject jlong jint jint jint jint g
jobject jlong jint jint jint jint jint b
jobject jlong jint jint jint r

◆ hsva_t() [2/12]

Beatmup::Color::hsva_t::hsva_t ( )
inline

Definition at line 87 of file color_spaces.h.

87 : h(0), s(0), v(0) {}

◆ hsva_t() [3/12]

Beatmup::Color::hsva_t::hsva_t ( const color3i _)
inline

Definition at line 89 of file color_spaces.h.

89 : hsva_t(_.r, _.g, _.b) {}

◆ hsva_t() [4/12]

Beatmup::Color::hsva_t::hsva_t ( const color4i _)
inline

Definition at line 90 of file color_spaces.h.

90 : hsva_t(_.r, _.g, _.b) {}

◆ hsva_t() [5/12]

Beatmup::Color::hsva_t::hsva_t ( const color3f _)
inline

Definition at line 91 of file color_spaces.h.

91 : hsva_t((float)_.r / 255, (float)_.g / 255, (float)_.b / 255) {}

◆ hsva_t() [6/12]

Beatmup::Color::hsva_t::hsva_t ( const color4f _)
inline

Definition at line 92 of file color_spaces.h.

92 : hsva_t((float)_.r / 255, (float)_.g / 255, (float)_.b / 255) {}

◆ hsva_t() [7/12]

Beatmup::Color::hsva_t::hsva_t ( const pixfloat1 _)
inline

Definition at line 94 of file color_spaces.h.

94  {
95  h = s = 0;
96  v = _.x;
97  }

◆ hsva_t() [8/12]

Beatmup::Color::hsva_t::hsva_t ( const pixfloat3 _)
inline

Definition at line 99 of file color_spaces.h.

99 : hsva_t(_.r, _.g, _.b) {}

◆ hsva_t() [9/12]

Beatmup::Color::hsva_t::hsva_t ( const pixfloat4 _)
inline

Definition at line 101 of file color_spaces.h.

101 : hsva_t(_.r, _.g, _.b) {}

◆ hsva_t() [10/12]

Beatmup::Color::hsva_t::hsva_t ( const pixint1 _)
inline

Definition at line 103 of file color_spaces.h.

103  {
104  h = s = 0;
105  v = (float)_.x / 255;
106  }

◆ hsva_t() [11/12]

Beatmup::Color::hsva_t::hsva_t ( const pixint3 _)
inline

Definition at line 108 of file color_spaces.h.

108 : hsva_t((float)_.r / 255, (float)_.g / 255, (float)_.b / 255) {}

◆ hsva_t() [12/12]

Beatmup::Color::hsva_t::hsva_t ( const pixint4 _)
inline

Definition at line 110 of file color_spaces.h.

110 : hsva_t((float)_.r / 255, (float)_.g / 255, (float)_.b / 255) {}

Member Function Documentation

◆ operator pixfloat4()

Beatmup::Color::hsva_t::operator pixfloat4 ( ) const
inline

Conversion to pixfloat.

Definition at line 58 of file color_spaces.h.

58  {
59  const float
60  H = h - (long)h + (h >= 0 ? 0 : 1),
61  C = v*s,
62  X = C*(1 - fabs(modf(H*6, 2) - 1)),
63  m = v - C;
64 
65  pixfloat4 out;
66  if (H < 1.0f / 6) {
67  out.r = C + m; out.g = X + m; out.b = m;
68  }
69  else if (H < 2.0f / 6) {
70  out.r = X + m; out.g = C + m; out.b = m;
71  }
72  else if (H < 3.0f / 6) {
73  out.r = m; out.g = C + m; out.b = X + m;
74  }
75  else if (H < 4.0f / 6) {
76  out.r = m; out.g = X + m; out.b = C + m;
77  }
78  else if (H < 5.0f / 6) {
79  out.r = X + m; out.g = m; out.b = C + m;
80  }
81  else {
82  out.r = C + m; out.g = m; out.b = X + m;
83  }
84  return out;
85  }
JNIEnv jlong jint out

Member Data Documentation

◆ h

pixfloat Beatmup::Color::hsva_t::h

Definition at line 35 of file color_spaces.h.

◆ s

pixfloat Beatmup::Color::hsva_t::s

Definition at line 35 of file color_spaces.h.

◆ v

pixfloat Beatmup::Color::hsva_t::v

Definition at line 35 of file color_spaces.h.


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