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 "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
Shinya Kitaoka d1f6c4
class ColorCardFx final : public TBaseZeraryFx {
Shinya Kitaoka 120a6e
  FX_DECLARATION(ColorCardFx)
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TPixelParamP m_color;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  ColorCardFx() : m_color(TPixel32::Green) {
Shinya Kitaoka 120a6e
    bindParam(this, "color", m_color);
Shinya Kitaoka 120a6e
    m_color->setDefaultValue(TPixel32::Green);
Shinya Kitaoka 120a6e
    setName(L"ColorCardFx");
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 38fd86
  bool canHandle(const TRenderSettings &info, double frame) override {
Shinya Kitaoka 38fd86
    return true;
Shinya Kitaoka 38fd86
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 38fd86
  bool doGetBBox(double frame, TRectD &bBox,
Shinya Kitaoka 38fd86
                 const TRenderSettings &info) override {
Shinya Kitaoka 120a6e
    bBox = TConsts::infiniteRectD;
Shinya Kitaoka 120a6e
    return true;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  void doCompute(TTile &tile, double frame, const TRenderSettings &) override {
Shinya Kitaoka 120a6e
    TRaster32P raster32 = tile.getRaster();
Shinya Kitaoka 120a6e
    if (raster32)
Shinya Kitaoka 120a6e
      raster32->fill(m_color->getPremultipliedValue(frame));
Shinya Kitaoka 120a6e
    else {
Shinya Kitaoka 120a6e
      TRaster64P ras64 = tile.getRaster();
Shinya Kitaoka 120a6e
      if (ras64)
Shinya Kitaoka 120a6e
        ras64->fill(toPixel64(m_color->getPremultipliedValue(frame)));
Shinya Kitaoka 120a6e
      else
Shinya Kitaoka 120a6e
        throw TException("ColorCardFx unsupported pixel type");
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  };
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//==================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class CheckBoardFx final : public TBaseZeraryFx {
Shinya Kitaoka 120a6e
  FX_DECLARATION(CheckBoardFx)
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TPixelParamP m_color1, m_color2;
Shinya Kitaoka 120a6e
  TDoubleParamP m_size;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  CheckBoardFx()
Shinya Kitaoka 120a6e
      : m_color1(TPixel32::Black), m_color2(TPixel32::White), m_size(50) {
Shinya Kitaoka 120a6e
    m_size->setMeasureName("fxLength");
Shinya Kitaoka 120a6e
    bindParam(this, "color1", m_color1);
Shinya Kitaoka 120a6e
    bindParam(this, "color2", m_color2);
Shinya Kitaoka 120a6e
    bindParam(this, "size", m_size);
Shinya Kitaoka 120a6e
    m_color1->setDefaultValue(TPixel32::Black);
Shinya Kitaoka 120a6e
    m_color2->setDefaultValue(TPixel32::White);
Shinya Kitaoka 120a6e
    m_size->setValueRange(1, 1000);
Shinya Kitaoka 120a6e
    m_size->setDefaultValue(50);
Shinya Kitaoka 120a6e
    setName(L"CheckBoardFx");
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 38fd86
  bool canHandle(const TRenderSettings &info, double frame) override {
Shinya Kitaoka 38fd86
    return false;
Shinya Kitaoka 38fd86
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  bool doGetBBox(double, TRectD &bBox, const TRenderSettings &info) override {
Shinya Kitaoka 120a6e
    bBox = TConsts::infiniteRectD;
Shinya Kitaoka 120a6e
    return true;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 38fd86
  void doCompute(TTile &tile, double frame,
Shinya Kitaoka 38fd86
                 const TRenderSettings &info) override {
Shinya Kitaoka 120a6e
    const TPixel32 &c1 = m_color1->getValue(frame);
Shinya Kitaoka 120a6e
    const TPixel32 &c2 = m_color2->getValue(frame);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    double size = m_size->getValue(frame);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    assert(info.m_shrinkX == info.m_shrinkY);
Shinya Kitaoka 120a6e
    size *= info.m_affine.a11 / info.m_shrinkX;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    TDimensionD dim(size, size);
Shinya Kitaoka 120a6e
    TRop::checkBoard(tile.getRaster(), c1, c2, dim, tile.m_pos);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  void getParamUIs(TParamUIConcept *&concepts, int &length) override {
Shinya Kitaoka 120a6e
    concepts = new TParamUIConcept[length = 1];
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    concepts[0].m_type  = TParamUIConcept::SIZE;
Shinya Kitaoka 120a6e
    concepts[0].m_label = "Size";
Shinya Kitaoka 120a6e
    concepts[0].m_params.push_back(m_size);
Shinya Kitaoka 120a6e
  }
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")