diff --git a/stuff/config/current.txt b/stuff/config/current.txt
index 19e32cf..a6cd128 100644
--- a/stuff/config/current.txt
+++ b/stuff/config/current.txt
@@ -240,6 +240,7 @@
- "STD_linearGradientFx.wave_phase" "Phase"
- "STD_linearGradientFx.color1" "Color 1"
- "STD_linearGradientFx.color2" "Color 2"
+ - "STD_linearGradientFx.curveType" "Type"
- "STD_linearWaveFx" "Linear Wave"
- "STD_linearWaveFx.period" "Period"
@@ -267,6 +268,7 @@
- "STD_multiLinearGradientFx.wave_frequency" "Frequency"
- "STD_multiLinearGradientFx.wave_phase" "Phase"
- "STD_multiLinearGradientFx.colors" "Colors"
+ - "STD_multiLinearGradientFx.curveType" "Type"
- "STD_localBlurFx" "Local Blur"
- "STD_localBlurFx.value" "Intensity"
@@ -324,6 +326,7 @@
- "STD_radialGradientFx.innerperiod" "Inner Size"
- "STD_radialGradientFx.color1" "Color 1"
- "STD_radialGradientFx.color2" "Color 2"
+ - "STD_radialGradientFx.curveType" "Type"
- "STD_randomWaveFx" "Random Wave"
@@ -358,6 +361,7 @@
- "STD_multiRadialGradientFx.count" "Quantity"
- "STD_multiRadialGradientFx.cycle" "Cycle"
- "STD_multiRadialGradientFx.colors" "Colors"
+ - "STD_multiRadialGradientFx.curveType" "Type"
- "STD_raylitFx" "Raylit"
- "STD_raylitFx.p" "Center X"
diff --git a/stuff/profiles/layouts/fxs/STD_linearGradientFx.xml b/stuff/profiles/layouts/fxs/STD_linearGradientFx.xml
index 7eeebcb..de531e5 100644
--- a/stuff/profiles/layouts/fxs/STD_linearGradientFx.xml
+++ b/stuff/profiles/layouts/fxs/STD_linearGradientFx.xml
@@ -4,6 +4,7 @@
color1
color2
color1 color2
+ curveType
wave_amplitude
wave_frequency
diff --git a/stuff/profiles/layouts/fxs/STD_multiLinearGradientFx.xml b/stuff/profiles/layouts/fxs/STD_multiLinearGradientFx.xml
index 988baef..8084dfc 100644
--- a/stuff/profiles/layouts/fxs/STD_multiLinearGradientFx.xml
+++ b/stuff/profiles/layouts/fxs/STD_multiLinearGradientFx.xml
@@ -4,6 +4,7 @@
count
cycle
colors
+ curveType
wave_amplitude
wave_frequency
diff --git a/stuff/profiles/layouts/fxs/STD_multiRadialGradientFx.xml b/stuff/profiles/layouts/fxs/STD_multiRadialGradientFx.xml
index 738463a..8966e16 100644
--- a/stuff/profiles/layouts/fxs/STD_multiRadialGradientFx.xml
+++ b/stuff/profiles/layouts/fxs/STD_multiRadialGradientFx.xml
@@ -4,6 +4,7 @@
count
cycle
colors
+ curveType
diff --git a/stuff/profiles/layouts/fxs/STD_radialGradientFx.xml b/stuff/profiles/layouts/fxs/STD_radialGradientFx.xml
index 9a9a0d5..a5eb1d2 100644
--- a/stuff/profiles/layouts/fxs/STD_radialGradientFx.xml
+++ b/stuff/profiles/layouts/fxs/STD_radialGradientFx.xml
@@ -5,6 +5,7 @@
period
color2
color1 color2
+ curveType
diff --git a/toonz/sources/common/tsystem/tfilepath.cpp b/toonz/sources/common/tsystem/tfilepath.cpp
index 9c84c77..c7efeaf 100644
--- a/toonz/sources/common/tsystem/tfilepath.cpp
+++ b/toonz/sources/common/tsystem/tfilepath.cpp
@@ -687,12 +687,12 @@ TFrameId TFilePath::getFrame() const {
}
char letter = '\0';
if (iswalpha(str[k])) letter = str[k++] + ('a' - L'a');
-
- if (number == 0 || k < i) // || letter!='\0')
- throw TMalformedFrameException(
- *this,
- str + L": " + QObject::tr("Malformed frame name").toStdWString());
-
+ /*
+ if (number == 0 || k < i) // || letter!='\0')
+ throw TMalformedFrameException(
+ *this,
+ str + L": " + QObject::tr("Malformed frame name").toStdWString());
+ */
int padding = 0;
if (str[j + 1] == '0') padding = digits;
diff --git a/toonz/sources/include/tcg/boost/zipped_range.h b/toonz/sources/include/tcg/boost/zipped_range.h
deleted file mode 100644
index 1810f9d..0000000
--- a/toonz/sources/include/tcg/boost/zipped_range.h
+++ /dev/null
@@ -1,45 +0,0 @@
-#pragma once
-
-#ifndef ZIPPED_RANGE_H
-#define ZIPPED_RANGE_H
-
-// boost includes
-#include
-#include
-
-/*!
- \file zipped_range.h
-
- \brief Contains a range creator for boost::zip_iterator objects.
- \remark Zipped ranges are currently constrained to a 2-tuple.
-*/
-
-namespace tcg {
-
-template
-struct _zip_rng_traits {
- typedef boost::zip_iterator<
- boost::tuple::type,
- typename boost::range_iterator::type>>
- iterator;
- typedef std::pair range;
-};
-
-//**********************************************************************************
-// Permuted Range creator
-//**********************************************************************************
-
-template
-typename _zip_rng_traits::range zipped_range(Rng1 &rng1,
- Rng2 &rng2) {
- typedef typename _zip_rng_traits::range range;
- typedef typename _zip_rng_traits::iterator iterator;
-
- return range(
- iterator(boost::make_tuple(boost::begin(rng1), boost::begin(rng2))),
- iterator(boost::make_tuple(boost::end(rng1), boost::end(rng2))));
-}
-
-} // namespace tcg
-
-#endif // ZIPPED_RANGE_H
diff --git a/toonz/sources/include/tools/stylepicker.h b/toonz/sources/include/tools/stylepicker.h
index 54f7c64..b5381bb 100644
--- a/toonz/sources/include/tools/stylepicker.h
+++ b/toonz/sources/include/tools/stylepicker.h
@@ -60,11 +60,12 @@ public:
int pickStyleId(const TPointD &point, double radius2 = 1, int mode = 2) const;
/*--- Toonz Raster LevelのToneを拾う。 ---*/
- int pickTone(const TPointD &pos);
+ int pickTone(const TPointD &pos) const;
// per pli come sopra, ma ritorna il maincolor
// per tzp e fullcolor ritorna il colore effettivo del pixel
TPixel32 pickColor(const TPointD &point, double radius2 = 1) const;
+ TPixel32 pickAverageColor(const TRectD &rect) const;
// ritorna il colore medio presente nell'area della finestra corrente openGL
TPixel32 pickColor(const TRectD &area) const;
diff --git a/toonz/sources/include/toonzqt/functionsheet.h b/toonz/sources/include/toonzqt/functionsheet.h
index 2aa3756..acb2333 100644
--- a/toonz/sources/include/toonzqt/functionsheet.h
+++ b/toonz/sources/include/toonzqt/functionsheet.h
@@ -48,6 +48,8 @@ class FunctionSheetColumnHeadViewer final : public Spreadsheet::ColumnPanel {
QPoint m_dragStartPosition;
FunctionTreeModel::Channel *m_draggingChannel;
+ int m_clickedColumn = -1;
+
public:
FunctionSheetColumnHeadViewer(FunctionSheet *parent);
diff --git a/toonz/sources/stdfx/gradients.cpp b/toonz/sources/stdfx/gradients.cpp
index 6fea2e4..89d516a 100644
--- a/toonz/sources/stdfx/gradients.cpp
+++ b/toonz/sources/stdfx/gradients.cpp
@@ -13,7 +13,8 @@ namespace {
template
void doComputeRadialT(TRasterPT ras, TPointD posTrasf,
const TSpectrumT &spectrum, double period,
- double count, double cycle, const TAffine &aff) {
+ double count, double cycle, const TAffine &aff,
+ double inner = 0.0, GradientCurveType type = Linear) {
int j;
double maxRadius = period * count;
double freq = 1.0 / period;
@@ -29,8 +30,30 @@ void doComputeRadialT(TRasterPT ras, TPointD posTrasf,
t = (radius + cycle) * freq;
t -= floor(t);
}
- // double polinomfactor=(-2*t+3)*(t*t);
- *pix++ = spectrum.getPremultipliedValue(t);
+
+ if (t <= inner)
+ t = 0;
+ else
+ t = (t - inner) / (1.0 - inner);
+
+ double factor;
+ switch (type) {
+ case Linear:
+ factor = t;
+ break;
+ case EaseIn:
+ factor = t * t;
+ break;
+ case EaseOut:
+ factor = 1.0 - (1.0 - t) * (1.0 - t);
+ break;
+ case EaseInOut:
+ default:
+ factor = (-2 * t + 3) * (t * t);
+ break;
+ }
+ *pix++ = spectrum.getPremultipliedValue(factor);
+
posAux.x += aff.a11;
posAux.y += aff.a21;
}
@@ -39,19 +62,20 @@ void doComputeRadialT(TRasterPT ras, TPointD posTrasf,
}
ras->unlock();
}
-}
+} // namespace
//------------------------------------------------------------------
void multiRadial(const TRasterP &ras, TPointD posTrasf,
const TSpectrumParamP colors, double period, double count,
- double cycle, const TAffine &aff, double frame) {
+ double cycle, const TAffine &aff, double frame, double inner,
+ GradientCurveType type) {
if ((TRaster32P)ras)
doComputeRadialT(ras, posTrasf, colors->getValue(frame), period,
- count, cycle, aff);
+ count, cycle, aff, inner, type);
else if ((TRaster64P)ras)
doComputeRadialT(ras, posTrasf, colors->getValue64(frame), period,
- count, cycle, aff);
+ count, cycle, aff, inner, type);
else
throw TException("MultiRadialGradientFx: unsupported Pixel Type");
}
@@ -63,7 +87,8 @@ template
void doComputeLinearT(TRasterPT ras, TPointD posTrasf,
const TSpectrumT &spectrum, double period,
double count, double w_amplitude, double w_freq,
- double w_phase, double cycle, const TAffine &aff) {
+ double w_phase, double cycle, const TAffine &aff,
+ GradientCurveType type = EaseInOut) {
double shift = 0;
double maxRadius = period * count / 2.;
double freq = 1.0 / period;
@@ -78,16 +103,32 @@ void doComputeLinearT(TRasterPT ras, TPointD posTrasf,
T *endPix = pix + ras->getLx();
while (pix < endPix) {
if (w_amplitude) shift = w_amplitude * sin(w_freq * posAux.y + w_phase);
- double radius = posAux.x + shift;
- double t = 1;
+ double radius = posAux.x + shift;
+ double t = 1;
if (fabs(radius) < maxRadius) {
t = (radius + maxRadius + cycle) * freq;
t -= floor(t);
} else if (radius < 0)
- t = 0;
- double polinomfactor = (-2 * t + 3) * (t * t);
+ t = 0;
+
+ double factor;
+ switch (type) {
+ case Linear:
+ factor = t;
+ break;
+ case EaseIn:
+ factor = t * t;
+ break;
+ case EaseOut:
+ factor = 1.0 - (1.0 - t) * (1.0 - t);
+ break;
+ case EaseInOut:
+ default:
+ factor = (-2 * t + 3) * (t * t);
+ break;
+ }
// pos.x += 1.0;
- *pix++ = spectrum.getPremultipliedValue(polinomfactor);
+ *pix++ = spectrum.getPremultipliedValue(factor);
posAux.x += aff.a11;
posAux.y += aff.a21;
}
@@ -96,19 +137,19 @@ void doComputeLinearT(TRasterPT ras, TPointD posTrasf,
}
ras->unlock();
}
-}
+} // namespace
//------------------------------------------------------------------
void multiLinear(const TRasterP &ras, TPointD posTrasf,
const TSpectrumParamP colors, double period, double count,
double amplitude, double freq, double phase, double cycle,
- const TAffine &aff, double frame) {
+ const TAffine &aff, double frame, GradientCurveType type) {
if ((TRaster32P)ras)
doComputeLinearT(ras, posTrasf, colors->getValue(frame), period,
- count, amplitude, freq, phase, cycle, aff);
+ count, amplitude, freq, phase, cycle, aff, type);
else if ((TRaster64P)ras)
doComputeLinearT(ras, posTrasf, colors->getValue64(frame), period,
- count, amplitude, freq, phase, cycle, aff);
+ count, amplitude, freq, phase, cycle, aff, type);
else
throw TException("MultiLinearGradientFx: unsupported Pixel Type");
}
diff --git a/toonz/sources/stdfx/gradients.h b/toonz/sources/stdfx/gradients.h
index 411512d..2650374 100644
--- a/toonz/sources/stdfx/gradients.h
+++ b/toonz/sources/stdfx/gradients.h
@@ -15,17 +15,21 @@ struct MultiRAdialParams {
double m_gridStep;
};
+enum GradientCurveType { EaseInOut = 0, Linear, EaseIn, EaseOut };
+
/*---------------------------------------------------------------------------*/
//! Deals with raster tiles and invokes multiradial functions
void multiRadial(const TRasterP &ras, TPointD posTrasf,
const TSpectrumParamP colors, double period, double count,
- double cycle, const TAffine &aff, double frame);
+ double cycle, const TAffine &aff, double frame,
+ double inner = 0.0, GradientCurveType type = Linear);
void multiLinear(const TRasterP &ras, TPointD posTrasf,
const TSpectrumParamP colors, double period, double count,
double amplitude, double freq, double phase, double cycle,
- const TAffine &aff, double frame);
+ const TAffine &aff, double frame,
+ GradientCurveType type = EaseInOut);
#endif
diff --git a/toonz/sources/stdfx/iwa_bokehreffx.cpp b/toonz/sources/stdfx/iwa_bokehreffx.cpp
index b11ab27..e57c2c0 100644
--- a/toonz/sources/stdfx/iwa_bokehreffx.cpp
+++ b/toonz/sources/stdfx/iwa_bokehreffx.cpp
@@ -43,7 +43,7 @@ void releaseAllRastersAndPlans(QList& rasterList,
releaseAllRasters(rasterList);
for (int p = 0; p < planList.size(); p++) kiss_fft_free(planList.at(p));
}
-};
+}; // namespace
//------------------------------------
BokehRefThread::BokehRefThread(int channel, kiss_fft_cpx* fftcpx_channel_before,
@@ -608,7 +608,9 @@ void Iwa_BokehRefFx::retrieveLayer(const float4* source_buff,
TRasterGR8P generation_buff_ras = allocateRasterAndLock(
&generation_buff, TDimensionI(lx, ly));
- for (int gen = 0; gen < margin; gen++) {
+ // extend (margin * 2) pixels in order to enough cover when two adjacent
+ // layers are both blurred in the maximum radius
+ for (int gen = 0; gen < margin * 2; gen++) {
// apply single median filter
doSingleMedian(source_buff, segment_layer_buff, indexMap_mainSub, index, lx,
ly, generation_buff, gen + 1);
diff --git a/toonz/sources/stdfx/stdfx.cpp b/toonz/sources/stdfx/stdfx.cpp
index cd8499b..2f11f6c 100644
--- a/toonz/sources/stdfx/stdfx.cpp
+++ b/toonz/sources/stdfx/stdfx.cpp
@@ -174,6 +174,8 @@ class MultiLinearGradientFx final : public TStandardZeraryFx {
TDoubleParamP m_wave_phase;
TSpectrumParamP m_colors;
+ TIntEnumParamP m_curveType;
+
public:
MultiLinearGradientFx()
: m_period(100) // args, "Period")
@@ -182,8 +184,12 @@ public:
, m_wave_amplitude(0.0) // args, "Cycle")
, m_wave_freq(0.0) // args, "Cycle")
, m_wave_phase(0.0) // args, "Cycle")
- // , m_colors (0) //args, "Colors")
- {
+ // , m_colors (0) //args, "Colors")
+ , m_curveType(new TIntEnumParam(EaseInOut, "Ease In-Out")) {
+ m_curveType->addItem(Linear, "Linear");
+ m_curveType->addItem(EaseIn, "Ease In");
+ m_curveType->addItem(EaseOut, "Ease Out");
+
std::vector colors = {
TSpectrum::ColorKey(0, TPixel32::White),
TSpectrum::ColorKey(0.33, TPixel32::Yellow),
@@ -198,6 +204,8 @@ public:
bindParam(this, "wave_frequency", m_wave_freq);
bindParam(this, "wave_phase", m_wave_phase);
bindParam(this, "colors", m_colors);
+ bindParam(this, "curveType", m_curveType);
+
m_period->setValueRange(0, (std::numeric_limits::max)());
m_cycle->setValueRange(0, (std::numeric_limits::max)());
m_wave_amplitude->setValueRange(0, (std::numeric_limits::max)());
@@ -238,6 +246,8 @@ class LinearGradientFx final : public TStandardZeraryFx {
TPixelParamP m_color1;
TPixelParamP m_color2;
+ TIntEnumParamP m_curveType;
+
public:
LinearGradientFx()
: m_period(100) // args, "Period")
@@ -246,14 +256,20 @@ public:
, m_wave_phase(0.0) // args, "Cycle")
, m_color1(TPixel32::Black)
, m_color2(TPixel32::White)
- // , m_colors (0) //args, "Colors")
- {
+ // , m_colors (0) //args, "Colors")
+ , m_curveType(new TIntEnumParam(EaseInOut, "Ease In-Out")) {
+ m_curveType->addItem(Linear, "Linear");
+ m_curveType->addItem(EaseIn, "Ease In");
+ m_curveType->addItem(EaseOut, "Ease Out");
+
bindParam(this, "period", m_period);
bindParam(this, "wave_amplitude", m_wave_amplitude);
bindParam(this, "wave_frequency", m_wave_freq);
bindParam(this, "wave_phase", m_wave_phase);
bindParam(this, "color1", m_color1);
bindParam(this, "color2", m_color2);
+ bindParam(this, "curveType", m_curveType);
+
m_period->setValueRange(0, std::numeric_limits::max());
m_wave_amplitude->setValueRange(0, std::numeric_limits::max());
m_period->setMeasureName("fxLength");
@@ -346,7 +362,8 @@ void LinearGradientFx::doCompute(TTile &tile, double frame,
TAffine aff = ri.m_affine.inv();
TPointD posTrasf = aff * tile.m_pos;
multiLinear(tile.getRaster(), posTrasf, m_colors, period, count, w_amplitude,
- w_freq, w_phase, cycle, aff, frame);
+ w_freq, w_phase, cycle, aff, frame,
+ (GradientCurveType)m_curveType->getValue());
/*
if (TRaster32P ras32 = tile.getRaster())
doComputeT(
@@ -380,7 +397,8 @@ void MultiLinearGradientFx::doCompute(TTile &tile, double frame,
TAffine aff = ri.m_affine.inv();
TPointD posTrasf = aff * tile.m_pos;
multiLinear(tile.getRaster(), posTrasf, m_colors, period, count, w_amplitude,
- w_freq, w_phase, cycle, aff, frame);
+ w_freq, w_phase, cycle, aff, frame,
+ (GradientCurveType)m_curveType->getValue());
/*
if (TRaster32P ras32 = tile.getRaster())
doComputeT(
@@ -406,20 +424,30 @@ class RadialGradientFx final : public TStandardZeraryFx {
TPixelParamP m_color1;
TPixelParamP m_color2;
+ TIntEnumParamP m_curveType;
+
public:
RadialGradientFx()
: m_period(100.0)
, m_innerperiod(0.0) // args, "Period")
, m_color1(TPixel32::White)
, m_color2(TPixel32::Transparent)
- // , m_colors (0) //args, "Colors")
- {
+ // , m_colors (0) //args, "Colors")
+ , m_curveType(new TIntEnumParam()) {
+ m_curveType->addItem(EaseInOut, "Ease In-Out");
+ m_curveType->addItem(Linear, "Linear");
+ m_curveType->addItem(EaseIn, "Ease In");
+ m_curveType->addItem(EaseOut, "Ease Out");
+ m_curveType->setDefaultValue(Linear);
+ m_curveType->setValue(Linear);
+
m_period->setMeasureName("fxLength");
m_innerperiod->setMeasureName("fxLength");
bindParam(this, "period", m_period);
bindParam(this, "innerperiod", m_innerperiod);
bindParam(this, "color1", m_color1);
bindParam(this, "color2", m_color2);
+ bindParam(this, "curveType", m_curveType);
m_period->setValueRange(0.0, std::numeric_limits::max());
m_innerperiod->setValueRange(0.0, std::numeric_limits::max());
}
@@ -458,13 +486,22 @@ class MultiRadialGradientFx final : public TStandardZeraryFx {
TDoubleParamP m_cycle;
TSpectrumParamP m_colors;
+ TIntEnumParamP m_curveType;
+
public:
MultiRadialGradientFx()
: m_period(100) // args, "Period")
, m_count(2) // args, "Count")
, m_cycle(0.0) // args, "Count")
- // , m_colors (0) //args, "Colors")
- {
+ // , m_colors (0) //args, "Colors")
+ , m_curveType(new TIntEnumParam()) {
+ m_curveType->addItem(EaseInOut, "Ease In-Out");
+ m_curveType->addItem(Linear, "Linear");
+ m_curveType->addItem(EaseIn, "Ease In");
+ m_curveType->addItem(EaseOut, "Ease Out");
+ m_curveType->setDefaultValue(Linear);
+ m_curveType->setValue(Linear);
+
m_period->setMeasureName("fxLength");
std::vector colors = {
TSpectrum::ColorKey(0, TPixel32::White),
@@ -477,6 +514,7 @@ public:
bindParam(this, "count", m_count);
bindParam(this, "cycle", m_cycle);
bindParam(this, "colors", m_colors);
+ bindParam(this, "curveType", m_curveType);
m_period->setValueRange(0, (std::numeric_limits::max)());
m_cycle->setValueRange(0, (std::numeric_limits::max)());
m_count->setValueRange(0, (std::numeric_limits::max)());
@@ -517,7 +555,7 @@ void MultiRadialGradientFx::doCompute(TTile &tile, double frame,
TAffine aff = ri.m_affine.inv();
TPointD posTrasf = aff * tile.m_pos;
multiRadial(tile.getRaster(), posTrasf, m_colors, period, count, cycle, aff,
- frame);
+ frame, 0.0, (GradientCurveType)m_curveType->getValue());
}
//==================================================================
@@ -536,13 +574,12 @@ void RadialGradientFx::doCompute(TTile &tile, double frame,
inner = 1 - TConsts::epsilon;
std::vector colors = {
TSpectrum::ColorKey(0, m_color1->getValue(frame)),
- TSpectrum::ColorKey(inner, m_color1->getValue(frame)),
TSpectrum::ColorKey(1, m_color2->getValue(frame))};
TSpectrumParamP m_colors = TSpectrumParamP(colors);
TAffine aff = ri.m_affine.inv();
TPointD posTrasf = aff * tile.m_pos;
multiRadial(tile.getRaster(), posTrasf, m_colors, period, count, cycle, aff,
- frame);
+ frame, inner, (GradientCurveType)m_curveType->getValue());
}
//------------------------------------------------------------------
diff --git a/toonz/sources/tnztools/stylepicker.cpp b/toonz/sources/tnztools/stylepicker.cpp
index a236390..b6cc05a 100644
--- a/toonz/sources/tnztools/stylepicker.cpp
+++ b/toonz/sources/tnztools/stylepicker.cpp
@@ -12,6 +12,8 @@
#include "tpixelutils.h"
#include "tregion.h"
+#include
+
//---------------------------------------------------------
StylePicker::StylePicker(const TImageP &image)
@@ -74,7 +76,7 @@ int StylePicker::pickStyleId(const TPointD &pos, double radius2,
styleId = palette->getClosestStyle(col);
} else if (TVectorImageP vi = m_image) {
// prima cerca lo stile della regione piu' vicina
- TRegion *r = vi->getRegion(pos);
+ TRegion *r = vi->getRegion(pos);
if (r) styleId = r->getStyle();
// poi cerca quello della stroke, ma se prima aveva trovato una regione,
// richiede che
@@ -101,7 +103,7 @@ int StylePicker::pickStyleId(const TPointD &pos, double radius2,
//---------------------------------------------------------
/*--- Toonz Raster LevelのToneを拾う。 ---*/
-int StylePicker::pickTone(const TPointD &pos) {
+int StylePicker::pickTone(const TPointD &pos) const {
if (TToonzImageP ti = m_image) {
TRasterCM32P ras = ti->getRaster();
if (!ras) return -1;
@@ -119,6 +121,7 @@ int StylePicker::pickTone(const TPointD &pos) {
TPixel32 StylePicker::pickColor(const TPointD &pos, double radius2) const {
TToonzImageP ti = m_image;
TRasterImageP ri = m_image;
+ TVectorImageP vi = m_image;
if (!!ri) // !!ti || !!ri)
{
TRasterP raster;
@@ -135,12 +138,74 @@ TPixel32 StylePicker::pickColor(const TPointD &pos, double radius2) const {
TRasterGR8P rasterGR8 = raster;
if (rasterGR8) return toPixel32(rasterGR8->pixels(point.y)[point.x]);
- } else if (TVectorImageP vi = m_image) {
+ } else if (vi) {
const TPalette *palette = m_palette.getPointer();
if (!palette) return TPixel32::Transparent;
int styleId = pickStyleId(pos, radius2);
if (0 <= styleId && styleId < palette->getStyleCount())
return palette->getStyle(styleId)->getAverageColor();
+ } else if (ti) {
+ const TPalette *palette = m_palette.getPointer();
+ if (!palette) return TPixel32::Transparent;
+ int paintId = pickStyleId(pos, radius2, 0);
+ int inkId = pickStyleId(pos, radius2, 1);
+ int tone = pickTone(pos);
+ TPixel32 ink, paint;
+ if (0 <= inkId && inkId < palette->getStyleCount())
+ ink = palette->getStyle(inkId)->getAverageColor();
+ if (0 <= paintId && paintId < palette->getStyleCount())
+ paint = palette->getStyle(paintId)->getAverageColor();
+
+ if (tone == 0)
+ return ink;
+ else if (tone == 255)
+ return paint;
+ else
+ return blend(ink, paint, tone, TPixelCM32::getMaxTone());
+ }
+ return TPixel32::Transparent;
+}
+
+//---------------------------------------------------------
+
+TPixel32 StylePicker::pickAverageColor(const TRectD &rect) const {
+ TRasterImageP ri = m_image;
+ assert(ri);
+ if (!!ri) {
+ TRasterP raster;
+ raster = ri->getRaster();
+
+ TPoint topLeft = getRasterPoint(rect.getP00());
+ TPoint bottomRight = getRasterPoint(rect.getP11());
+
+ if (!raster->getBounds().overlaps(TRect(topLeft, bottomRight)))
+ return TPixel32::Transparent;
+
+ topLeft.x = std::max(0, topLeft.x);
+ topLeft.y = std::max(0, topLeft.y);
+ bottomRight.x = std::min(raster->getLx(), bottomRight.x);
+ bottomRight.y = std::min(raster->getLy(), bottomRight.y);
+
+ TRaster32P raster32 = raster;
+ assert(raster32);
+ if (raster32) {
+ UINT r = 0, g = 0, b = 0, m = 0, size = 0;
+ for (int y = topLeft.y; y < bottomRight.y; y++) {
+ TPixel32 *p = &raster32->pixels(y)[topLeft.x];
+ for (int x = topLeft.x; x < bottomRight.x; x++, p++) {
+ r += p->r;
+ g += p->g;
+ b += p->b;
+ m += p->m;
+ size++;
+ }
+ }
+
+ if (size)
+ return TPixel32(r / size, g / size, b / size, m / size);
+ else
+ return TPixel32::Transparent;
+ }
}
return TPixel32::Transparent;
}
@@ -236,7 +301,7 @@ TPixel32 getAverageColor(TStroke *stroke) {
return TPixel32(buffer[0].b, buffer[0].g, buffer[0].r, 255);
}
-} // namspace
+} // namespace
//---------------------------------------------------------
diff --git a/toonz/sources/tnztools/toolutils.cpp b/toonz/sources/tnztools/toolutils.cpp
index cd7832b..141845b 100644
--- a/toonz/sources/tnztools/toolutils.cpp
+++ b/toonz/sources/tnztools/toolutils.cpp
@@ -1526,8 +1526,8 @@ void ToolUtils::drawBalloon(const TPointD &pos, std::string text,
delta.x *= devPixRatio;
delta.y *= devPixRatio;
- textRect.moveTo(qMax(delta.x, 10 * devPixRatio + mrg),
- qMax(mrg + 2 * devPixRatio, -delta.y - baseLine));
+ textRect.moveTo(std::max(delta.x, 10 * devPixRatio + mrg),
+ std::max(mrg + 2 * devPixRatio, -delta.y - baseLine));
int y = textRect.top() + baseLine;
int x0 = textRect.left() - mrg;
@@ -1577,7 +1577,7 @@ void ToolUtils::drawBalloon(const TPointD &pos, std::string text,
}
QSize size(textRect.width() + textRect.left() + mrg,
- qMax(textRect.bottom() + mrg, y + delta.y) + 3 * devPixRatio);
+ std::max(textRect.bottom() + mrg, y + delta.y) + 3 * devPixRatio);
QImage label(size.width(), size.height(), QImage::Format_ARGB32);
label.fill(Qt::transparent);
diff --git a/toonz/sources/tnztools/toonzrasterbrushtool.cpp b/toonz/sources/tnztools/toonzrasterbrushtool.cpp
index ec896b9..c432f36 100644
--- a/toonz/sources/tnztools/toonzrasterbrushtool.cpp
+++ b/toonz/sources/tnztools/toonzrasterbrushtool.cpp
@@ -1017,17 +1017,21 @@ void ToonzRasterBrushTool::drawEmptyCircle(TPointD pos, int thick,
//-------------------------------------------------------------------------------------------------------
-TPointD ToonzRasterBrushTool::getCenteredCursorPos(const TPointD &originalCursorPos) {
- TDimension resolution = m_application->getCurrentLevel()->getSimpleLevel()->getProperties()->getImageRes();
+TPointD ToonzRasterBrushTool::getCenteredCursorPos(
+ const TPointD &originalCursorPos) {
+ if (m_isMyPaintStyleSelected) return originalCursorPos;
+ TXshLevelHandle *levelHandle = m_application->getCurrentLevel();
+ TXshSimpleLevel *level = levelHandle ? levelHandle->getSimpleLevel() : 0;
+ TDimension resolution =
+ level ? level->getProperties()->getImageRes() : TDimension(0, 0);
+
bool xEven = (resolution.lx % 2 == 0);
bool yEven = (resolution.ly % 2 == 0);
TPointD centeredCursorPos = originalCursorPos;
- if (xEven)
- centeredCursorPos.x -= 0.5;
- if (yEven)
- centeredCursorPos.y -= 0.5;
+ if (xEven) centeredCursorPos.x -= 0.5;
+ if (yEven) centeredCursorPos.y -= 0.5;
return centeredCursorPos;
}
@@ -1295,7 +1299,8 @@ void ToonzRasterBrushTool::leftButtonDown(const TPointD &pos,
TPointD thickOffset(m_maxCursorThick * 0.5, m_maxCursorThick * 0.5);
invalidateRect = convert(m_strokeSegmentRect) - rasCenter;
- invalidateRect += TRectD(centeredPos - thickOffset, centeredPos + thickOffset);
+ invalidateRect +=
+ TRectD(centeredPos - thickOffset, centeredPos + thickOffset);
invalidateRect +=
TRectD(m_brushPos - thickOffset, m_brushPos + thickOffset);
} else if (m_hardness.getValue() == 100 || m_pencil.getValue()) {
@@ -1303,7 +1308,8 @@ void ToonzRasterBrushTool::leftButtonDown(const TPointD &pos,
* --*/
if (!m_pencil.getValue()) thickness -= 1.0;
- TThickPoint thickPoint(centeredPos + convert(ras->getCenter()), thickness);
+ TThickPoint thickPoint(centeredPos + convert(ras->getCenter()),
+ thickness);
m_rasterTrack = new RasterStrokeGenerator(
ras, BRUSH, NONE, m_styleId, thickPoint, drawOrder != OverAll, 0,
!m_pencil.getValue(), drawOrder == PaletteOrder);
@@ -1395,7 +1401,8 @@ void ToonzRasterBrushTool::leftButtonDrag(const TPointD &pos,
TPointD thickOffset(m_maxCursorThick * 0.5, m_maxCursorThick * 0.5);
invalidateRect = convert(m_strokeSegmentRect) - rasCenter;
- invalidateRect += TRectD(centeredPos - thickOffset, centeredPos + thickOffset);
+ invalidateRect +=
+ TRectD(centeredPos - thickOffset, centeredPos + thickOffset);
invalidateRect +=
TRectD(m_brushPos - thickOffset, m_brushPos + thickOffset);
} else if (m_rasterTrack &&
diff --git a/toonz/sources/tnztools/toonzrasterbrushtool.h b/toonz/sources/tnztools/toonzrasterbrushtool.h
index 9b58297..c524ad6 100644
--- a/toonz/sources/tnztools/toonzrasterbrushtool.h
+++ b/toonz/sources/tnztools/toonzrasterbrushtool.h
@@ -227,7 +227,7 @@ protected:
static void drawEmptyCircle(TPointD point, int thick, bool isLxEven,
bool isLyEven, bool isPencil);
- static TPointD getCenteredCursorPos(const TPointD &originalCursorPos);
+ TPointD getCenteredCursorPos(const TPointD &originalCursorPos);
};
//------------------------------------------------------------
diff --git a/toonz/sources/toonz/colormodelviewer.cpp b/toonz/sources/toonz/colormodelviewer.cpp
index 5323e93..39deb09 100644
--- a/toonz/sources/toonz/colormodelviewer.cpp
+++ b/toonz/sources/toonz/colormodelviewer.cpp
@@ -198,7 +198,7 @@ void ColorModelViewer::loadImage(const TFilePath &fp) {
//-----------------------------------------------------------------------------
/*! Create and open the Right-click menu color model viewer.
-*/
+ */
void ColorModelViewer::contextMenuEvent(QContextMenuEvent *event) {
/*-- Levelが取得できない場合はMenuを出さない --*/
TApp *app = TApp::instance();
@@ -258,21 +258,21 @@ void ColorModelViewer::contextMenuEvent(QContextMenuEvent *event) {
//-----------------------------------------------------------------------------
/*! If left button is pressed recall \b pick() in event pos.
-*/
+ */
void ColorModelViewer::mousePressEvent(QMouseEvent *event) {
if (event->button() == Qt::LeftButton) pick(event->pos() * getDevPixRatio());
}
//-----------------------------------------------------------------------------
/*! If left button is moved recall \b pick() in event pos.
-*/
+ */
void ColorModelViewer::mouseMoveEvent(QMouseEvent *event) {
if (event->buttons() & Qt::LeftButton) pick(event->pos() * getDevPixRatio());
}
//-----------------------------------------------------------------------------
/*! Pick color from image and set it as current style.
-*/
+ */
void ColorModelViewer::pick(const QPoint &p) {
TImageP img = m_imageViewer->getImage();
if (!img) return;
@@ -296,7 +296,7 @@ void ColorModelViewer::pick(const QPoint &p) {
カレントToolに合わせてPickモードを変更
0=Area, 1=Line, 2=Line&Areas(default)
---*/
- int styleIndex = picker.pickStyleId(pos, 1, m_mode);
+ int styleIndex = picker.pickStyleId(pos + TPointD(-0.5, -0.5), 1, m_mode);
if (styleIndex < 0) return;
@@ -366,7 +366,7 @@ void ColorModelViewer::showEvent(QShowEvent *e) {
ToolHandle *toolHandle = TApp::instance()->getCurrentTool();
bool ret = connect(paletteHandle, SIGNAL(paletteSwitched()), this,
SLOT(showCurrentImage()));
- ret = ret && connect(paletteHandle, SIGNAL(paletteChanged()), this,
+ ret = ret && connect(paletteHandle, SIGNAL(paletteChanged()), this,
SLOT(showCurrentImage()));
ret = ret && connect(paletteHandle, SIGNAL(colorStyleChanged(bool)), this,
SLOT(showCurrentImage()));
@@ -487,7 +487,7 @@ void ColorModelViewer::showCurrentImage() {
//-----------------------------------------------------------------------------
/*! Clone current image and set it in viewer.
-*/
+ */
void ColorModelViewer::loadCurrentFrame() {
TApp *app = TApp::instance();
TXshLevel *xl = app->getCurrentLevel()->getLevel();
@@ -535,8 +535,8 @@ void ColorModelViewer::loadCurrentFrame() {
m_flipConsole->enableProgressBar(false);
m_flipConsole->setProgressBarStatus(0);
m_flipConsole->setFrameRange(1, 1, 1);
- m_title1 = m_viewerTitle + " :: " +
- m_currentRefImgPath.withoutParentDir().withFrame(fid);
+ m_title1 = m_viewerTitle +
+ " :: " + m_currentRefImgPath.withoutParentDir().withFrame(fid);
m_title = " ::