Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "trop.h"
Toshihiro Shimizu 890ddd
#include "tfxparam.h"
Toshihiro Shimizu 890ddd
#include "stdfx.h"
Toshihiro Shimizu 890ddd
#include "tpluginmanager.h"
Toshihiro Shimizu 890ddd
#include "tpixelutils.h"
Toshihiro Shimizu 890ddd
#include "tspectrumparam.h"
Toshihiro Shimizu 890ddd
#include "ttzpimagefx.h"
Toshihiro Shimizu 890ddd
#include "gradients.h"
Toshihiro Shimizu 890ddd
#include "tunit.h"
Toshihiro Shimizu 890ddd
#include "tparamuiconcept.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include <qcoreapplication></qcoreapplication>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 9f5a1b
#ifdef _WIN32
Toshihiro Shimizu 890ddd
#pragma warning(disable : 4996)
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
#undef max
Toshihiro Shimizu 890ddd
//==================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
bool isAlmostIsotropic(const TAffine &aff)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return aff.isIsotropic(0.001);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//==================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class FadeFx : public TStandardRasterFx
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	FX_PLUGIN_DECLARATION(FadeFx)
Toshihiro Shimizu 890ddd
	TRasterFxPort m_input;
Toshihiro Shimizu 890ddd
	TDoubleParamP m_value;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	FadeFx() : m_value(50)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		m_value->setValueRange(0, 100);
Toshihiro Shimizu 890ddd
		bindParam(this, "value", m_value);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		addInputPort("Source", m_input);
Toshihiro Shimizu 890ddd
	};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	~FadeFx(){};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	bool doGetBBox(double frame, TRectD &bBox, const TRenderSettings &info)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		if (m_input.isConnected()) {
Toshihiro Shimizu 890ddd
			bool ret = m_input->doGetBBox(frame, bBox, info);
Toshihiro Shimizu 890ddd
			// devo scurire bgColor
Toshihiro Shimizu 890ddd
			return ret;
Toshihiro Shimizu 890ddd
		} else {
Toshihiro Shimizu 890ddd
			bBox = TRectD();
Toshihiro Shimizu 890ddd
			return false;
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void doCompute(TTile &tile, double frame, const TRenderSettings &ri)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		if (!m_input.isConnected())
Toshihiro Shimizu 890ddd
			return;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		m_input->compute(tile, frame, ri);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		double v = 1 - m_value->getValue(frame) / 100;
Toshihiro Shimizu 890ddd
		TRop::rgbmScale(tile.getRaster(), tile.getRaster(), 1, 1, 1, v);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	bool canHandle(const TRenderSettings &info, double frame) { return true; }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//==================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class SpiralFx : public TStandardZeraryFx
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	FX_PLUGIN_DECLARATION(SpiralFx)
Toshihiro Shimizu 890ddd
	TDoubleParamP m_freq;
Toshihiro Shimizu 890ddd
	TDoubleParamP m_phase;
Toshihiro Shimizu 890ddd
	TSpectrumParamP m_spectrum;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	SpiralFx()
Toshihiro Shimizu 890ddd
		: m_freq(0.1) // args, "Freq")
Toshihiro Shimizu 890ddd
		  ,
Toshihiro Shimizu 890ddd
		  m_phase(0.0) // args, "Phase")
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		// m_freq->setDefaultValue(0.1);
Toshihiro Shimizu 890ddd
		// m_phase->setDefaultValue(0.0);
Toshihiro Shimizu 890ddd
		const TPixel32 transparent(0, 0, 0, 0);
Toshihiro Shimizu 890ddd
		/*
Toshihiro Shimizu 890ddd
	 TPixel32 colors[] = {
Toshihiro Shimizu 890ddd
			TPixel32::Magenta, 
Toshihiro Shimizu 890ddd
			TPixel32::Black, 
Toshihiro Shimizu 890ddd
			TPixel32::Red, 
Toshihiro Shimizu 890ddd
			TPixel32::Yellow, 
Toshihiro Shimizu 890ddd
			transparent};    
Toshihiro Shimizu 890ddd
 */
Toshihiro Shimizu 890ddd
		TSpectrum::ColorKey colors[] = {
Toshihiro Shimizu 890ddd
			TSpectrum::ColorKey(0, TPixel32::Magenta),
Toshihiro Shimizu 890ddd
			TSpectrum::ColorKey(0.25, TPixel32::Black),
Toshihiro Shimizu 890ddd
			TSpectrum::ColorKey(0.5, TPixel32::Red),
Toshihiro Shimizu 890ddd
			TSpectrum::ColorKey(0.75, TPixel32::Yellow),
Toshihiro Shimizu 890ddd
			TSpectrum::ColorKey(1, transparent)};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		m_spectrum = TSpectrumParamP(tArrayCount(colors), colors);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		bindParam(this, "colors", m_spectrum);
Toshihiro Shimizu 890ddd
		bindParam(this, "freq", m_freq);
Toshihiro Shimizu 890ddd
		bindParam(this, "phase", m_phase);
Toshihiro Shimizu 890ddd
		m_freq->setValueRange(0, 1);
Toshihiro Shimizu 890ddd
		//m_spectrum->setDefaultValue(tArrayCount(colors), colors);
Toshihiro Shimizu 890ddd
	};
