Class HSVInterpolation

Inheritance Relationships

Base Type

Class Documentation

class HSVInterpolation : public flamegpu::visualiser::ColorFunction

Agent color function for mapping a floating point value to a HSV hue

Public Functions

HSVInterpolation(const std::string &variable_name, const float &hMin, const float &hMax, const float &s = 1.0f, const float &v = 0.88f)

Constructs a HSV interpolation function generator All components must be provided in the inclusive range [0.0, 1.0]

Parameters:
  • variable_name – Name of the agent variable which maps to hue, the variable type must be float

  • hMin – Hue value when the agent variable is 0.0

  • hMax – Hue value when the agent variable is 1.0

  • s – Saturation (the inverse amount of grey)

  • v – Value (brightness)

HSVInterpolation &setBounds(const float &min_bound, const float &max_bound)

Set the bounds to clamp an agent variable to before using for HSV interpolation

Note

Defaults to (0.0, 1.0)

Parameters:
  • min_bound – The agent variable value that should map to the minimum hue, must be smaller than max_bound

  • max_bound – The agent variable value that should map to the maximum hue, must be larger than min_bound

Throws:

exception::InvalidArgument – if min_bound > max_bound

Returns:

Returns itself, so that you can chain the method (otherwise constructor would have too many optional args)

HSVInterpolation &setWrapHue(const bool &_wrapHue)

If set to true, hue will interpolate over the 0/360 boundary If set false, hue will interpolate without wrapping (e.g. if hMax is < hMin), hMin will be assigned to the lower_bound By default this is set to false

virtual std::string getSrc(unsigned int array_len) const override

Returns GLSL for a function that returns a color based on the configured HSV interpolation

Parameters:

array_len – Length of the variable array

virtual std::string getSamplerName() const override

Always returns “color_arg”

virtual std::string getAgentVariableName() const override

Returns variable_name

virtual std::type_index getAgentVariableRequiredType() const override

Returns std::type_index(typeid(float))

Public Static Functions

static HSVInterpolation REDGREEN(const std::string &variable_name, const float &min_bound = 0.0f, const float &max_bound = 1.0f)

0 = Red, 1 = Green

Parameters:
  • variable_name – agent variable of type float to map to the color

  • min_bound – The value of the agent variable which should map to the Red

  • max_bound – The value of the agent variable which should map to the Green

static HSVInterpolation GREENRED(const std::string &variable_name, const float &min_bound = 0.0f, const float &max_bound = 1.0f)

0 = Green, 1 = Red

Parameters:
  • variable_name – agent variable of type float to map to the color

  • min_bound – The value of the agent variable which should map to Green

  • max_bound – The value of the agent variable which should map to Red