/***************************************************************************
*                                                                          *
*  Copyright (C) Golaem S.A.  All Rights Reserved.                         *
*                                                                          *
***************************************************************************/

#pragma once

#include "glmCoreAPI.h"
#include "glmTypes.h"
#include "glmMathBase.h"

namespace glm
{
	//************************************************************
	/*! @name Color Utilities
	*/ //*********************************************************
	//@{
	//------------------------------------------------------------
	//! Modify a color from some hsl parameters
	/*	\param inr, ing, ing source color
	\param h hue delta in the set [-1, 1]
	\param s sat delta in the set [-1, 1]
	\param l lit delta in the set [-1, 1]
	\param outr, outg, outb corresponding RGB color in the set [0, 1]
	\note please report any modifications to the function in CrowdArnoldShader
	*/ //---------------------------------------------------------
	void GLM_CORE_API changeColorHSL(float inr, float ing, float inb, float h, float s, float l, float& outr, float& outg, float& outb);

	//------------------------------------------------------------
	//! Convert RGB to HSL
	/*	\param rgbValue RGB color in the set [0, 1]
	\note From http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript
	\note please report any modifications to the function in CrowdArnoldShader
	*/ //---------------------------------------------------------
	void GLM_CORE_API rbgToHsl(float inr, float ing, float inb, float& outh, float& outs, float& outl);

	//------------------------------------------------------------
	//! Convert HSL to RBG
	/*	\param hslValue Assumes h, s, and l are contained in the set [0, 1] and
	\return corresponding RGB color in the set [0, 1]
	\note From http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript
	\note please report any modifications to the function in CrowdArnoldShader
	*/ //---------------------------------------------------------
	void GLM_CORE_API hslToRgb(float inh, float ins, float inl, float& outr, float& outg, float& outb);

	//------------------------------------------------------------
	//! Convert hue component to rgb (used by hslToRgb)
	/*	\return a scalar in the set [0, 1]
	\note From http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript
	\note please report any modifications to the function in CrowdArnoldShader
	*/ //---------------------------------------------------------
	float GLM_CORE_API hueToRgb(float p, float q, float t);

	/**
	* \brief Splits an uint32_t colorABGR into its rgba components
	*/
	void GLM_CORE_API getColorComponents(uint32_t color, unsigned char& r, unsigned char& g, unsigned char& b, unsigned char& a);

	/**
	* \brief Creates an uint32_t colorABGR from its rgba components
	*/
	void GLM_CORE_API getColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a, uint32_t& color);

	/**
	* \brief Compare colors.
	* \note the ColorComparisonOperator::EQUAL and ColorComparisonOperator::NOT_EQUAL modes comapre the r/g/b channels
	* \note every other mode modes compares the lightness value
	*/
	bool GLM_CORE_API compareColors(uint32_t color1, ComparisonOperator::Value comparison, uint32_t color2, float threshold);
	//@}
}

