Skip to content

Commit

Permalink
Added Color::ToUIntArgb() for converting colors to format profiler ex…
Browse files Browse the repository at this point in the history
…pects
  • Loading branch information
rokups committed Jun 28, 2017
1 parent 75fc862 commit d24c488
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Source/Atomic/Math/Color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,17 @@ void Color::FromHCM(float h, float c, float m)
b_ += m;
}

/// ATOMIC BEGIN
unsigned Color::ToUIntArgb() const
{
unsigned r = (unsigned)Clamp(((int)(r_ * 255.0f)), 0, 255);
unsigned g = (unsigned)Clamp(((int)(g_ * 255.0f)), 0, 255);
unsigned b = (unsigned)Clamp(((int)(b_ * 255.0f)), 0, 255);
unsigned a = (unsigned)Clamp(((int)(a_ * 255.0f)), 0, 255);
return (a << 24) | (r << 16) | (g << 8) | b;
}
/// ATOMIC END


const Color Color::WHITE;
const Color Color::GRAY(0.5f, 0.5f, 0.5f);
Expand All @@ -342,4 +353,5 @@ const Color Color::CYAN(0.0f, 1.0f, 1.0f);
const Color Color::MAGENTA(1.0f, 0.0f, 1.0f);
const Color Color::YELLOW(1.0f, 1.0f, 0.0f);
const Color Color::TRANSPARENT(0.0f, 0.0f, 0.0f, 0.0f);

}
7 changes: 7 additions & 0 deletions Source/Atomic/Math/Color.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@ class ATOMIC_API Color
/// Return as string.
String ToString() const;

// ATOMIC BEGIN

/// Return color packed to a 32-bit integer, with B component in the lowest 8 bits. Components are clamped to [0, 1] range.
unsigned ToUIntArgb() const;

// ATOMIC END

/// Red value.
float r_;
/// Green value.
Expand Down

0 comments on commit d24c488

Please sign in to comment.