Audacity 3.2.0
Namespaces | Classes | Typedefs | Functions
graphics Namespace Reference

Namespaces

namespace  Colors
 
namespace  details
 

Classes

struct  Color
 Class for storing color in 32-bit format. More...
 
struct  PointType
 A point in 2D space. More...
 
struct  RectType
 Rectangle that is defined by the top left corner and the size. More...
 
struct  SizeType
 A class that represents size in 2D space. More...
 

Typedefs

using Point = PointType< float >
 Alias for the point with float data type. More...
 
using Rect = RectType< float >
 Alias for rectangle with float data type. More...
 
using Size = SizeType< float >
 Alias for SizeType<float> More...
 

Functions

template<typename ScaleType >
constexpr Color lerp (Color lhs, Color rhs, ScaleType t)
 Performs linear interpolation between two colors. More...
 
GRAPHICS_API constexpr Color ColorFromRGA (uint32_t rgba) noexcept
 A helper function to create a color from a 32-bit RGBA integer. More...
 
GRAPHICS_API constexpr Color ColorFromABGR (uint32_t abgr) noexcept
 A helper function to create a color from a 32-bit ABGR integer. More...
 
GRAPHICS_API constexpr Color ColorFromRGB (uint32_t rgb) noexcept
 A helper function to create a color from a 32-bit RGB integer. Alpha is set to 255. More...
 
GRAPHICS_API constexpr Color ColorFromARGB (uint32_t argb) noexcept
 A helper function to create a color from a 32-bit ARGB integer. More...
 
GRAPHICS_API constexpr Color ColorFromFloatRGBA (float r, float g, float b, float a) noexcept
 A helper function to create a color from the floating point components. More...
 
template<typename To , typename From >
PointType< To > point_cast (PointType< From > point)
 Casts a point to another point type. More...
 
template<typename DataType >
bool operator== (PointType< DataType > lhs, PointType< DataType > rhs) noexcept
 
template<typename DataType >
bool operator!= (PointType< DataType > lhs, PointType< DataType > rhs) noexcept
 
template<typename DataType >
PointType< DataType > operator+ (PointType< DataType > lhs, PointType< DataType > rhs) noexcept
 
template<typename DataType >
PointType< DataType > operator- (PointType< DataType > lhs, PointType< DataType > rhs) noexcept
 
template<typename DataType >
PointType< DataType > operator* (PointType< DataType > lhs, PointType< DataType > rhs) noexcept
 
template<typename DataType >
PointType< DataType > operator/ (PointType< DataType > lhs, PointType< DataType > rhs) noexcept
 
template<typename DataType , typename ScaleType >
PointType< DataType > operator* (PointType< DataType > lhs, ScaleType rhs) noexcept
 
template<typename DataType , typename ScaleType >
PointType< DataType > operator* (ScaleType lhs, PointType< DataType > rhs) noexcept
 
template<typename DataType , typename ScaleType >
PointType< DataType > operator/ (PointType< DataType > lhs, ScaleType rhs) noexcept
 
template<typename DataType >
auto DotProduct (PointType< DataType > lhs, PointType< DataType > rhs) noexcept
 Returns the dot (inner) product between the vectors, defined by points. More...
 
template<typename DataType >
auto Norm (PointType< DataType > lhs) noexcept
 Returns the length of a vector matching the point. More...
 
template<typename DataType >
auto Distance (PointType< DataType > lhs, PointType< DataType > rhs) noexcept
 Returns the distance between the two points. More...
 
template<typename DataType >
auto Normalized (PointType< DataType > pt) noexcept
 Returns a normalized vector in the direction of point. More...
 
template<typename DataType >
bool operator== (const RectType< DataType > lhs, const RectType< DataType > rhs) noexcept
 
template<typename DataType >
bool operator!= (const RectType< DataType > lhs, const RectType< DataType > rhs) noexcept
 
