Geometrize  1.0
C++ library for geometrizing images into geometric primitives
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
commonutil.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <algorithm>
4 #include <cstdint>
5 
6 #include "bitmap/rgba.h"
7 
8 namespace geometrize
9 {
10 class Bitmap;
11 }
12 
13 namespace geometrize
14 {
15 
16 namespace commonutil
17 {
18 
23 void seedRandomGenerator(std::uint32_t seed);
24 
32 std::int32_t randomRange(std::int32_t min, std::int32_t max);
33 
41 template<typename T> T clamp(const T& value, const T& lower, const T& upper)
42 {
43  return (std::max)(lower, (std::min)(value, upper));
44 }
45 
52 
53 }
54 
55 }
void seedRandomGenerator(const std::uint32_t seed)
seedRandomGenerator Seeds the (thread-local) random number generators.
Definition: commonutil.cpp:19
T clamp(const T &value, const T &lower, const T &upper)
clamp Clamps a value within a range.
Definition: commonutil.h:41
geometrize::rgba getAverageImageColor(const geometrize::Bitmap &image)
getAverageImageColor Computes the average RGB color of the pixels in the bitmap.
Definition: commonutil.cpp:30
std::int32_t randomRange(const std::int32_t min, const std::int32_t max)
randomRange Returns a random integer in the range, inclusive. Uses thread-local random number generat...
Definition: commonutil.cpp:24
The Bitmap class is a helper class for working with bitmap data.
Definition: bitmap.h:15
The rgba struct is a helper for manipulating RGBA8888 color data.
Definition: rgba.h:12