Toshihiro Shimizu 890ddd
	~SpiralFx(){};
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 &ri);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	bool canHandle(const TRenderSettings &info, double frame) { return true; }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
namespace
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
template <class t=""></class>
Toshihiro Shimizu 890ddd
void doComputeT(TRasterPT<t> raster, TPointD posTrasf, const TAffine &aff,</t>
Toshihiro Shimizu 890ddd
				const TSpectrumT<t> &spectrum, double freq, double phase)</t>
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	raster->lock();
Toshihiro Shimizu 890ddd
	for (int y = 0; y < raster->getLy(); y++) {
Toshihiro Shimizu 890ddd
		TPointD posAux = posTrasf;
Toshihiro Shimizu 890ddd
		T *pix = raster->pixels(y);
Toshihiro Shimizu 890ddd
		for (int x = 0; x < raster->getLx(); x++) {
Toshihiro Shimizu 890ddd
			double ang = 0.0;
Toshihiro Shimizu 890ddd
			if (posAux.x != 0 || posAux.y != 0)
Toshihiro Shimizu 890ddd
				ang = atan2(posAux.y, posAux.x);
Toshihiro Shimizu 890ddd
			double r = sqrt(posAux.x * posAux.x + posAux.y * posAux.y);
Toshihiro Shimizu 890ddd
			double v = 0.5 * (1 + sin(r * freq + ang + phase));
Toshihiro Shimizu 890ddd
			*pix++ = spectrum.getPremultipliedValue(v);
Toshihiro Shimizu 890ddd
			posAux.x += aff.a11;
Toshihiro Shimizu 890ddd
			posAux.y += aff.a21;
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
		posTrasf.x += aff.a12;
Toshihiro Shimizu 890ddd
		posTrasf.y += aff.a22;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	raster->unlock();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//==================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void SpiralFx::doCompute(TTile &tile, double frame, const TRenderSettings &ri)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	double phase = m_phase->getValue(frame);
Toshihiro Shimizu 890ddd
	double freq = m_freq->getValue(frame);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TAffine aff = ri.m_affine.inv();
Toshihiro Shimizu 890ddd
	TPointD posTrasf = aff * tile.m_pos;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (TRaster32P ras32 = tile.getRaster())
Toshihiro Shimizu 890ddd
		doComputeT<tpixel32>(ras32, posTrasf, aff, m_spectrum->getValue(frame), freq, phase);</tpixel32>
Toshihiro Shimizu 890ddd
	else if (TRaster64P ras64 = tile.getRaster())
Toshihiro Shimizu 890ddd
		doComputeT<tpixel64>(ras64, posTrasf, aff, m_spectrum->getValue64(frame), freq, phase);</tpixel64>
Toshihiro Shimizu 890ddd
	else
Toshihiro Shimizu 890ddd
		throw TException("SpiralFx: unsupported Pixel Type");
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class MultiLinearGradientFx : public TStandardZeraryFx
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	FX_PLUGIN_DECLARATION(MultiLinearGradientFx)
Toshihiro Shimizu 890ddd
	TDoubleParamP m_period;
Toshihiro Shimizu 890ddd
	TDoubleParamP m_count;
Toshihiro Shimizu 890ddd
	TDoubleParamP m_cycle;
Toshihiro Shimizu 890ddd
	TDoubleParamP m_wave_amplitude;
Toshihiro Shimizu 890ddd
	TDoubleParamP m_wave_freq;
Toshihiro Shimizu 890ddd
	TDoubleParamP m_wave_phase;
Toshihiro Shimizu 890ddd
	TSpectrumParamP m_colors;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	MultiLinearGradientFx()
Toshihiro Shimizu 890ddd
		: m_period(100) //args, "Period")
Toshihiro Shimizu 890ddd
		  ,
Toshihiro Shimizu 890ddd
		  m_count(2) //args, "Count")
Toshihiro Shimizu 890ddd
		  ,
Toshihiro Shimizu 890ddd
		  m_cycle(0.0) //args, "Cycle")
Toshihiro Shimizu 890ddd
		  ,
Toshihiro Shimizu 890ddd
		  m_wave_amplitude(0.0) //args, "Cycle")
Toshihiro Shimizu 890ddd
		  ,
Toshihiro Shimizu 890ddd
		  m_wave_freq(0.0) //args, "Cycle")
Toshihiro Shimizu 890ddd
		  ,
Toshihiro Shimizu 890ddd
		  m_wave_phase(0.0) //args, "Cycle")
Toshihiro Shimizu 890ddd
							//    , m_colors (0) //args, "Colors")
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		TSpectrum::ColorKey colors[] = {
Toshihiro Shimizu 890ddd
			TSpectrum::ColorKey(0, TPixel32::White),
Toshihiro Shimizu 890ddd
			TSpectrum::ColorKey(0.33, TPixel32::Yellow),
Toshihiro Shimizu 890ddd
			TSpectrum::ColorKey(0.66, TPixel32::Red),
Toshihiro Shimizu 890ddd
			TSpectrum::ColorKey(1, TPixel32::White)};
Toshihiro Shimizu 890ddd
		m_colors = TSpectrumParamP(tArrayCount(colors), colors);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		bindParam(this, "period", m_period);
Toshihiro Shimizu 890ddd
		bindParam(this, "count", m_count);
Toshihiro Shimizu 890ddd
		bindParam(this, "cycle", m_cycle);
Toshihiro Shimizu 890ddd
		bindParam(this, "wave_amplitude", m_wave_amplitude);
Toshihiro Shimizu 890ddd
		bindParam(this, "wave_frequency", m_wave_freq);
Toshihiro Shimizu 890ddd
		bindParam(this, "wave_phase", m_wave_phase);
Toshihiro Shimizu 890ddd
		bindParam(this, "colors", m_colors);
Toshihiro Shimizu 890ddd
		m_period->setValueRange(0, (std::numeric_limits<double>::max)());</double>
Toshihiro Shimizu 890ddd
		m_cycle->setValueRange(0, (std::numeric_limits<double>::max)());</double>
Toshihiro Shimizu 890ddd
		m_wave_amplitude->setValueRange(0, (std::numeric_limits<double>::max)());</double>
Toshihiro Shimizu 890ddd
		m_count->setValueRange(0, (std::numeric_limits<double>::max)());</double>
Toshihiro Shimizu 890ddd
		m_period->setMeasureName("fxLength");
Toshihiro Shimizu 890ddd
		m_wave_amplitude->setMeasureName("fxLength");
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	~MultiLinearGradientFx(){};
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
Toshihiro Shimizu 890ddd
		return true;
Toshihiro Shimizu 890ddd
		// si potrebbe/dovrebbe fare meglio
Toshihiro Shimizu 890ddd
	};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void doCompute(TTile &tile, double frame, const TRenderSettings &ri);
Toshihiro Shimizu 890ddd
	bool canHandle(const TRenderSettings &info, double frame) { return true; }
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::WIDTH;
Toshihiro Shimizu 890ddd
		concepts[0].m_label = "Size";
Toshihiro Shimizu 890ddd
		concepts[0].m_params.push_back(m_period);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class LinearGradientFx : public TStandardZeraryFx
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	FX_PLUGIN_DECLARATION(LinearGradientFx)
Toshihiro Shimizu 890ddd
	TDoubleParamP m_period;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TDoubleParamP m_wave_amplitude;
Toshihiro Shimizu 890ddd
	TDoubleParamP m_wave_freq;
Toshihiro Shimizu 890ddd
	TDoubleParamP m_wave_phase;
Toshihiro Shimizu 890ddd
	TPixelParamP m_color1;
Toshihiro Shimizu 890ddd
	TPixelParamP m_color2;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	LinearGradientFx()
Toshihiro Shimizu 890ddd
		: m_period(100) //args, "Period")
Toshihiro Shimizu 890ddd
		  ,
Toshihiro Shimizu 890ddd
		  m_wave_amplitude(0.0) //args, "Cycle")
Toshihiro Shimizu 890ddd
		  ,
Toshihiro Shimizu 890ddd
		  m_wave_freq(0.0) //args, "Cycle")
Toshihiro Shimizu 890ddd
		  ,
Toshihiro Shimizu 890ddd
		  m_wave_phase(0.0) //args, "Cycle")
Toshihiro Shimizu 890ddd
		  ,
Toshihiro Shimizu 890ddd
		  m_color1(TPixel32::Black), m_color2(TPixel32::White)
Toshihiro Shimizu 890ddd
	//    , m_colors (0) //args, "Colors")
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		bindParam(this, "period", m_period);
Toshihiro Shimizu 890ddd
		bindParam(this, "wave_amplitude", m_wave_amplitude);
Toshihiro Shimizu 890ddd
		bindParam(this, "wave_frequency", m_wave_freq);
Toshihiro Shimizu 890ddd
		bindParam(this, "wave_phase", m_wave_phase);
Toshihiro Shimizu 890ddd
		bindParam(this, "color1", m_color1);
Toshihiro Shimizu 890ddd
		bindParam(this, "color2", m_color2);
Toshihiro Shimizu 890ddd
		m_period->setValueRange(0, std::numeric_limits<double>::max());</double>
Toshihiro Shimizu 890ddd
		m_wave_amplitude->setValueRange(0, std::numeric_limits<double>::max());</double>
Toshihiro Shimizu 890ddd
		m_period->setMeasureName("fxLength");
Toshihiro Shimizu 890ddd
		m_wave_amplitude->setMeasureName("fxLength");
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	~LinearGradientFx(){};
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
Toshihiro Shimizu 890ddd
		return true;
Toshihiro Shimizu 890ddd
		// si potrebbe/dovrebbe fare meglio
Toshihiro Shimizu 890ddd
	};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void doCompute(TTile &tile, double frame, const TRenderSettings &ri);