template<typename To , typename From >
RectType< To > rect_cast (RectType< From > rect)
 Cast the rectangle to another data type. More...
 
template<typename To , typename From >
SizeType< To > size_cast (SizeType< From > point)
 Casts size to another data type. More...
 
template<typename DataType >
bool operator== (SizeType< DataType > lhs, SizeType< DataType > rhs) noexcept
 
template<typename DataType >
bool operator!= (SizeType< DataType > lhs, SizeType< DataType > rhs) noexcept
 
template<typename DataType >
SizeType< DataType > operator+ (SizeType< DataType > lhs, SizeType< DataType > rhs) noexcept
 
template<typename DataType >
SizeType< DataType > operator- (SizeType< DataType > lhs, SizeType< DataType > rhs) noexcept
 
template<typename DataType >
SizeType< DataType > operator* (SizeType< DataType > lhs, SizeType< DataType > rhs) noexcept
 
template<typename DataType >
SizeType< DataType > operator/ (SizeType< DataType > lhs, SizeType< DataType > rhs) noexcept
 
template<typename DataType , typename ScaleType >
SizeType< DataType > operator* (SizeType< DataType > lhs, ScaleType rhs) noexcept
 
template<typename DataType , typename ScaleType >
SizeType< DataType > operator* (ScaleType lhs, SizeType< DataType > rhs) noexcept
 
template<typename DataType , typename ScaleType >
SizeType< DataType > operator/ (SizeType< DataType > lhs, ScaleType rhs) noexcept
 

Detailed Description


Audacity: A Digital Audio Editor

Color.h

Dmitry Vedenko


Audacity: A Digital Audio Editor

Point.h

Dmitry Vedenko


Audacity: A Digital Audio Editor

Rect.h

Dmitry Vedenko


Audacity: A Digital Audio Editor

Size.h

Dmitry Vedenko

Typedef Documentation

◆ Point

using graphics::Point = typedef PointType<float>

Alias for the point with float data type.

Definition at line 191 of file Point.h.

◆ Rect

using graphics::Rect = typedef RectType<float>

Alias for rectangle with float data type.

Definition at line 66 of file Rect.h.

◆ Size

using graphics::Size = typedef SizeType<float>

Alias for SizeType<float>

Definition at line 174 of file Size.h.

Function Documentation

◆ ColorFromABGR()

GRAPHICS_API constexpr Color graphics::ColorFromABGR ( uint32_t  abgr)
constexprnoexcept

A helper function to create a color from a 32-bit ABGR integer.

Definition at line 250 of file Color.h.

251{
252 return Color::FromABGR(abgr);
253}

References graphics::Color::FromABGR().

Here is the call graph for this function:

◆ ColorFromARGB()

GRAPHICS_API constexpr Color graphics::ColorFromARGB ( uint32_t  argb)
constexprnoexcept

A helper function to create a color from a 32-bit ARGB integer.

Definition at line 264 of file Color.h.

265{
266 return Color(
267 uint8_t((argb >> 16) & 0xFF), uint8_t((argb >> 8) & 0xFF),
268 uint8_t((argb >> 0) & 0xFF), uint8_t((argb >> 24) & 0xFF));
269}
Class for storing color in 32-bit format.
Definition: Color.h:29

◆ ColorFromFloatRGBA()

GRAPHICS_API constexpr Color graphics::ColorFromFloatRGBA ( float  r,
float  g,
float  b,
float  a 
)
constexprnoexcept

A helper function to create a color from the floating point components.

Definition at line 273 of file Color.h.

274{
275 return Color::FromFloatRGBA(r, g, b, a);
276}

References graphics::Color::FromFloatRGBA().

Here is the call graph for this function:

◆ ColorFromRGA()

GRAPHICS_API constexpr Color graphics::ColorFromRGA ( uint32_t  rgba)
constexprnoexcept

A helper function to create a color from a 32-bit RGBA integer.

Definition at line 242 of file Color.h.

