|
shun-iwasawa |
6817df |
#include "iwa_corridorgradientfx.h"
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
#include "trop.h"
|
|
shun-iwasawa |
6817df |
#include "tparamuiconcept.h"
|
|
shun-iwasawa |
6817df |
#include "tspectrumparam.h"
|
|
shun-iwasawa |
6817df |
#include "gradients.h"
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
#include <qpolygonf></qpolygonf>
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
#include <array></array>
|
|
shun-iwasawa |
6817df |
#include <algorithm></algorithm>
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
//------------------------------------------------------------
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
Iwa_CorridorGradientFx::Iwa_CorridorGradientFx()
|
|
shun-iwasawa |
6817df |
: m_shape(new TIntEnumParam(0, "Quadrangle"))
|
|
shun-iwasawa |
6817df |
, m_innerColor(TPixel32::White)
|
|
shun-iwasawa |
6817df |
, m_outerColor(TPixel32::Black)
|
|
shun-iwasawa |
6817df |
, m_curveType(new TIntEnumParam()) {
|
|
shun-iwasawa |
6817df |
for (int inout = 0; inout < 2; inout++) {
|
|
shun-iwasawa |
6817df |
double size = (inout == 0) ? 50. : 400.;
|
|
shun-iwasawa |
6817df |
std::string inout_str = (inout == 0) ? "_in" : "_out";
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
for (int c = 0; c < 4; c++) {
|
|
shun-iwasawa |
6817df |
Qt::Corner corner = (Qt::Corner)c;
|
|
shun-iwasawa |
6817df |
TPointD basePos(1, 1);
|
|
shun-iwasawa |
6817df |
if (corner == Qt::TopLeftCorner || corner == Qt::BottomLeftCorner)
|
|
shun-iwasawa |
6817df |
basePos.x *= -1;
|
|
shun-iwasawa |
6817df |
if (corner == Qt::BottomLeftCorner || corner == Qt::BottomRightCorner)
|
|
shun-iwasawa |
6817df |
basePos.y *= -1;
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
m_points[inout][corner] = basePos * size;
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
m_points[inout][corner]->getX()->setMeasureName("fxLength");
|
|
shun-iwasawa |
6817df |
m_points[inout][corner]->getY()->setMeasureName("fxLength");
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
std::string TB_str =
|
|
shun-iwasawa |
6817df |
(corner == Qt::TopLeftCorner || corner == Qt::TopRightCorner)
|
|
shun-iwasawa |
6817df |
? "top"
|
|
shun-iwasawa |
6817df |
: "bottom";
|
|
shun-iwasawa |
6817df |
std::string LR_str =
|
|
shun-iwasawa |
6817df |
(corner == Qt::TopLeftCorner || corner == Qt::BottomLeftCorner)
|
|
shun-iwasawa |
6817df |
? "_left"
|
|
shun-iwasawa |
6817df |
: "_right";
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
bindParam(this, TB_str + LR_str + inout_str, m_points[inout][corner]);
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
m_shape->addItem(1, "Circle");
|
|
shun-iwasawa |
6817df |
bindParam(this, "shape", m_shape);
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
m_curveType->addItem(EaseInOut, "Ease In-Out");
|
|
shun-iwasawa |
6817df |
m_curveType->addItem(Linear, "Linear");
|
|
shun-iwasawa |
6817df |
m_curveType->addItem(EaseIn, "Ease In");
|
|
shun-iwasawa |
6817df |
m_curveType->addItem(EaseOut, "Ease Out");
|
|
shun-iwasawa |
6817df |
m_curveType->setDefaultValue(Linear);
|
|
shun-iwasawa |
6817df |
m_curveType->setValue(Linear);
|
|
shun-iwasawa |
6817df |
bindParam(this, "curveType", m_curveType);
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
bindParam(this, "inner_color", m_innerColor);
|
|
shun-iwasawa |
6817df |
bindParam(this, "outer_color", m_outerColor);
|
|
shun-iwasawa |
481b59 |
|
|
shun-iwasawa |
481b59 |
enableComputeInFloat(true);
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
//------------------------------------------------------------
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
bool Iwa_CorridorGradientFx::doGetBBox(double frame, TRectD &bBox,
|
|
shun-iwasawa |
6817df |
const TRenderSettings &ri) {
|
|
shun-iwasawa |
6817df |
bBox = TConsts::infiniteRectD;
|
|
shun-iwasawa |
6817df |
return true;
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
//------------------------------------------------------------
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
namespace {
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
QPointF toQPointF(const TPointD &p) { return QPointF(p.x, p.y); }
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
double WedgeProduct(const TPointD v, const TPointD w) {
|
|
shun-iwasawa |
6817df |
return v.x * w.y - v.y * w.x;
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
struct BilinearParam {
|
|
shun-iwasawa |
6817df |
TPointD p0, b1, b2, b3;
|
|
shun-iwasawa |
6817df |
};
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
//------------------------------------------------------------
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
double getFactor(const TPointD &p, const BilinearParam ¶m,
|
|
shun-iwasawa |
6817df |
const GradientCurveType type) {
|
|
shun-iwasawa |
6817df |
double t;
|
|
shun-iwasawa |
6817df |
TPointD q = p - param.p0;
|
|
shun-iwasawa |
6817df |
// Set up quadratic formula
|
|
shun-iwasawa |
6817df |
float A = WedgeProduct(param.b2, param.b3);
|
|
shun-iwasawa |
6817df |
float B = WedgeProduct(param.b3, q) - WedgeProduct(param.b1, param.b2);
|
|
shun-iwasawa |
6817df |
float C = WedgeProduct(param.b1, q);
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
// Solve for v
|
|
shun-iwasawa |
6817df |
if (std::abs(A) < 0.001) {
|
|
shun-iwasawa |
6817df |
// Linear form
|
|
shun-iwasawa |
6817df |
t = -C / B;
|
|
shun-iwasawa |
6817df |
} else {
|
|
shun-iwasawa |
6817df |
// Quadratic form
|
|
shun-iwasawa |
6817df |
float discrim = B * B - 4 * A * C;
|
|
shun-iwasawa |
6817df |
t = 0.5 * (-B - std::sqrt(discrim)) / A;
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
double factor;
|
|
shun-iwasawa |
6817df |
switch (type) {
|
|
shun-iwasawa |
6817df |
case Linear:
|
|
shun-iwasawa |
6817df |
factor = t;
|
|
shun-iwasawa |
6817df |
break;
|
|
shun-iwasawa |
6817df |
case EaseIn:
|
|
shun-iwasawa |
6817df |
factor = t * t;
|
|
shun-iwasawa |
6817df |
break;
|
|
shun-iwasawa |
6817df |
case EaseOut:
|
|
shun-iwasawa |
6817df |
factor = 1.0 - (1.0 - t) * (1.0 - t);
|
|
shun-iwasawa |
6817df |
break;
|
|
shun-iwasawa |
6817df |
case EaseInOut:
|
|
shun-iwasawa |
6817df |
default:
|
|
shun-iwasawa |
6817df |
factor = (-2 * t + 3) * (t * t);
|
|
shun-iwasawa |
6817df |
break;
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
return factor;
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
//------------------------------------------------------------
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
template <typename pixel="" raster,="" typename=""></typename>
|
|
shun-iwasawa |
6817df |
void doQuadrangleT(RASTER ras, TDimensionI dim, TPointD pos[2][4],
|
|
shun-iwasawa |
6817df |
const TSpectrumT<pixel> &spectrum, GradientCurveType type) {</pixel>
|
|
shun-iwasawa |
6817df |
auto buildPolygon = [&](QPolygonF &pol, Qt::Corner c1, Qt::Corner c2) {
|
|
shun-iwasawa |
6817df |
pol << toQPointF(pos[0][(int)c1]) << toQPointF(pos[1][(int)c1])
|
|
shun-iwasawa |
6817df |
<< toQPointF(pos[1][(int)c2]) << toQPointF(pos[0][(int)c2]);
|
|
shun-iwasawa |
6817df |
};
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
auto buildBilinearParam = [&](BilinearParam &bp, Qt::Corner c1,
|
|
shun-iwasawa |
6817df |
Qt::Corner c2) {
|
|
shun-iwasawa |
6817df |
bp.p0 = pos[0][(int)c1];
|
|
shun-iwasawa |
6817df |
bp.b1 = pos[0][(int)c2] - pos[0][(int)c1];
|
|
shun-iwasawa |
6817df |
bp.b2 = pos[1][(int)c1] - pos[0][(int)c1];
|
|
shun-iwasawa |
6817df |
bp.b3 =
|
|
shun-iwasawa |
6817df |
pos[0][(int)c1] - pos[0][(int)c2] - pos[1][(int)c1] + pos[1][(int)c2];
|
|
shun-iwasawa |
6817df |
};
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
std::array<qpolygonf, 4=""> polygons;</qpolygonf,>
|
|
shun-iwasawa |
6817df |
std::array<bilinearparam, 4=""> params;</bilinearparam,>
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
// Top
|
|
shun-iwasawa |
6817df |
buildPolygon(polygons[0], Qt::TopLeftCorner, Qt::TopRightCorner);
|
|
shun-iwasawa |
6817df |
buildBilinearParam(params[0], Qt::TopLeftCorner, Qt::TopRightCorner);
|
|
shun-iwasawa |
6817df |
// Left
|
|
shun-iwasawa |
6817df |
buildPolygon(polygons[1], Qt::BottomLeftCorner, Qt::TopLeftCorner);
|
|
shun-iwasawa |
6817df |
buildBilinearParam(params[1], Qt::BottomLeftCorner, Qt::TopLeftCorner);
|
|
shun-iwasawa |
6817df |
// Bottom
|
|
shun-iwasawa |
6817df |
buildPolygon(polygons[2], Qt::BottomRightCorner, Qt::BottomLeftCorner);
|
|
shun-iwasawa |
6817df |
buildBilinearParam(params[2], Qt::BottomRightCorner, Qt::BottomLeftCorner);
|
|
shun-iwasawa |
6817df |
// Right
|
|
shun-iwasawa |
6817df |
buildPolygon(polygons[3], Qt::TopRightCorner, Qt::BottomRightCorner);
|
|
shun-iwasawa |
6817df |
buildBilinearParam(params[3], Qt::TopRightCorner, Qt::BottomRightCorner);
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
QPolygonF innerPolygon;
|
|
shun-iwasawa |
6817df |
innerPolygon << toQPointF(pos[0][Qt::TopLeftCorner])
|
|
shun-iwasawa |
6817df |
<< toQPointF(pos[0][Qt::TopRightCorner])
|
|
shun-iwasawa |
6817df |
<< toQPointF(pos[0][Qt::BottomRightCorner])
|
|
shun-iwasawa |
6817df |
<< toQPointF(pos[0][Qt::BottomLeftCorner]);
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
ras->lock();
|
|
shun-iwasawa |
6817df |
for (int j = 0; j < ras->getLy(); j++) {
|
|
shun-iwasawa |
6817df |
PIXEL *pix = ras->pixels(j);
|
|
shun-iwasawa |
6817df |
PIXEL *endPix = pix + ras->getLx();
|
|
shun-iwasawa |
6817df |
int i = 0;
|
|
shun-iwasawa |
6817df |
while (pix < endPix) {
|
|
shun-iwasawa |
6817df |
QPointF p(i, j);
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
double factor;
|
|
shun-iwasawa |
6817df |
bool found = false;
|
|
shun-iwasawa |
6817df |
for (int edge = 0; edge < 4; edge++) {
|
|
shun-iwasawa |
6817df |
if (polygons[edge].containsPoint(p, Qt::WindingFill)) {
|
|
shun-iwasawa |
6817df |
factor = getFactor(TPointD(i, j), params.at(edge), type);
|
|
shun-iwasawa |
6817df |
found = true;
|
|
shun-iwasawa |
6817df |
break;
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
if (!found) {
|
|
shun-iwasawa |
6817df |
if (innerPolygon.containsPoint(p, Qt::WindingFill))
|
|
shun-iwasawa |
6817df |
factor = 0.0;
|
|
shun-iwasawa |
6817df |
else
|
|
shun-iwasawa |
6817df |
factor = 1.0;
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
*pix++ = spectrum.getPremultipliedValue(factor);
|
|
shun-iwasawa |
6817df |
i++;
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
ras->unlock();
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
//------------------------------------------------------------
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
template <typename pixel="" raster,="" typename=""></typename>
|
|
shun-iwasawa |
6817df |
void doCircleT(RASTER ras, TDimensionI dim, TPointD pos[2][4],
|
|
shun-iwasawa |
6817df |
const TSpectrumT<pixel> &spectrum, GradientCurveType type) {</pixel>
|
|
shun-iwasawa |
6817df |
auto lerp = [](TPointD p1, TPointD p2, double f) {
|
|
shun-iwasawa |
6817df |
return p1 * (1 - f) + p2 * f;
|
|
shun-iwasawa |
6817df |
};
|
|
shun-iwasawa |
6817df |
auto bilinearPos = [&](TPointD uv, int inout) {
|
|
shun-iwasawa |
6817df |
return lerp(lerp(pos[inout][Qt::BottomLeftCorner],
|
|
shun-iwasawa |
6817df |
pos[inout][Qt::BottomRightCorner], uv.x),
|
|
shun-iwasawa |
6817df |
lerp(pos[inout][Qt::TopLeftCorner],
|
|
shun-iwasawa |
6817df |
pos[inout][Qt::TopRightCorner], uv.x),
|
|
shun-iwasawa |
6817df |
uv.y);
|
|
shun-iwasawa |
6817df |
};
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
const int DIVNUM = 36;
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
std::array<tpointd, divnum=""> innerPos;</tpointd,>
|
|
shun-iwasawa |
6817df |
std::array<tpointd, divnum=""> outerPos;</tpointd,>
|
|
shun-iwasawa |
6817df |
double tmpRadius = std::sqrt(2.0) / 2.0;
|
|
shun-iwasawa |
6817df |
for (int div = 0; div < DIVNUM; div++) {
|
|
shun-iwasawa |
6817df |
double angle = 2.0 * M_PI * (double)div / (double)DIVNUM;
|
|
shun-iwasawa |
6817df |
// circle position in uv coordinate
|
|
shun-iwasawa |
6817df |
TPointD uv(tmpRadius * std::cos(angle) + 0.5,
|
|
shun-iwasawa |
6817df |
tmpRadius * std::sin(angle) + 0.5);
|
|
shun-iwasawa |
6817df |
// compute inner and outer circle positions by bilinear interpolation
|
|
shun-iwasawa |
6817df |
// using uv coordinate values.
|
|
shun-iwasawa |
6817df |
innerPos[div] = bilinearPos(uv, 0);
|
|
shun-iwasawa |
6817df |
outerPos[div] = bilinearPos(uv, 1);
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
// - - - - - - - -
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
auto buildPolygon = [&](QPolygonF &pol, int id1, int id2) {
|
|
shun-iwasawa |
6817df |
pol << toQPointF(innerPos[id2]) << toQPointF(outerPos[id2])
|
|
shun-iwasawa |
6817df |
<< toQPointF(outerPos[id1]) << toQPointF(innerPos[id1]);
|
|
shun-iwasawa |
6817df |
};
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
auto buildBilinearParam = [&](BilinearParam &bp, int id1, int id2) {
|
|
shun-iwasawa |
6817df |
bp.p0 = innerPos[id2];
|
|
shun-iwasawa |
6817df |
bp.b1 = innerPos[id1] - innerPos[id2];
|
|
shun-iwasawa |
6817df |
bp.b2 = outerPos[id2] - innerPos[id2];
|
|
shun-iwasawa |
6817df |
bp.b3 = innerPos[id2] - innerPos[id1] - outerPos[id2] + outerPos[id1];
|
|
shun-iwasawa |
6817df |
};
|
|
shun-iwasawa |
6817df |
std::array<qpolygonf, divnum=""> polygons;</qpolygonf,>
|
|
shun-iwasawa |
6817df |
std::array<bilinearparam, divnum=""> params;</bilinearparam,>
|
|
shun-iwasawa |
6817df |
QPolygonF innerPolygon;
|
|
shun-iwasawa |
6817df |
for (int div = 0; div < DIVNUM; div++) {
|
|
shun-iwasawa |
6817df |
int next_div = (div == DIVNUM - 1) ? 0 : div + 1;
|
|
shun-iwasawa |
6817df |
// create polygon and bilinear parameters for each piece surrounding the
|
|
shun-iwasawa |
6817df |
// circle
|
|
shun-iwasawa |
6817df |
buildPolygon(polygons[div], div, next_div);
|
|
shun-iwasawa |
6817df |
buildBilinearParam(params[div], div, next_div);
|
|
shun-iwasawa |
6817df |
// create inner circle polygon
|
|
shun-iwasawa |
6817df |
innerPolygon << toQPointF(innerPos[div]);
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
// - - - ok, ready to render
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
ras->lock();
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
for (int j = 0; j < ras->getLy(); j++) {
|
|
shun-iwasawa |
6817df |
PIXEL *pix = ras->pixels(j);
|
|
shun-iwasawa |
6817df |
PIXEL *endPix = pix + ras->getLx();
|
|
shun-iwasawa |
6817df |
int i = 0;
|
|
shun-iwasawa |
6817df |
while (pix < endPix) {
|
|
shun-iwasawa |
6817df |
QPointF p(i, j);
|
|
shun-iwasawa |
6817df |
double factor;
|
|
shun-iwasawa |
6817df |
bool found = false;
|
|
shun-iwasawa |
6817df |
for (int div = 0; div < DIVNUM; div++) {
|
|
shun-iwasawa |
6817df |
// check if the point is inside of the surrounding pieces
|
|
shun-iwasawa |
6817df |
if (polygons[div].containsPoint(p, Qt::WindingFill)) {
|
|
shun-iwasawa |
6817df |
// compute factor by invert bilinear interpolation
|
|
shun-iwasawa |
6817df |
factor = getFactor(TPointD(i, j), params.at(div), type);
|
|
shun-iwasawa |
6817df |
found = true;
|
|
shun-iwasawa |
6817df |
break;
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
if (!found) {
|
|
shun-iwasawa |
6817df |
if (innerPolygon.containsPoint(p, Qt::WindingFill))
|
|
shun-iwasawa |
6817df |
factor = 0.0;
|
|
shun-iwasawa |
6817df |
else
|
|
shun-iwasawa |
6817df |
factor = 1.0;
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
*pix++ = spectrum.getPremultipliedValue(factor);
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
i++;
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
ras->unlock();
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
}; // namespace
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
//------------------------------------------------------------
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
void Iwa_CorridorGradientFx::doCompute(TTile &tile, double frame,
|
|
shun-iwasawa |
6817df |
const TRenderSettings &ri) {
|
|
shun-iwasawa |
481b59 |
if (!((TRaster32P)tile.getRaster()) && !((TRaster64P)tile.getRaster()) &&
|
|
shun-iwasawa |
481b59 |
!((TRasterFP)tile.getRaster())) {
|
|
shun-iwasawa |
6817df |
throw TRopException("unsupported input pixel type");
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
// convert shape position to render region coordinate
|
|
shun-iwasawa |
6817df |
TPointD pos[2][4];
|
|
shun-iwasawa |
6817df |
TAffine aff = ri.m_affine;
|
|
shun-iwasawa |
6817df |
TDimensionI dimOut(tile.getRaster()->getLx(), tile.getRaster()->getLy());
|
|
shun-iwasawa |
6817df |
TPointD dimOffset((float)dimOut.lx / 2.0f, (float)dimOut.ly / 2.0f);
|
|
shun-iwasawa |
6817df |
for (int inout = 0; inout < 2; inout++) {
|
|
shun-iwasawa |
6817df |
for (int c = 0; c < 4; c++) {
|
|
shun-iwasawa |
6817df |
TPointD _point = m_points[inout][c]->getValue(frame);
|
|
shun-iwasawa |
6817df |
pos[inout][c] = aff * _point -
|
|
shun-iwasawa |
6817df |
(tile.m_pos + tile.getRaster()->getCenterD()) + dimOffset;
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
std::vector<tspectrum::colorkey> colors = {</tspectrum::colorkey>
|
|
shun-iwasawa |
6817df |
TSpectrum::ColorKey(0, m_innerColor->getValue(frame)),
|
|
shun-iwasawa |
6817df |
TSpectrum::ColorKey(1, m_outerColor->getValue(frame))};
|
|
shun-iwasawa |
6817df |
TSpectrumParamP m_colors = TSpectrumParamP(colors);
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
tile.getRaster()->clear();
|
|
shun-iwasawa |
6817df |
TRaster32P outRas32 = (TRaster32P)tile.getRaster();
|
|
shun-iwasawa |
6817df |
TRaster64P outRas64 = (TRaster64P)tile.getRaster();
|
|
shun-iwasawa |
481b59 |
TRasterFP outRasF = (TRasterFP)tile.getRaster();
|
|
shun-iwasawa |
6817df |
if (m_shape->getValue() == 0) { // Quadrangle
|
|
shun-iwasawa |
6817df |
if (outRas32)
|
|
shun-iwasawa |
6817df |
doQuadrangleT<traster32p, tpixel32="">(</traster32p,>
|
|
shun-iwasawa |
6817df |
outRas32, dimOut, pos, m_colors->getValue(frame),
|
|
shun-iwasawa |
6817df |
(GradientCurveType)m_curveType->getValue());
|
|
shun-iwasawa |
6817df |
else if (outRas64)
|
|
shun-iwasawa |
6817df |
doQuadrangleT<traster64p, tpixel64="">(</traster64p,>
|
|
shun-iwasawa |
6817df |
outRas64, dimOut, pos, m_colors->getValue64(frame),
|
|
shun-iwasawa |
6817df |
(GradientCurveType)m_curveType->getValue());
|
|
shun-iwasawa |
481b59 |
else if (outRasF)
|
|
shun-iwasawa |
481b59 |
doQuadrangleT<trasterfp, tpixelf="">(</trasterfp,>
|
|
shun-iwasawa |
481b59 |
outRasF, dimOut, pos, m_colors->getValueF(frame),
|
|
shun-iwasawa |
481b59 |
(GradientCurveType)m_curveType->getValue());
|
|
shun-iwasawa |
6817df |
} else { // m_shape == 1 : Circle
|
|
shun-iwasawa |
6817df |
if (outRas32)
|
|
shun-iwasawa |
6817df |
doCircleT<traster32p, tpixel32="">(</traster32p,>
|
|
shun-iwasawa |
6817df |
outRas32, dimOut, pos, m_colors->getValue(frame),
|
|
shun-iwasawa |
6817df |
(GradientCurveType)m_curveType->getValue());
|
|
shun-iwasawa |
6817df |
else if (outRas64)
|
|
shun-iwasawa |
6817df |
doCircleT<traster64p, tpixel64="">(</traster64p,>
|
|
shun-iwasawa |
6817df |
outRas64, dimOut, pos, m_colors->getValue64(frame),
|
|
shun-iwasawa |
6817df |
(GradientCurveType)m_curveType->getValue());
|
|
shun-iwasawa |
481b59 |
else if (outRasF)
|
|
shun-iwasawa |
481b59 |
doCircleT<trasterfp, tpixelf="">(outRasF, dimOut, pos,</trasterfp,>
|
|
shun-iwasawa |
481b59 |
m_colors->getValueF(frame),
|
|
shun-iwasawa |
481b59 |
(GradientCurveType)m_curveType->getValue());
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
//------------------------------------------------------------
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
void Iwa_CorridorGradientFx::getParamUIs(TParamUIConcept *&concepts,
|
|
shun-iwasawa |
6817df |
int &length) {
|
|
shun-iwasawa |
6817df |
concepts = new TParamUIConcept[length = 6];
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
int vectorUiIdOffset = 2;
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
std::array<qt::corner, 4=""> loopIds{Qt::TopLeftCorner, Qt::TopRightCorner,</qt::corner,>
|
|
shun-iwasawa |
6817df |
Qt::BottomRightCorner,
|
|
shun-iwasawa |
6817df |
Qt::BottomLeftCorner};
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
for (int inout = 0; inout < 2; inout++) {
|
|
shun-iwasawa |
6817df |
concepts[inout].m_type = TParamUIConcept::QUAD;
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
for (int c = 0; c < 4; c++) {
|
|
shun-iwasawa |
6817df |
Qt::Corner corner = loopIds[c];
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
// quad ui
|
|
shun-iwasawa |
6817df |
concepts[inout].m_params.push_back(m_points[inout][(int)corner]);
|
|
shun-iwasawa |
6817df |
concepts[inout].m_label = (inout == 0) ? " In" : " Out";
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
// vector ui
|
|
shun-iwasawa |
6817df |
if (inout == 0)
|
|
shun-iwasawa |
6817df |
concepts[vectorUiIdOffset + (int)corner].m_type =
|
|
shun-iwasawa |
6817df |
TParamUIConcept::VECTOR;
|
|
shun-iwasawa |
6817df |
concepts[vectorUiIdOffset + (int)corner].m_params.push_back(
|
|
shun-iwasawa |
6817df |
m_points[inout][(int)corner]);
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
//------------------------------------------------------------
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
FX_PLUGIN_IDENTIFIER(Iwa_CorridorGradientFx, "iwa_CorridorGradientFx");
|