Toshihiro Shimizu 890ddd
	bool canHandle(const TRenderSettings &info, double frame) { return true; }
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::WIDTH;
Toshihiro Shimizu 890ddd
		concepts[0].m_label = "Size";
Toshihiro Shimizu 890ddd
		concepts[0].m_params.push_back(m_period);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//==================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
namespace
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
template <class t=""></class>
Toshihiro Shimizu 890ddd
void doComputeT(TRasterPT<t> ras, TPointD posTrasf, const TSpectrumT<t> &spectrum,</t></t>
Toshihiro Shimizu 890ddd
				double period, double count, double w_amplitude, double w_freq, double w_phase, double cycle, const TAffine &aff)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	double shift = 0;
Toshihiro Shimizu 890ddd
	double maxRadius = period * count / 2.;
Toshihiro Shimizu 890ddd
	double freq = 1.0 / period;
Toshihiro Shimizu 890ddd
	int j;
Toshihiro Shimizu 890ddd
	ras->lock();
Toshihiro Shimizu 890ddd
	for (j = 0; j < ras->getLy(); j++) {
Toshihiro Shimizu 890ddd
		TPointD posAux = posTrasf;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		//TPointD pos = tile.m_pos;
Toshihiro Shimizu 890ddd
		//pos.y += j;
Toshihiro Shimizu 890ddd
		T *pix = ras->pixels(j);
Toshihiro Shimizu 890ddd
		T *endPix = pix + ras->getLx();
Toshihiro Shimizu 890ddd
		while (pix < endPix) {
Toshihiro Shimizu 890ddd
			if (w_amplitude)
Toshihiro Shimizu 890ddd
				shift = w_amplitude * sin(w_freq * posAux.y + w_phase);
Toshihiro Shimizu 890ddd
			double radius = posAux.x + shift;
Toshihiro Shimizu 890ddd
			double t = 1;
Toshihiro Shimizu 890ddd
			if (fabs(radius) < maxRadius) {
Toshihiro Shimizu 890ddd
				t = (radius + maxRadius + cycle) * freq;
Toshihiro Shimizu 890ddd
				t -= floor(t);
Toshihiro Shimizu 890ddd
			} else if (radius < 0)
Toshihiro Shimizu 890ddd
				t = 0;
Toshihiro Shimizu 890ddd
			double polinomfactor = (-2 * t + 3) * (t * t);
Toshihiro Shimizu 890ddd
			//pos.x += 1.0;
Toshihiro Shimizu 890ddd
			*pix++ = spectrum.getPremultipliedValue(polinomfactor);
Toshihiro Shimizu 890ddd
			posAux.x += aff.a11;
Toshihiro Shimizu 890ddd
			posAux.y += aff.a21;
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
		posTrasf.x += aff.a12;
Toshihiro Shimizu 890ddd
		posTrasf.y += aff.a22;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	ras->unlock();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//==================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void LinearGradientFx::doCompute(TTile &tile, double frame, const TRenderSettings &ri)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	assert((TRaster32P)tile.getRaster() || (TRaster64P)tile.getRaster());
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	double period = m_period->getValue(frame) / ri.m_shrinkX;
Toshihiro Shimizu 890ddd
	double count = 1.0;
Toshihiro Shimizu 890ddd
	double cycle = 0;
Toshihiro Shimizu 890ddd
	double w_amplitude = m_wave_amplitude->getValue(frame) / ri.m_shrinkX;
Toshihiro Shimizu 890ddd
	double w_freq = m_wave_freq->getValue(frame) * ri.m_shrinkX;
Toshihiro Shimizu 890ddd
	double w_phase = m_wave_phase->getValue(frame);
Toshihiro Shimizu 890ddd
	w_freq = (w_freq * 0.01 * TConsts::pi) / 180;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TSpectrum::ColorKey colors[] = {
Toshihiro Shimizu 890ddd
		TSpectrum::ColorKey(0, m_color1->getValue(frame)),
Toshihiro Shimizu 890ddd
		TSpectrum::ColorKey(1, m_color2->getValue(frame))};
Toshihiro Shimizu 890ddd
	TSpectrumParamP m_colors = TSpectrumParamP(tArrayCount(colors), colors);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TAffine aff = ri.m_affine.inv();
Toshihiro Shimizu 890ddd
	TPointD posTrasf = aff * tile.m_pos;
Toshihiro Shimizu 890ddd
	multiLinear(tile.getRaster(), posTrasf, m_colors, period, count, w_amplitude, w_freq, w_phase, cycle, aff, frame);
Toshihiro Shimizu 890ddd
	/*
Toshihiro Shimizu 890ddd
	if (TRaster32P ras32 = tile.getRaster())
Toshihiro Shimizu 890ddd
    doComputeT<tpixel32>(</tpixel32>
Toshihiro Shimizu 890ddd
      ras32, posTrasf, 
Toshihiro Shimizu 890ddd
      m_colors->getValue(frame), 
Toshihiro Shimizu 890ddd
      period, count, w_amplitude, w_freq, w_phase, cycle, aff);
Toshihiro Shimizu 890ddd
  else if (TRaster64P ras64 = tile.getRaster())
Toshihiro Shimizu 890ddd
    doComputeT<tpixel64>(</tpixel64>
Toshihiro Shimizu 890ddd
      ras64, posTrasf, 
Toshihiro Shimizu 890ddd
      m_colors->getValue64(frame), 
Toshihiro Shimizu 890ddd
      period, count, w_amplitude, w_freq, w_phase, cycle, aff);
Toshihiro Shimizu 890ddd
  else
Toshihiro Shimizu 890ddd
    throw TException("MultiLinearGradientFx: unsupported Pixel Type");
Toshihiro Shimizu 890ddd
    */
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//==================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void MultiLinearGradientFx::doCompute(TTile &tile, double frame, const TRenderSettings &ri)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	assert((TRaster32P)tile.getRaster() || (TRaster64P)tile.getRaster());
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	double period = m_period->getValue(frame) / ri.m_shrinkX;
Toshihiro Shimizu 890ddd
	double count = m_count->getValue(frame);
Toshihiro Shimizu 890ddd
	double cycle = m_cycle->getValue(frame) / ri.m_shrinkX;
Toshihiro Shimizu 890ddd
	double w_amplitude = m_wave_amplitude->getValue(frame) / ri.m_shrinkX;
Toshihiro Shimizu 890ddd
	double w_freq = m_wave_freq->getValue(frame) * ri.m_shrinkX;
Toshihiro Shimizu 890ddd
	double w_phase = m_wave_phase->getValue(frame);
Toshihiro Shimizu 890ddd
	w_freq = (w_freq * 0.01 * TConsts::pi) / 180;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TAffine aff = ri.m_affine.inv();
Toshihiro Shimizu 890ddd
	TPointD posTrasf = aff * tile.m_pos;
Toshihiro Shimizu 890ddd
	multiLinear(tile.getRaster(), posTrasf, m_colors, period, count, w_amplitude, w_freq, w_phase, cycle, aff, frame);
Toshihiro Shimizu 890ddd
	/*
Toshihiro Shimizu 890ddd
	if (TRaster32P ras32 = tile.getRaster())
Toshihiro Shimizu 890ddd
    doComputeT<tpixel32>(</tpixel32>
Toshihiro Shimizu 890ddd
      ras32, posTrasf, 
Toshihiro Shimizu 890ddd
      m_colors->getValue(frame), 
Toshihiro Shimizu 890ddd
      period, count, w_amplitude, w_freq, w_phase, cycle, aff);
Toshihiro Shimizu 890ddd
  else if (TRaster64P ras64 = tile.getRaster())
Toshihiro Shimizu 890ddd
    doComputeT<tpixel64>(</tpixel64>
Toshihiro Shimizu 890ddd
      ras64, posTrasf, 
Toshihiro Shimizu 890ddd
      m_colors->getValue64(frame), 
Toshihiro Shimizu 890ddd
      period, count, w_amplitude, w_freq, w_phase, cycle, aff);
Toshihiro Shimizu 890ddd
  else
Toshihiro Shimizu 890ddd
    throw TException("MultiLinearGradientFx: unsupported Pixel Type");
Toshihiro Shimizu 890ddd
    */
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//==================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class RadialGradientFx : public TStandardZeraryFx
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	FX_PLUGIN_DECLARATION(RadialGradientFx)
Toshihiro Shimizu 890ddd
	TDoubleParamP m_period;
Toshihiro Shimizu 890ddd
	TDoubleParamP m_innerperiod;
Toshihiro Shimizu 890ddd
	TPixelParamP m_color1;
Toshihiro Shimizu 890ddd
	TPixelParamP m_color2;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	RadialGradientFx()
Toshihiro Shimizu 890ddd
		: m_period(100.0), m_innerperiod(0.0) //args, "Period")
Toshihiro Shimizu 890ddd
		  ,
Toshihiro Shimizu 890ddd
		  m_color1(TPixel32::White), m_color2(TPixel32::Transparent)
Toshihiro Shimizu 890ddd
	//    , m_colors (0) //args, "Colors")
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		m_period->setMeasureName("fxLength");
Toshihiro Shimizu 890ddd
		m_innerperiod->setMeasureName("fxLength");
Toshihiro Shimizu 890ddd
		bindParam(this, "period", m_period);
Toshihiro Shimizu 890ddd
		bindParam(this, "innerperiod", m_innerperiod);
Toshihiro Shimizu 890ddd
		bindParam(this, "color1", m_color1);
Toshihiro Shimizu 890ddd
		bindParam(this, "color2", m_color2);
Toshihiro Shimizu 890ddd
		m_period->setValueRange(0.0, std::numeric_limits<double>::max());</double>
Toshihiro Shimizu 890ddd
		m_innerperiod->setValueRange(0.0, std::numeric_limits<double>::max());</double>
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	~RadialGradientFx(){};
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
		// si potrebbe/dovrebbe fare meglio
Toshihiro Shimizu 890ddd
	};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void doCompute(TTile &tile, double frame, const TRenderSettings &ri);
Toshihiro Shimizu 890ddd
	bool canHandle(const TRenderSettings &info, double frame) { return true; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void getParamUIs(TParamUIConcept *&concepts, int &length)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		concepts = new TParamUIConcept[length = 2];
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		concepts[0].m_type = TParamUIConcept::RADIUS;
Toshihiro Shimizu 890ddd
		concepts[0].m_label = "Inner Size";
Toshihiro Shimizu 890ddd
		concepts[0].m_params.push_back(m_innerperiod);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		concepts[1].m_type = TParamUIConcept::RADIUS;
Toshihiro Shimizu 890ddd
		concepts[1].m_label = "Outer Size";
Toshihiro Shimizu 890ddd
		concepts[1].m_params.push_back(m_period);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//==================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class MultiRadialGradientFx : public TStandardZeraryFx
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	FX_PLUGIN_DECLARATION(MultiRadialGradientFx)
Toshihiro Shimizu 890ddd
	TDoubleParamP m_period;
Toshihiro Shimizu 890ddd
	TDoubleParamP m_count;
Toshihiro Shimizu 890ddd
	TDoubleParamP m_cycle;
Toshihiro Shimizu 890ddd
	TSpectrumParamP m_colors;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	MultiRadialGradientFx()
Toshihiro Shimizu 890ddd
		: m_period(100) //args, "Period")
Toshihiro Shimizu 890ddd
		  ,
Toshihiro Shimizu 890ddd
		  m_count(2) //args, "Count")
Toshihiro Shimizu 890ddd
		  ,
Toshihiro Shimizu 890ddd
		  m_cycle(0.0) //args, "Count")
Toshihiro Shimizu 890ddd
					   //    , m_colors (0) //args, "Colors")
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		m_period->setMeasureName("fxLength");
Toshihiro Shimizu 890ddd
		TSpectrum::ColorKey colors[] = {
Toshihiro Shimizu 890ddd
			TSpectrum::ColorKey(0, TPixel32::White),
Toshihiro Shimizu 890ddd
			TSpectrum::ColorKey(0.33, TPixel32::Yellow),
Toshihiro Shimizu 890ddd
			TSpectrum::ColorKey(0.66, TPixel32::Red),
Toshihiro Shimizu 890ddd
			TSpectrum::ColorKey(1, TPixel32::White)};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		m_colors = TSpectrumParamP(tArrayCount(colors), colors);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		bindParam(this, "period", m_period);
Toshihiro Shimizu 890ddd
		bindParam(this, "count", m_count);
Toshihiro Shimizu 890ddd
		bindParam(this, "cycle", m_cycle);
Toshihiro Shimizu 890ddd
		bindParam(this, "colors", m_colors);
Toshihiro Shimizu 890ddd
		m_period->setValueRange(0, (std::numeric_limits<double>::max)());</double>
Toshihiro Shimizu 890ddd
		m_cycle->setValueRange(0, (std::numeric_limits<double>::max)());</double>
Toshihiro Shimizu 890ddd
		m_count->setValueRange(0, (std::numeric_limits<double>::max)());</double>
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	~MultiRadialGradientFx(){};
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
		// si potrebbe/dovrebbe fare meglio
Toshihiro Shimizu 890ddd
	};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void doCompute(TTile &tile, double frame, const TRenderSettings &ri);
Toshihiro Shimizu 890ddd
	bool canHandle(const TRenderSettings &info, double frame) { return true; }
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::RADIUS;
Toshihiro Shimizu 890ddd
		concepts[0].m_label = "Period";
Toshihiro Shimizu 890ddd
		concepts[0].m_params.push_back(m_period);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//==================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void MultiRadialGradientFx::doCompute(TTile &tile, double frame, const TRenderSettings &ri)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	assert((TRaster32P)tile.getRaster() || (TRaster64P)tile.getRaster());
Toshihiro Shimizu 890ddd
	double period = m_period->getValue(frame) / ri.m_shrinkX;
Toshihiro Shimizu 890ddd
	double count = m_count->getValue(frame);
Toshihiro Shimizu 890ddd
	double cycle = m_cycle->getValue(frame) / ri.m_shrinkX;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TAffine aff = ri.m_affine.inv();
Toshihiro Shimizu 890ddd
	TPointD posTrasf = aff * tile.m_pos;
Toshihiro Shimizu 890ddd
	multiRadial(tile.getRaster(), posTrasf, m_colors, period, count, cycle, aff, frame);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//==================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void RadialGradientFx::doCompute(TTile &tile, double frame, const TRenderSettings &ri)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	assert((TRaster32P)tile.getRaster() || (TRaster64P)tile.getRaster());
Toshihiro Shimizu 890ddd
	double period = m_period->getValue(frame) / ri.m_shrinkX;
Toshihiro Shimizu 890ddd
	double innerperiod = m_innerperiod->getValue(frame) / ri.m_shrinkX;
Toshihiro Shimizu 890ddd
	double count = 1.0;
Toshihiro Shimizu 890ddd
	double cycle = 0.0;
Toshihiro Shimizu 890ddd
	double inner = 0.0;
Toshihiro Shimizu 890ddd
	if (innerperiod < period)
Toshihiro Shimizu 890ddd
		inner = innerperiod / period;
Toshihiro Shimizu 890ddd
	else
Toshihiro Shimizu 890ddd
		inner = 1 - TConsts::epsilon;
Toshihiro Shimizu 890ddd
	TSpectrum::ColorKey colors[] = {
Toshihiro Shimizu 890ddd
		TSpectrum::ColorKey(0, m_color1->getValue(frame)),
Toshihiro Shimizu 890ddd
		TSpectrum::ColorKey(inner, m_color1->getValue(frame)),
Toshihiro Shimizu 890ddd
		TSpectrum::ColorKey(1, m_color2->getValue(frame))};
Toshihiro Shimizu 890ddd
	TSpectrumParamP m_colors = TSpectrumParamP(tArrayCount(colors), colors);
Toshihiro Shimizu 890ddd
	TAffine aff = ri.m_affine.inv();
Toshihiro Shimizu 890ddd
	TPointD posTrasf = aff * tile.m_pos;
Toshihiro Shimizu 890ddd
	multiRadial(tile.getRaster(), posTrasf, m_colors, period, count, cycle, aff, frame);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class LightSpotFx : public TStandardZeraryFx
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	FX_PLUGIN_DECLARATION(LightSpotFx)
Toshihiro Shimizu 890ddd
	TDoubleParamP m_softness;
Toshihiro Shimizu 890ddd
	TDoubleParamP m_a;
Toshihiro Shimizu 890ddd
	TDoubleParamP m_b;
Toshihiro Shimizu 890ddd
	TPixelParamP m_color;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	LightSpotFx()
Toshihiro Shimizu 890ddd
		: m_softness(0.2) //args, "Softness")
Toshihiro Shimizu 890ddd
		  ,
Toshihiro Shimizu 890ddd
		  m_a(200) //args, "A")
Toshihiro Shimizu 890ddd
		  ,
Toshihiro Shimizu 890ddd
		  m_b(100) //args, "B")
Toshihiro Shimizu 890ddd
		  ,
Toshihiro Shimizu 890ddd
		  m_color(TPixel::Magenta) //args, "Color")
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		m_a->setMeasureName("fxLength");
Toshihiro Shimizu 890ddd
		m_b->setMeasureName("fxLength");
Toshihiro Shimizu 890ddd
		bindParam(this, "softness", m_softness);
Toshihiro Shimizu 890ddd
		bindParam(this, "a", m_a);
Toshihiro Shimizu 890ddd
		bindParam(this, "b", m_b);
Toshihiro Shimizu 890ddd
		bindParam(this, "color", m_color);
Toshihiro Shimizu 890ddd
		/*
Toshihiro Shimizu 890ddd
	  m_a->setDefaultValue(200);
Toshihiro Shimizu 890ddd
	  m_b->setDefaultValue(100);
Toshihiro Shimizu 890ddd
    m_color->setDefaultValue(TPixel::Magenta);
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	~LightSpotFx(){};
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
		// si potrebbe/dovrebbe fare meglio
Toshihiro Shimizu 890ddd
	};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void doCompute(TTile &tile, double frame, const TRenderSettings &ri);
Toshihiro Shimizu 890ddd
	bool canHandle(const TRenderSettings &info, double frame) { return true; }
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::RECT;
Toshihiro Shimizu 890ddd
		concepts[0].m_params.push_back(m_a);
Toshihiro Shimizu 890ddd
		concepts[0].m_params.push_back(m_b);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
namespace
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
template <class t=""></class>
Toshihiro Shimizu 890ddd
void doComputeT(TRasterPT<t> raster, TPointD posTrasf, const TAffine &aff, const T &pixelColor,</t>
Toshihiro Shimizu 890ddd
				double softness, double a, double b)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	double aa = a * a;
Toshihiro Shimizu 890ddd
	double bb = b * b;
Toshihiro Shimizu 890ddd
	double invaa = 1 / aa;
Toshihiro Shimizu 890ddd
	double invbb = 1 / bb;
Toshihiro Shimizu 890ddd
	double num = 2 * (aa + bb);
Toshihiro Shimizu 890ddd
	double normax = num / (5 * aa + bb);
Toshihiro Shimizu 890ddd
	int j;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	raster->lock();
Toshihiro Shimizu 890ddd
	for (j = 0; j < raster->getLy(); j++) {
Toshihiro Shimizu 890ddd
		TPointD posAux = posTrasf;
Toshihiro Shimizu 890ddd
		T *pix = raster->pixels(j);
Toshihiro Shimizu 890ddd
		T *endPix = pix + raster->getLx();
Toshihiro Shimizu 890ddd
		while (pix < endPix) {
Toshihiro Shimizu 890ddd
			double yyrot = (posAux.y) * (posAux.y);
Toshihiro Shimizu 890ddd
			double yvar = (yyrot)*invbb + 1;
Toshihiro Shimizu 890ddd
			double result;
Toshihiro Shimizu 890ddd
			double fact, xrot, tempvar, normtmp, outsideslope;
Toshihiro Shimizu 890ddd
			//pos.x += 1.0;
Toshihiro Shimizu 890ddd
			xrot = (posAux.x);
Toshihiro Shimizu 890ddd
			tempvar = xrot * xrot * invaa + yvar;
Toshihiro Shimizu 890ddd
			fact = tempvar * 0.5;
Toshihiro Shimizu 890ddd
			if (fact < 1) {
Toshihiro Shimizu 890ddd
				normtmp = num / (aa + bb + (xrot - a) * (xrot - a) + yyrot);
Toshihiro Shimizu 890ddd
				result = normtmp;
Toshihiro Shimizu 890ddd
			} else {
Toshihiro Shimizu 890ddd
				outsideslope = 1 / (1 + (fact - 1) * softness);
Toshihiro Shimizu 890ddd
				result = normax * outsideslope;
Toshihiro Shimizu 890ddd
			}
Toshihiro Shimizu 890ddd
			if (result > 1)
Toshihiro Shimizu 890ddd
				result = 1;
Toshihiro Shimizu 890ddd
			if (result < 0)
Toshihiro Shimizu 890ddd
				result = 0;
Toshihiro Shimizu 890ddd
			*pix++ = blend(T::Black, pixelColor, result);
Toshihiro Shimizu 890ddd
			posAux.x += aff.a11;
Toshihiro Shimizu 890ddd
			posAux.y += aff.a21;
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
		posTrasf.x += aff.a12;
Toshihiro Shimizu 890ddd
		posTrasf.y += aff.a22;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	raster->unlock();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//==================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void LightSpotFx::doCompute(TTile &tile, double frame, const TRenderSettings &ri)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	double a = m_a->getValue(frame) / ri.m_shrinkX;
Toshihiro Shimizu 890ddd
	double b = m_b->getValue(frame) / ri.m_shrinkX;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (a == 0.0 || b == 0.0) {
Toshihiro Shimizu 890ddd
		if ((TRaster32P)tile.getRaster())
Toshihiro Shimizu 890ddd
			((TRaster32P)tile.getRaster())->fill(TPixel32::Black);
Toshihiro Shimizu 890ddd
		else if ((TRaster64P)tile.getRaster())
Toshihiro Shimizu 890ddd
			((TRaster64P)tile.getRaster())->fill(TPixel64::Black);
Toshihiro Shimizu 890ddd
		return;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TAffine aff = ri.m_affine.inv();
Toshihiro Shimizu 890ddd
	TPointD posTrasf = aff * tile.m_pos;
Toshihiro Shimizu 890ddd
	const TPixel32 pixelColor = m_color->getValue(frame);
Toshihiro Shimizu 890ddd
	double softness = m_softness->getValue(frame);
Toshihiro Shimizu 890ddd
	if ((TRaster32P)tile.getRaster())
Toshihiro Shimizu 890ddd
		doComputeT<tpixel32>(tile.getRaster(), posTrasf, aff, pixelColor, softness, a, b);</tpixel32>
Toshihiro Shimizu 890ddd
	else if ((TRaster64P)tile.getRaster())
Toshihiro Shimizu 890ddd
		doComputeT<tpixel64>(tile.getRaster(), posTrasf, aff, toPixel64(pixelColor), softness, a, b);</tpixel64>
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
FX_PLUGIN_IDENTIFIER(SpiralFx, "spiralFx")
Toshihiro Shimizu 890ddd
FX_PLUGIN_IDENTIFIER(FadeFx, "fadeFx")
Toshihiro Shimizu 890ddd
FX_PLUGIN_IDENTIFIER(RadialGradientFx, "radialGradientFx")
Toshihiro Shimizu 890ddd
FX_PLUGIN_IDENTIFIER(MultiRadialGradientFx, "multiRadialGradientFx")
Toshihiro Shimizu 890ddd
FX_PLUGIN_IDENTIFIER(LinearGradientFx, "linearGradientFx")
Toshihiro Shimizu 890ddd
FX_PLUGIN_IDENTIFIER(MultiLinearGradientFx, "multiLinearGradientFx")
Toshihiro Shimizu 890ddd
FX_PLUGIN_IDENTIFIER(LightSpotFx, "lightSpotFx")
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*
Toshihiro Shimizu 890ddd
TLIBMAIN {
Toshihiro Shimizu 890ddd
static TPluginInfo info("stdfx");
Toshihiro Shimizu 890ddd
return &info;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
DV_EXPORT_API void initStdFx()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
}