tahoma2d/toonz/sources/include/tcolorfunctions.h

108 lines
2.8 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
#ifndef T_COLOR_FUNCTIONS_INCLUDED
#define T_COLOR_FUNCTIONS_INCLUDED
#include "tpixel.h"
#undef DVAPI
#undef DVVAR
#ifdef TCOLOR_EXPORTS
#define DVAPI DV_EXPORT_API
#define DVVAR DV_EXPORT_VAR
#else
#define DVAPI DV_IMPORT_API
#define DVVAR DV_IMPORT_VAR
#endif
//-----------------------------------------------------------------------------
2016-06-15 18:43:10 +12:00
class DVAPI TColorFunction {
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
virtual TPixel32 operator()(
const TPixel32 &color) const = 0; // {return color;};
struct Parameters { // outX = tcrop(inX * m_mX + m_cX, 0, 1); 0<=inX<=1
double m_mR, m_mG, m_mB, m_mM;
double m_cR, m_cG, m_cB, m_cM;
Parameters()
: m_mR(1)
, m_mG(1)
, m_mB(1)
, m_mM(1)
, m_cR(0)
, m_cG(0)
, m_cB(0)
, m_cM(0) {}
};
virtual TColorFunction *clone() const = 0;
virtual bool getParameters(
Parameters &p) const = 0; //{ p = Parameters(); return true; }
virtual ~TColorFunction() {}
2016-03-19 06:57:51 +13:00
};
//-----------------------------------------------------------------------------
2016-06-15 18:43:10 +12:00
class DVAPI TGenericColorFunction : public TColorFunction {
double m_m[4], m_c[4];
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
TGenericColorFunction(const double m[4], const double c[4]);
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
TColorFunction *clone() const override { return new TGenericColorFunction(m_m, m_c); }
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
TPixel32 operator()(const TPixel32 &color) const override;
bool getParameters(Parameters &p) const override;
2016-03-19 06:57:51 +13:00
};
//-----------------------------------------------------------------------------
2016-06-15 18:43:10 +12:00
class DVAPI TColorFader : public TColorFunction {
TPixel32 m_color;
double m_fade;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
TColorFader() : m_color(), m_fade(0.5) {}
TColorFader(const TPixel32 &color, double fade)
: m_color(color), m_fade(fade) {}
2016-06-19 20:06:29 +12:00
TColorFunction *clone() const override { return new TColorFader(m_color, m_fade); }
2016-06-15 18:43:10 +12:00
2016-06-19 20:06:29 +12:00
TPixel32 operator()(const TPixel32 &color) const override;
bool getParameters(Parameters &p) const override;
2016-03-19 06:57:51 +13:00
};
//-----------------------------------------------------------------------------
2016-06-15 18:43:10 +12:00
class DVAPI TOnionFader : public TColorFunction {
TPixel32 m_color;
double m_fade;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
TOnionFader() : m_color(), m_fade(0.5) {}
TOnionFader(const TPixel32 &color, double fade)
: m_color(color), m_fade(fade) {}
2016-06-19 20:06:29 +12:00
TColorFunction *clone() const override { return new TOnionFader(m_color, m_fade); }
2016-06-15 18:43:10 +12:00
2016-06-19 20:06:29 +12:00
TPixel32 operator()(const TPixel32 &color) const override;
bool getParameters(Parameters &p) const override;
2016-03-19 06:57:51 +13:00
};
2016-06-15 18:43:10 +12:00
class DVAPI TTranspFader : public TColorFunction {
double m_transp;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
TTranspFader() : m_transp(0.5) {}
TTranspFader(double transp) : m_transp(transp) {}
2016-06-19 20:06:29 +12:00
TColorFunction *clone() const override { return new TTranspFader(m_transp); }
2016-06-15 18:43:10 +12:00
2016-06-19 20:06:29 +12:00
TPixel32 operator()(const TPixel32 &color) const override;
bool getParameters(Parameters &p) const override;
2016-03-19 06:57:51 +13:00
};
#endif