NDEVR
API Documentation
RandomColorGenerator.h
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{
47
52 class NDEVR_BASE_API RandomColorGenerator
53 {
54 private:
56 enum ColorRangeType
57 {
58 e_hue_range,
59 e_low_bounds,
60 e_saturation_range,
61 e_brightness_range
62 };
64 public:
67 static ColorMap LoadColorBounds();
68 //--------------------------------------------------------------------------
71 : options()
72 {}
73
76 : options(opt)
77 {}
78
87 void setOptions(RandomColorOptions& ops) { options = ops; }
88 private:
89 mutable RandomColorOptions options;
90 static ColorMap s_color_dictionary;
91 //--------------------------------------------------------------------------
92 private:
93 //--------------------------------------------------------------------------
97 Bounds<1, sint04> getSaturationRange(const Angle<uint02>& hue) const {
98 return getColorInfo(hue.toTypeAngle<sint04>())[ColorRangeType::e_saturation_range][0];
99 }
100 //--------------------------------------------------------------------------
104 static Bounds<1, sint04> getHueRange(int colorInput);
105 //--------------------------------------------------------------------------
109 static Bounds<1, sint04> getHueRange_s(RandomColorOptions::HueStyle colorInput);
110 //--------------------------------------------------------------------------
114 sint04 randomWithin(const Bounds<1, sint04>& range) const;
115 //--------------------------------------------------------------------------
118 Angle<uint02> pickHue() const;
119 //--------------------------------------------------------------------------
123 Dictionary<ColorRangeType, Buffer<Bounds<1, sint04>>> getColorInfo(Angle<sint04> hue) const;
124 //--------------------------------------------------------------------------
128 uint01 pickSaturation(const Angle<uint02>& hue) const;
129 //--------------------------------------------------------------------------
134 uint01 getMinimumBrightness(const Angle<uint02>& H, uint01 S) const;
135 //--------------------------------------------------------------------------
140 uint01 pickBrightness(const Angle<uint02>& H, uint01 S) const;
141
142 };
143};
Stores an angle in an optimized internal format with support for efficient trigonometric operations.
Definition Angle.h:83
constexpr Angle< t_new_type > toTypeAngle() const
Explicit conversion of an angle from one container type to another.
Definition Angle.h:198
A specification of upper and lower bounds in N-dimensions.
Definition Bounds.hpp:54
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:64
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:57
RandomColorGenerator(const RandomColorOptions &opt)
Constructs a generator with the specified options.
void setOptions(RandomColorOptions &ops)
Replaces the current color generation options.
Buffer< RGBColor > randomColors(uint04 count) const
Generates a buffer of random RGB colors.
RandomColorGenerator()
Constructs a generator with default options.
RGBColor randomColorRGB() const
Generates a single random RGB color based on the current options.
static ColorMap LoadColorBounds()
Loads and returns the predefined color bounds dictionary for all hue styles.
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
int32_t sint04
-Defines an alias representing a 4 byte, signed integer.
Options for configuring random color generation with custom hue and brightness constraints.
RandomColorOptions(HueStyle hue, LuminosityStyle style)
Constructs random color options with the given hue and luminosity style.
int hue
Numeric hue value override, or Constant<int>::Invalid if unset.
HueStyle hue_name
The named hue family constraint.
RandomColorOptions()
Constructs default random color options.
LuminosityStyle
Controls the brightness level of generated colors.
@ e_random
Randomly selected brightness.
@ e_light
Light, pastel-like colors.
@ e_dark
Dark, muted colors.
@ e_bright
Bright, vivid colors.
HueStyle
Constrains the hue family for generated colors.
@ e_purple
Purple hue family.
@ e_blue
Blue hue family.
@ e_orange
Orange hue family.
@ e_pink
Pink hue family.
@ e_yellow
Yellow hue family.
@ e_green
Green hue family.
@ e_unset
No hue constraint; any hue may be chosen.
@ e_monochrome
Grayscale with no chromatic hue.
size_t seed
Seed for the random number generator.
LuminosityStyle luminosity
The desired luminosity style.