243{
244 return Color(
245 uint8_t((rgba >> 24) & 0xFF), uint8_t((rgba >> 16) & 0xFF),
246 uint8_t((rgba >> 8) & 0xFF), uint8_t((rgba >> 0) & 0xFF));
247}

◆ ColorFromRGB()

GRAPHICS_API constexpr Color graphics::ColorFromRGB ( uint32_t  rgb)
constexprnoexcept

A helper function to create a color from a 32-bit RGB integer. Alpha is set to 255.

Definition at line 256 of file Color.h.

257{
258 return Color(
259 uint8_t((rgb >> 16) & 0xFF), uint8_t((rgb >> 8) & 0xFF),
260 uint8_t((rgb >> 0) & 0xFF), uint8_t(0xFF));
261}

◆ Distance()

template<typename DataType >
auto graphics::Distance ( PointType< DataType >  lhs,
PointType< DataType >  rhs 
)
noexcept

Returns the distance between the two points.

Definition at line 173 of file Point.h.

174{
175 return std::sqrt(DotProduct(lhs, rhs));
176}
auto DotProduct(PointType< DataType > lhs, PointType< DataType > rhs) noexcept
Returns the dot (inner) product between the vectors, defined by points.
Definition: Point.h:159
__finl float_x4 __vecc sqrt(const float_x4 &a)

References DotProduct(), and staffpad::audio::simd::sqrt().

Here is the call graph for this function:

◆ DotProduct()

template<typename DataType >
auto graphics::DotProduct ( PointType< DataType >  lhs,
PointType< DataType >  rhs 
)
noexcept

Returns the dot (inner) product between the vectors, defined by points.

Definition at line 159 of file Point.h.

160{
161 return lhs.x * rhs.x + lhs.y * rhs.y;
162}
DataType y
Definition: Point.h:25
DataType x
Definition: Point.h:24

Referenced by Distance(), and Norm().

Here is the caller graph for this function:

◆ lerp()

template<typename ScaleType >
constexpr Color graphics::lerp ( Color  lhs,
Color  rhs,
ScaleType  t 
)
constexpr

Performs linear interpolation between two colors.

Definition at line 233 of file Color.h.

234{
235 return { Color::Lerp(lhs.mRed, rhs.mRed, t),
236 Color::Lerp(lhs.mGreen, rhs.mGreen, t),
237 Color::Lerp(lhs.mBlue, rhs.mBlue, t),
238 Color::Lerp(lhs.mAlpha, rhs.mAlpha, t) };
239}
uint8_t mBlue
Definition: Color.h:226
uint8_t mRed
Definition: Color.h:226
uint8_t mAlpha
Definition: Color.h:226
uint8_t mGreen
Definition: Color.h:226

◆ Norm()

template<typename DataType >
auto graphics::Norm ( PointType< DataType >  lhs)
noexcept

Returns the length of a vector matching the point.

Definition at line 166 of file Point.h.

167{
168 return std::sqrt(DotProduct(lhs, lhs));
169}

References DotProduct(), and staffpad::audio::simd::sqrt().

Referenced by Normalized().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Normalized()

template<typename DataType >
auto graphics::Normalized ( PointType< DataType >  pt)
noexcept

Returns a normalized vector in the direction of point.

Definition at line 180 of file Point.h.

181{
182 const auto norm = Norm(pt);
183
184 if (norm <= std::numeric_limits<DataType>::epsilon())
185 return pt;
186
187 return pt / norm;
188}
auto Norm(PointType< DataType > lhs) noexcept
Returns the length of a vector matching the point.
Definition: Point.h:166
__m128 norm(__m128 x, __m128 y)

References simd_complex_conversions::norm(), and Norm().

Here is the call graph for this function:

◆ operator!=() [1/3]

template<typename DataType >
bool graphics::operator!= ( const RectType< DataType >  lhs,
const RectType< DataType >  rhs 
)
noexcept

