diff --git a/stuff/config/current.txt b/stuff/config/current.txt index cb1f02a..9d28339 100644 --- a/stuff/config/current.txt +++ b/stuff/config/current.txt @@ -405,6 +405,7 @@ "STD_solarizeFx.peak_edge" "Peak Edge" "STD_spiralFx" "Spiral" + "STD_spiralFx.type" "Type" "STD_spiralFx.freq" "Frequency" "STD_spiralFx.phase" "Phase" "STD_spiralFx.colors" "Colors" diff --git a/stuff/profiles/layouts/fxs/STD_spiralFx.xml b/stuff/profiles/layouts/fxs/STD_spiralFx.xml index 49a0571..5deef61 100644 --- a/stuff/profiles/layouts/fxs/STD_spiralFx.xml +++ b/stuff/profiles/layouts/fxs/STD_spiralFx.xml @@ -1,5 +1,6 @@ + type colors freq phase diff --git a/toonz/sources/stdfx/stdfx.cpp b/toonz/sources/stdfx/stdfx.cpp index 1183754..163d1da 100644 --- a/toonz/sources/stdfx/stdfx.cpp +++ b/toonz/sources/stdfx/stdfx.cpp @@ -69,13 +69,17 @@ public: class SpiralFx final : public TStandardZeraryFx { FX_PLUGIN_DECLARATION(SpiralFx) + TIntEnumParamP m_type; TDoubleParamP m_freq; TDoubleParamP m_phase; TSpectrumParamP m_spectrum; + enum SpiralType { Archimedean, Logarithmic }; + public: SpiralFx() - : m_freq(0.1) // args, "Freq") + : m_type(new TIntEnumParam(Archimedean, "Archimedean")) + , m_freq(0.1) // args, "Freq") , m_phase(0.0) // args, "Phase") { // m_freq->setDefaultValue(0.1); @@ -97,6 +101,8 @@ TPixel32 colors[] = { TSpectrum::ColorKey(1, transparent)}; m_spectrum = TSpectrumParamP(colors); + m_type->addItem(Logarithmic, "Logarithmic"); + bindParam(this, "type", m_type); bindParam(this, "colors", m_spectrum); bindParam(this, "freq", m_freq); bindParam(this, "phase", m_phase); @@ -122,7 +128,8 @@ TPixel32 colors[] = { namespace { template void doComputeT(TRasterPT raster, TPointD posTrasf, const TAffine &aff, - const TSpectrumT &spectrum, double freq, double phase) { + const TSpectrumT &spectrum, double freq, double phase, + bool isLogarithmic) { raster->lock(); for (int y = 0; y < raster->getLy(); y++) { TPointD posAux = posTrasf; @@ -131,6 +138,7 @@ void doComputeT(TRasterPT raster, TPointD posTrasf, const TAffine &aff, double ang = 0.0; if (posAux.x != 0 || posAux.y != 0) ang = atan2(posAux.y, posAux.x); double r = sqrt(posAux.x * posAux.x + posAux.y * posAux.y); + if (isLogarithmic) r = std::log(r) * 30.0; double v = 0.5 * (1 + sin(r * freq + ang + phase)); *pix++ = spectrum.getPremultipliedValue(v); posAux.x += aff.a11; @@ -146,18 +154,19 @@ void doComputeT(TRasterPT raster, TPointD posTrasf, const TAffine &aff, //================================================================== void SpiralFx::doCompute(TTile &tile, double frame, const TRenderSettings &ri) { - double phase = m_phase->getValue(frame); - double freq = m_freq->getValue(frame); + double phase = m_phase->getValue(frame); + double freq = m_freq->getValue(frame); + bool isLogarithmic = SpiralType(m_type->getValue()) == Logarithmic; TAffine aff = ri.m_affine.inv(); TPointD posTrasf = aff * tile.m_pos; if (TRaster32P ras32 = tile.getRaster()) doComputeT(ras32, posTrasf, aff, m_spectrum->getValue(frame), - freq, phase); + freq, phase, isLogarithmic); else if (TRaster64P ras64 = tile.getRaster()) doComputeT(ras64, posTrasf, aff, m_spectrum->getValue64(frame), - freq, phase); + freq, phase, isLogarithmic); else throw TException("SpiralFx: unsupported Pixel Type"); }