Author: Carlos Lopez <[email protected]>
Date: Fri Nov 23 19:34:15 2012 +0100
Cairo Operators: Add support for blend mode SUBTRACT using a custom blend
function.
---
synfig-core/src/synfig/cairo_operators.cpp | 2 +-
synfig-core/src/synfig/color.cpp | 30 +++++++++++++++++++++++++++-
2 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/synfig-core/src/synfig/cairo_operators.cpp
b/synfig-core/src/synfig/cairo_operators.cpp
index a0594dd..21a4c06 100644
--- a/synfig-core/src/synfig/cairo_operators.cpp
+++ b/synfig-core/src/synfig/cairo_operators.cpp
@@ -232,6 +232,7 @@ void cairo_paint_with_alpha_operator(cairo_t* acr, float
alpha, Color::BlendMeth
}
case Color::BLEND_ADD:
+ case Color::BLEND_SUBTRACT:
case Color::BLEND_DIVIDE:
{
cairo_push_group(cr);
@@ -274,7 +275,6 @@ void cairo_paint_with_alpha_operator(cairo_t* acr, float
alpha, Color::BlendMeth
cairo_pattern_destroy(pattern);
break;
}
- case Color::BLEND_SUBTRACT:
case Color::BLEND_DIFFERENCE:
case Color::BLEND_COLOR:
case Color::BLEND_ALPHA_BRIGHTEN:
diff --git a/synfig-core/src/synfig/color.cpp b/synfig-core/src/synfig/color.cpp
index 2b39448..3f2e808 100644
--- a/synfig-core/src/synfig/color.cpp
+++ b/synfig-core/src/synfig/color.cpp
@@ -407,7 +407,6 @@ blendfunc_ADD(CairoColor &a, CairoColor &b, float amount)
return CairoColor(rc, gc, bc, ac);
}
-
template <class C>
static C
blendfunc_SUBTRACT(C &a,C &b,float amount)
@@ -421,6 +420,35 @@ blendfunc_SUBTRACT(C &a,C &b,float amount)
return b;
}
+//Specialization for CairoColor
+template <>
+static CairoColor
+blendfunc_SUBTRACT(CairoColor &a, CairoColor &b, float amount)
+{
+ int ra, ga, ba, aa;
+ int rb, gb, bb, ab;
+ int rc, gc, bc, ac;
+
+ ra=a.get_r();
+ ga=a.get_g();
+ ba=a.get_b();
+ aa=a.get_a();
+
+ rb=b.get_r();
+ gb=b.get_g();
+ bb=b.get_b();
+ ab=b.get_a();
+
+ int aba=ab*amount;
+
+ rc=rb-(ra*aba)/255;
+ gc=gb-(ga*aba)/255;
+ bc=bb-(ba*aba)/255;
+ ac=ab;
+
+ return CairoColor(rc, gc, bc, ac);
+}
+
template <class C>
static C
blendfunc_DIFFERENCE(C &a,C &b,float amount)
------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
Synfig-devl mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synfig-devl