Definition at line 52 of file Rect.h.

54{
55 return !(lhs == rhs);
56}

◆ operator!=() [2/3]

template<typename DataType >
bool graphics::operator!= ( PointType< DataType >  lhs,
PointType< DataType >  rhs 
)
noexcept

Definition at line 103 of file Point.h.

104{
105 return !(lhs == rhs);
106}

◆ operator!=() [3/3]

template<typename DataType >
bool graphics::operator!= ( SizeType< DataType >  lhs,
SizeType< DataType >  rhs 
)
noexcept

Definition at line 119 of file Size.h.

120{
121 return !(lhs == rhs);
122}

◆ operator*() [1/6]

template<typename DataType >
PointType< DataType > graphics::operator* ( PointType< DataType >  lhs,
PointType< DataType >  rhs 
)
noexcept

Definition at line 124 of file Point.h.

125{
126 return { lhs.x * rhs.x, lhs.y * rhs.y };
127}

◆ operator*() [2/6]

template<typename DataType , typename ScaleType >
PointType< DataType > graphics::operator* ( PointType< DataType >  lhs,
ScaleType  rhs 
)
noexcept

Definition at line 137 of file Point.h.

138{
139 return { static_cast<DataType>(lhs.x * rhs),
140 static_cast<DataType>(lhs.y * rhs) };
141}

◆ operator*() [3/6]

template<typename DataType , typename ScaleType >
PointType< DataType > graphics::operator* ( ScaleType  lhs,
PointType< DataType >  rhs 
)
noexcept

Definition at line 144 of file Point.h.

145{
146 return { static_cast<DataType>(lhs * rhs.x),
147 static_cast<DataType>(lhs * rhs.y) };
148}

◆ operator*() [4/6]

template<typename DataType , typename ScaleType >
SizeType< DataType > graphics::operator* ( ScaleType  lhs,
SizeType< DataType >  rhs 
)
noexcept

Definition at line 160 of file Size.h.

161{
162 return { static_cast<DataType>(lhs * rhs.width),
163 static_cast<DataType>(lhs * rhs.height) };
164}
DataType height
Height.
Definition: Size.h:37
DataType width
Width.
Definition: Size.h:35

◆ operator*() [5/6]

template<typename DataType , typename ScaleType >
SizeType< DataType > graphics::operator* ( SizeType< DataType >  lhs,
ScaleType  rhs 
)
noexcept

Definition at line 153 of file Size.h.

154{
155 return { static_cast<DataType>(lhs.width * rhs),
156 static_cast<DataType>(lhs.height * rhs) };
157}

◆ operator*() [6/6]

template<typename DataType >
SizeType< DataType > graphics::operator* ( SizeType< DataType >  lhs,
SizeType< DataType >  rhs 
)
noexcept

Definition at line 140 of file Size.h.

141{
142 return { lhs.width * rhs.width, lhs.height * rhs.height };
143}

◆ operator+() [1/2]

template<typename DataType >
PointType< DataType > graphics::operator+ ( PointType< DataType >  lhs,
PointType< DataType >  rhs 
)
noexcept

Definition at line 110 of file Point.h.

111{
112 return { lhs.x + rhs.x, lhs.y + rhs.y };
113}

◆ operator+() [2/2]

template<typename DataType >
SizeType< DataType > graphics::operator+ ( SizeType< DataType >  lhs,
SizeType< DataType >  rhs 
)
noexcept

Definition at line 126 of file Size.h.

127{
128 return { lhs.width + rhs.width, lhs.height + rhs.height };
129}

◆ operator-() [1/2]

template<typename DataType >
PointType< DataType > graphics::operator- ( PointType< DataType >  lhs,
PointType< DataType >  rhs 
)
noexcept

Definition at line 117 of file Point.h.

118{
119 return { lhs.x - rhs.x, lhs.y - rhs.y };
120}

◆ operator-() [2/2]

