Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzCore includes
Toshihiro Shimizu 890ddd
#include "trop.h"
Toshihiro Shimizu 890ddd
#include "tpixelutils.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzBase includes
Toshihiro Shimizu 890ddd
#include "tparamset.h"
Toshihiro Shimizu 890ddd
#include "tdoubleparam.h"
Toshihiro Shimizu 890ddd
#include "tzeraryfx.h"
Toshihiro Shimizu 890ddd
#include "tfxparam.h"
Toshihiro Shimizu 890ddd
#include "tparamuiconcept.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tbasefx.h"
Toshihiro Shimizu 890ddd
#include "tzeraryfx.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//==================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class ColorCardFx : public TBaseZeraryFx
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	FX_DECLARATION(ColorCardFx)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TPixelParamP m_color;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	ColorCardFx() : m_color(TPixel32::Green)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		bindParam(this, "color", m_color);
Toshihiro Shimizu 890ddd
		m_color->setDefaultValue(TPixel32::Green);
Toshihiro Shimizu 890ddd
		setName(L"ColorCardFx");
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	bool canHandle(const TRenderSettings &info, double frame) { return true; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	bool doGetBBox(double frame, TRectD &bBox, const TRenderSettings &info)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		bBox = TConsts::infiniteRectD;
Toshihiro Shimizu 890ddd
		return true;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void doCompute(TTile &tile, double frame, const TRenderSettings &)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		TRaster32P raster32 = tile.getRaster();
Toshihiro Shimizu 890ddd
		if (raster32)
Toshihiro Shimizu 890ddd
			raster32->fill(m_color->getPremultipliedValue(frame));
Toshihiro Shimizu 890ddd
		else {
Toshihiro Shimizu 890ddd
			TRaster64P ras64 = tile.getRaster();
Toshihiro Shimizu 890ddd
			if (ras64)
Toshihiro Shimizu 890ddd
				ras64->fill(toPixel64(m_color->getPremultipliedValue(frame)));
Toshihiro Shimizu 890ddd
			else
Toshihiro Shimizu 890ddd
				throw TException("ColorCardFx unsupported pixel type");
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	};
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//==================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class CheckBoardFx : public TBaseZeraryFx
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	FX_DECLARATION(CheckBoardFx)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TPixelParamP m_color1, m_color2;
Toshihiro Shimizu 890ddd
	TDoubleParamP m_size;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	CheckBoardFx() : m_color1(TPixel32::Black), m_color2(TPixel32::White), m_size(50)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		m_size->setMeasureName("fxLength");
Toshihiro Shimizu 890ddd
		bindParam(this, "color1", m_color1);
Toshihiro Shimizu 890ddd
		bindParam(this, "color2", m_color2);
Toshihiro Shimizu 890ddd
		bindParam(this, "size", m_size);
Toshihiro Shimizu 890ddd
		m_color1->setDefaultValue(TPixel32::Black);
Toshihiro Shimizu 890ddd
		m_color2->setDefaultValue(TPixel32::White);
Toshihiro Shimizu 890ddd
		m_size->setValueRange(1, 1000);
Toshihiro Shimizu 890ddd
		m_size->setDefaultValue(50);
Toshihiro Shimizu 890ddd
		setName(L"CheckBoardFx");
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	bool canHandle(const TRenderSettings &info, double frame) { return false; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	bool doGetBBox(double, TRectD &bBox, const TRenderSettings &info)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		bBox = TConsts::infiniteRectD;
Toshihiro Shimizu 890ddd
		return true;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void doCompute(TTile &tile, double frame, const TRenderSettings &info)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		const TPixel32 &c1 = m_color1->getValue(frame);
Toshihiro Shimizu 890ddd
		const TPixel32 &c2 = m_color2->getValue(frame);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		double size = m_size->getValue(frame);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		assert(info.m_shrinkX == info.m_shrinkY);
Toshihiro Shimizu 890ddd
		size *= info.m_affine.a11 / info.m_shrinkX;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		TDimensionD dim(size, size);
Toshihiro Shimizu 890ddd
		TRop::checkBoard(tile.getRaster(), c1, c2, dim, tile.m_pos);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void getParamUIs(TParamUIConcept *&concepts, int &length)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		concepts = new TParamUIConcept[length = 1];
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		concepts[0].m_type = TParamUIConcept::SIZE;
Toshihiro Shimizu 890ddd
		concepts[0].m_label = "Size";
Toshihiro Shimizu 890ddd
		concepts[0].m_params.push_back(m_size);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//==================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
FX_IDENTIFIER(ColorCardFx, "colorCardFx")
Toshihiro Shimizu 890ddd
FX_IDENTIFIER(CheckBoardFx, "checkBoardFx")