API Documentation
Loading...
Searching...
No Matches
RandomColorGenerator.h
Go to the documentation of this file.
1#pragma once
2#include <NDEVR/RGBColor.h>
3#include <NDEVR/Buffer.h>
4#include <NDEVR/Bounds.h>
5#include <NDEVR/Dictionary.h>
6#include <cmath>
7namespace NDEVR
8{
9 /**----------------------------------------------------------------------------
10 \brief Used with RandomColorGenerator to generate random colors
11 Options allow for custom hues and brightness.
12 ----------------------------------------------------------------------------*/
40 /**----------------------------------------------------------------------------
41 \brief Generates random colors based off of some specified settings
42 Useful for generating unique colors for lists of objects.
43 ----------------------------------------------------------------------------*/
45 {
46 private:
47 enum ColorRangeType
48 {
49 e_hue_range,
50 e_low_bounds,
51 e_saturation_range,
52 e_brightness_range
53 };
55 public:
56
57
59 //--------------------------------------------------------------------------
61 : options()
62 {}
64 : options(opt)
65 {}
68
69 private:
70
71 mutable RandomColorOptions options;
72 static ColorMap s_color_dictionary;
73 //--------------------------------------------------------------------------
74 private:
75 //--------------------------------------------------------------------------
76 Bounds<1, sint04> getSaturationRange(const Angle<sint02>& hue) const {
77 return getColorInfo(hue.toTypeAngle<sint04>())[ColorRangeType::e_saturation_range][0];
78 }
79 //--------------------------------------------------------------------------
80 static Bounds<1, sint04> getHueRange(int colorInput);
81 //--------------------------------------------------------------------------
82 static Bounds<1, sint04> getHueRange_s(RandomColorOptions::HueStyle colorInput);
83 //--------------------------------------------------------------------------
84 sint04 randomWithin(const Bounds<1, sint04>& range) const;
85 //--------------------------------------------------------------------------
86 Angle<sint02> pickHue() const;
87 //--------------------------------------------------------------------------
89 //--------------------------------------------------------------------------
90 uint01 pickSaturation(const Angle<sint02>& hue) const;
91 //--------------------------------------------------------------------------
92 uint01 getMinimumBrightness(const Angle<sint02>& H, uint01 S) const;
93 //--------------------------------------------------------------------------
94 uint01 pickBrightness(const Angle<sint02>& H, uint01 S) const;
95
96 };
97};
#define NDEVR_BASE_API
Definition DLLInfo.h:57
The primary angle storage class for this API. Stores an angle in an optimized format.
Definition StringStream.h:540
constexpr Angle< t_new_type > toTypeAngle() const
Explicit conversion of an angle from one container type to another.
Definition Angle.h:226
A specification of upper and lower bounds in N-dimensions.
Definition Bounds.hpp:52
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
A hash-based key-value store, useful for quick associative lookups. Key features include:
Definition Dictionary.h:61
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:54
Generates random colors based off of some specified settings.
Definition RandomColorGenerator.h:45
Buffer< RGBColor > randomColors(uint04 count) const
static ColorMap LoadColorBounds()
RandomColorGenerator(const RandomColorOptions &opt)
Definition RandomColorGenerator.h:63
RandomColorGenerator()
Definition RandomColorGenerator.h:60
RGBColor randomColorRGB() const
Definition ACIColor.h:37
int32_t sint04
-Defines an alias representing a 4 byte, signed integer. -Can represent exact integer values -2147483...
Definition BaseValues.hpp:64
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:80
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
Used with RandomColorGenerator to generate random colors.
Definition RandomColorGenerator.h:14
LuminosityStyle luminosity
Definition RandomColorGenerator.h:38
size_t seed
Definition RandomColorGenerator.h:37
LuminosityStyle
Definition RandomColorGenerator.h:16
@ e_light
Definition RandomColorGenerator.h:19
@ e_bright
Definition RandomColorGenerator.h:18
@ e_random
Definition RandomColorGenerator.h:17
HueStyle hue_name
Definition RandomColorGenerator.h:36
HueStyle
Definition RandomColorGenerator.h:23
@ e_green
Definition RandomColorGenerator.h:29
@ e_purple
Definition RandomColorGenerator.h:31
@ e_unset
Definition RandomColorGenerator.h:24
@ e_orange
Definition RandomColorGenerator.h:27
@ e_blue
Definition RandomColorGenerator.h:30
@ e_yellow
Definition RandomColorGenerator.h:28
@ e_monochrome
Definition RandomColorGenerator.h:25
@ e_red
Definition RandomColorGenerator.h:26
int hue
Definition RandomColorGenerator.h:35