template<typename DataType >
SizeType< DataType > graphics::operator- ( SizeType< DataType >  lhs,
SizeType< DataType >  rhs 
)
noexcept

Definition at line 133 of file Size.h.

134{
135 return { lhs.width - rhs.width, lhs.height - rhs.height };
136}

◆ operator/() [1/4]

template<typename DataType >
PointType< DataType > graphics::operator/ ( PointType< DataType >  lhs,
PointType< DataType >  rhs 
)
noexcept

Definition at line 131 of file Point.h.

132{
133 return { lhs.x / rhs.x, lhs.y / rhs.y };
134}

◆ operator/() [2/4]

template<typename DataType , typename ScaleType >
PointType< DataType > graphics::operator/ ( PointType< DataType >  lhs,
ScaleType  rhs 
)
noexcept

Definition at line 151 of file Point.h.

152{
153 return { static_cast<DataType>(lhs.x / rhs),
154 static_cast<DataType>(lhs.y / rhs) };
155}

◆ operator/() [3/4]

template<typename DataType , typename ScaleType >
SizeType< DataType > graphics::operator/ ( SizeType< DataType >  lhs,
ScaleType  rhs 
)
noexcept

Definition at line 167 of file Size.h.

168{
169 return { static_cast<DataType>(lhs.width / rhs),
170 static_cast<DataType>(lhs.height / rhs) };
171}

◆ operator/() [4/4]

template<typename DataType >
SizeType< DataType > graphics::operator/ ( SizeType< DataType >  lhs,
SizeType< DataType >  rhs 
)
noexcept

Definition at line 147 of file Size.h.

148{
149 return { lhs.width / rhs.width, lhs.height / rhs.height };
150}

◆ operator==() [1/3]

template<typename DataType >
bool graphics::operator== ( const RectType< DataType >  lhs,
const RectType< DataType >  rhs 
)
noexcept

Definition at line 45 of file Rect.h.

47{
48 return lhs.origin == rhs.origin && lhs.size == rhs.size;
49}
PointType< DataType > origin
Origin of the rectangle.
Definition: Rect.h:25
SizeType< DataType > size
Size of the rectangle.
Definition: Rect.h:27

◆ operator==() [2/3]

template<typename DataType >
bool graphics::operator== ( PointType< DataType >  lhs,
PointType< DataType >  rhs 
)
noexcept

Definition at line 97 of file Point.h.

98{
99 return lhs.x == rhs.x && lhs.y == rhs.y;
100}

◆ operator==() [3/3]

template<typename DataType >
bool graphics::operator== ( SizeType< DataType >  lhs,
SizeType< DataType >  rhs 
)
noexcept

Definition at line 113 of file Size.h.

114{
115 return lhs.width == rhs.width && lhs.height == rhs.height;
116}

◆ point_cast()

template<typename To , typename From >
PointType< To > graphics::point_cast ( PointType< From >  point)

Casts a point to another point type.

Definition at line 91 of file Point.h.

92{
93 return { static_cast<To>(point.x), static_cast<To>(point.y) };
94}

References graphics::PointType< DataType >::x, and graphics::PointType< DataType >::y.

◆ rect_cast()

template<typename To , typename From >
RectType< To > graphics::rect_cast ( RectType< From >  rect)

Cast the rectangle to another data type.

Definition at line 60 of file Rect.h.

61{
62 return { point_cast<To>(rect.origin), size_cast<To>(rect.size) };
63}

References graphics::RectType< DataType >::origin, and graphics::RectType< DataType >::size.

◆ size_cast()

template<typename To , typename From >
SizeType< To > graphics::size_cast ( SizeType< From >  point)

Casts size to another data type.

Definition at line 107 of file Size.h.

108{
109 return { static_cast<To>(point.width), static_cast<To>(point.height) };
110}

References graphics::SizeType< DataType >::height, and graphics::SizeType< DataType >::width.