#ifndef TEXTURE_COMPOSER_H
#define TEXTURE_COMPOSER_H

#include "TextureSupport.h"


//---------------------
template <typename DATA> InternalTextureData<DATA>& operator +=( InternalTextureData<DATA>& operand1, const float scalar )
{
	for ( int i=0; i< operand1.pixelData.size(); ++i)
	{
		operand1.pixelData[i] += scalar;
	}

	return operand1;
}
template <typename DATA> InternalTextureData<DATA> operator +(const  InternalTextureData<DATA>& operand1, const float scalar)
{
	InternalTextureData<DATA> finalTex(operand1);
	return finalTex+=scalar;
}
template <typename DATA> InternalTextureData<DATA> operator +(const float scalar, const  InternalTextureData<DATA>& operand1)
{
	InternalTextureData<DATA> finalTex(operand1);
	return finalTex+=scalar;
}
//---------------------
template <typename DATA> InternalTextureData<DATA>& operator -=(  InternalTextureData<DATA>& operand1, const float scalar )
{
	for ( int i=0; i< operand1.pixelData.size(); ++i)
	{
		operand1.pixelData[i] -= scalar;
	}

	return operand1;
}
template <typename DATA> InternalTextureData<DATA> operator -(const  InternalTextureData<DATA>& operand1, const float scalar)
{
	InternalTextureData<DATA> finalTex(operand1);
	return finalTex-=scalar;
}
template <typename DATA> InternalTextureData<DATA> operator -(const float scalar, const  InternalTextureData<DATA>& operand1)
{
	InternalTextureData<DATA> finalTex(operand1);

	for ( int i=0; i< finalTex.pixelData.size(); ++i)
	{
		finalTex.pixelData[i] = scalar - operand1.pixelData[i];
	}

	return finalTex;
}
//---------------------
template <typename DATA> InternalTextureData<DATA>& operator *=(  InternalTextureData<DATA>& operand1, const float scalar )
{
	for ( int i=0; i< operand1.pixelData.size(); ++i)
	{
		operand1.pixelData[i] *= scalar;
	}

	return operand1;
}
template <typename DATA> InternalTextureData<DATA> operator *(const  InternalTextureData<DATA>& operand1, const float scalar)
{
	InternalTextureData<DATA> finalTex(operand1);
	return finalTex*=scalar;
}

template <typename DATA> InternalTextureData<DATA> operator *(const float scalar, const  InternalTextureData<DATA>& operand1)
{
	InternalTextureData<DATA> finalTex(operand1);
	return finalTex*=scalar;
}
//---------------------
template <typename DATA> InternalTextureData<DATA>& operator /=(  InternalTextureData<DATA>& operand1, const float scalar )
{
	for ( int i=0; i< operand1.pixelData.size(); ++i)
	{
		operand1.pixelData[i] /= scalar;
	}

	return operand1;
}
template <typename DATA> InternalTextureData<DATA> operator /(const  InternalTextureData<DATA>& operand1, const float scalar)
{
	InternalTextureData<DATA> finalTex(operand1);
	return finalTex /= scalar;
}
template <typename DATA> InternalTextureData<DATA> operator /( const float scalar, const  InternalTextureData<DATA>& operand1)
{
	InternalTextureData<DATA> finalTex(operand1);

	for ( int i=0; i< operand1.pixelData.size(); ++i)
	{
		finalTex.pixelData[i] = scalar / operand1.pixelData[i];
	}

	return finalTex;
}
//---------------------
template <typename DATA> InternalTextureData<DATA>& operator %=(  InternalTextureData<DATA>& operand1, const float scalar )
{
	for ( int i=0; i< operand1.pixelData.size(); ++i)
	{
		operand1.pixelData[i] %= scalar;
	}

	return operand1;
}
template <typename DATA> InternalTextureData<DATA> operator %(const  InternalTextureData<DATA>& operand1, const float scalar)
{
	InternalTextureData<DATA> finalTex(operand1);
	return finalTex %= scalar;
}

//=============================================
//=============================================
template <typename DATA> InternalTextureData<DATA>& operator +=(  InternalTextureData<DATA>& operand1, const  InternalTextureData<DATA>& operand2)
{
	assert( operand1.pixelData.size() == operand2.pixelData.size() && "Textures have different size!" );

	for ( int i=0; i< operand1.pixelData.size(); ++i)
	{
		operand1.pixelData[i] += operand2.pixelData[i];
	}

	return operand1;
}
template <typename DATA> InternalTextureData<DATA> operator +(const  InternalTextureData<DATA>& operand1, const  InternalTextureData<DATA>& operand2)
{
	InternalTextureData<DATA> finalTex(operand1);
	return finalTex+=operand2;
}
//---------------------
template <typename DATA> InternalTextureData<DATA>& operator -=(  InternalTextureData<DATA>& operand1, const  InternalTextureData<DATA>& operand2)
{
	assert( operand1.pixelData.size() == operand2.pixelData.size() && "Textures have different size!" );

	for ( int i=0; i< operand1.pixelData.size(); ++i)
	{
		operand1.pixelData[i] -= operand2.pixelData[i];
	}

	return operand1;
}
template <typename DATA> InternalTextureData<DATA> operator -(const  InternalTextureData<DATA>& operand1, const  InternalTextureData<DATA>& operand2)
{
	InternalTextureData<DATA> finalTex(operand1);
	return finalTex-=operand2;
}
//---------------------
template <typename DATA> InternalTextureData<DATA>& operator *=(  InternalTextureData<DATA>& operand1, const  InternalTextureData<DATA>& operand2)
{
	assert( operand1.pixelData.size() == operand2.pixelData.size() && "Textures have different size!" );

	for ( int i=0; i< operand1.pixelData.size(); ++i)
	{
		operand1.pixelData[i] *= operand2.pixelData[i];
	}

	return operand1;
}
template <typename DATA> InternalTextureData<DATA> operator *(const  InternalTextureData<DATA>& operand1, const  InternalTextureData<DATA>& operand2)
{
	InternalTextureData<DATA> finalTex(operand1);
	return finalTex*=operand2;
}
//---------------------
template <typename DATA> InternalTextureData<DATA>& operator /=(  InternalTextureData<DATA>& operand1, const  InternalTextureData<DATA>& operand2)
{
	assert( operand1.pixelData.size() == operand2.pixelData.size() && "Textures have different size!" );

	for ( int i=0; i< operand1.pixelData.size(); ++i)
	{
		operand1.pixelData[i] /= operand2.pixelData[i];
	}

	return operand1;
}
template <typename DATA> InternalTextureData<DATA> operator /(const  InternalTextureData<DATA>& operand1, const  InternalTextureData<DATA>& operand2)
{
	InternalTextureData<DATA> finalTex(operand1);
	return finalTex/=operand2;
}
#endif