Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

logarithmic option for spiral fx

shun-iwasawa83f5eed9c3c4
diff --git a/stuff/config/current.txt b/stuff/config/current.txt
index cb1f02af8..9d283396d 100644
--- a/stuff/config/current.txt
+++ b/stuff/config/current.txt
@@ -405,6 +405,7 @@
<item>"STD_solarizeFx.peak_edge" "Peak Edge" </item>
<item>"STD_spiralFx" "Spiral" </item>
+ <item>"STD_spiralFx.type" "Type" </item>
<item>"STD_spiralFx.freq" "Frequency" </item>
<item>"STD_spiralFx.phase" "Phase" </item>
<item>"STD_spiralFx.colors" "Colors" </item>
diff --git a/stuff/profiles/layouts/fxs/STD_spiralFx.xml b/stuff/profiles/layouts/fxs/STD_spiralFx.xml
index 49a05717c..5deef6131 100644
--- a/stuff/profiles/layouts/fxs/STD_spiralFx.xml
+++ b/stuff/profiles/layouts/fxs/STD_spiralFx.xml
@@ -1,5 +1,6 @@
<fxlayout>
<page name="Spiral">
+ <control>type</control>
<control>colors</control>
<control>freq</control>
<control>phase</control>
diff --git a/toonz/sources/stdfx/stdfx.cpp b/toonz/sources/stdfx/stdfx.cpp
index 1183754d0..163d1da60 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 <class T>
void doComputeT(TRasterPT<T> raster, TPointD posTrasf, const TAffine &aff,
- const TSpectrumT<T> &spectrum, double freq, double phase) {
+ const TSpectrumT<T> &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<T> 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<T> 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<TPixel32>(ras32, posTrasf, aff, m_spectrum->getValue(frame),
- freq, phase);
+ freq, phase, isLogarithmic);
else if (TRaster64P ras64 = tile.getRaster())
doComputeT<TPixel64>(ras64, posTrasf, aff, m_spectrum->getValue64(frame),
- freq, phase);
+ freq, phase, isLogarithmic);
else
throw TException("SpiralFx: unsupported Pixel Type");
}