logarithmic option for spiral fx
This commit is contained in:
parent
0ef650c288
commit
83f5eed9c3
3 changed files with 17 additions and 6 deletions
|
@ -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>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<fxlayout>
|
||||
<page name="Spiral">
|
||||
<control>type</control>
|
||||
<control>colors</control>
|
||||
<control>freq</control>
|
||||
<control>phase</control>
|
||||
|
|
|
@ -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;
|
||||
|
@ -148,16 +156,17 @@ 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);
|
||||
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");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue