Commit c08e24e2 authored by Dmitry Kazakov's avatar Dmitry Kazakov Committed by Eliakin Costa
Browse files

FEATURE: New "Hard Overlay" blending mode

Blending mode and a hotkey it "Shift+Alt+P"
Mostly explained here: https://phabricator.kde.org/T6037

Many thanks for Radian Art for implementing and testing it!

Reviewers: #krita, dkazakov, rempt
Reviewed By: #krita, dkazakov
Subscribers: timotheegiet, kamathraghavendra, #krita

Differential Revision: https://phabricator.kde.org/D5903
parent 96886aaa
......@@ -1763,6 +1763,18 @@
<isCheckable>false</isCheckable>
<statusTip></statusTip>
</Action>
<Action name="Select Hard Overlay Blending Mode">
<icon></icon>
<text>Select Hard Overlay Blending Mode</text>
<whatsThis></whatsThis>
<toolTip>Select Hard Overlay Blending Mode</toolTip>
<iconText>Select Hard Overlay Blending Mode</iconText>
<activationFlags>0</activationFlags>
<activationConditions>0</activationConditions>
<shortcut>Alt+Shift+P</shortcut>
<isCheckable>false</isCheckable>
<statusTip></statusTip>
</Action>
<Action name="Select Soft Light Blending Mode">
<icon></icon>
<text>Select Soft Light Blending Mode</text>
......
......@@ -90,6 +90,7 @@ KoCompositeOpRegistry::KoCompositeOpRegistry()
m_map.insert(m_categories[4], KoID(COMPOSITE_GEOMETRIC_MEAN , i18n("Geometric Mean")));
m_map.insert(m_categories[4], KoID(COMPOSITE_DESTINATION_ATOP, i18n("Destination Atop")));
m_map.insert(m_categories[4], KoID(COMPOSITE_DESTINATION_IN , i18n("Destination In")));
m_map.insert(m_categories[4], KoID(COMPOSITE_HARD_OVERLAY , i18n("Hard Overlay")));
m_map.insert(m_categories[5], KoID(COMPOSITE_BUMPMAP , i18n("Bumpmap")));
m_map.insert(m_categories[5], KoID(COMPOSITE_COMBINE_NORMAL, i18n("Combine Normal Map")));
......
......@@ -63,7 +63,8 @@ const QString COMPOSITE_EXCLUSION = "exclusion";
const QString COMPOSITE_HARD_MIX = "hard mix";
const QString COMPOSITE_OVERLAY = "overlay";
const QString COMPOSITE_BEHIND = "behind";
const QString COMPOSITE_GREATER = "greater";
const QString COMPOSITE_GREATER = "greater";
const QString COMPOSITE_HARD_OVERLAY = "hard overlay";
const QString COMPOSITE_DARKEN = "darken";
const QString COMPOSITE_BURN = "burn";//this is also known as 'color burn'.
......
......@@ -416,6 +416,19 @@ inline T cfOverlay(T src, T dst) { return cfHardLight(dst, src); }
template<class T>
inline T cfMultiply(T src, T dst) { return Arithmetic::mul(src, dst); }
template<class T>
inline T cfHardOverlay(T src, T dst) {
using namespace Arithmetic;
qreal fsrc = scale<qreal>(src);
qreal fdst = scale<qreal>(dst);
if(fsrc > 0.5f) {
return scale<T>(cfDivide(inv(2.0 * fsrc - 1.0f), fdst));
}
return scale<T>(mul(2.0 * fsrc, fdst));
}
template<class T>
inline T cfDifference(T src, T dst) { return qMax(src,dst) - qMin(src,dst); }
......
......@@ -122,6 +122,7 @@ struct AddGeneralOps<Traits, true>
add<&cfGeometricMean<Arg> >(cs, COMPOSITE_GEOMETRIC_MEAN, i18n("Geometric Mean"), KoCompositeOp::categoryMix());
add<&cfParallel<Arg> >(cs, COMPOSITE_PARALLEL , i18n("Parallel") , KoCompositeOp::categoryMix());
add<&cfAllanon<Arg> >(cs, COMPOSITE_ALLANON , i18n("Allanon") , KoCompositeOp::categoryMix());
add<&cfHardOverlay<Arg> >(cs, COMPOSITE_HARD_OVERLAY , i18n("Hard Overlay") , KoCompositeOp::categoryMix());
add<&cfScreen<Arg> >(cs, COMPOSITE_SCREEN , i18n("Screen") , KoCompositeOp::categoryLight());
add<&cfColorDodge<Arg> >(cs, COMPOSITE_DODGE , i18n("Color Dodge") , KoCompositeOp::categoryLight());
......
......@@ -182,6 +182,13 @@ KisCompositeOpComboBox::KisCompositeOpComboBox(QWidget* parent):
connect(action, SIGNAL(triggered()), SLOT(slotOverlay()));
m_actions << action;
// Hard Overlay
// Shift + Alt + P
action = new KisAction(i18n("Select Hard Overlay Blending Mode"), this);
action->setDefaultShortcut(QKeySequence(Qt::SHIFT + Qt::ALT + Qt::Key_P));
connect(action, SIGNAL(triggered()), SLOT(slotHardOverlay()));
m_actions << action;
// Soft Light
// Shift + Alt + F
action = new KisAction(i18n("Select Soft Light Blending Mode"), this);
......@@ -408,6 +415,11 @@ void KisCompositeOpComboBox::slotOverlay()
selectCompositeOp(KoCompositeOpRegistry::instance().getKoID(COMPOSITE_OVERLAY));
}
void KisCompositeOpComboBox::slotHardOverlay()
{
selectCompositeOp(KoCompositeOpRegistry::instance().getKoID(COMPOSITE_HARD_OVERLAY));
}
void KisCompositeOpComboBox::slotSoftLight()
{
selectCompositeOp(KoCompositeOpRegistry::instance().getKoID(COMPOSITE_SOFT_LIGHT_PHOTOSHOP));
......
......@@ -78,6 +78,7 @@ private Q_SLOTS:
void slotColorDodge();
void slotLinearDodge();
void slotOverlay();
void slotHardOverlay();
void slotSoftLight();
void slotHardLight();
void slotVividLight();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment