Author: Carlos Lopez <[email protected]>
Date: Fri Nov 23 19:23:59 2012 +0100
Cairo Operators: Add support for blend mode ADD using a custom blend function.
---
synfig-core/src/synfig/cairo_operators.cpp | 2 +-
synfig-core/src/synfig/color.cpp | 30 ++++++++++++++++++++++++++++
2 files changed, 31 insertions(+), 1 deletions(-)
diff --git a/synfig-core/src/synfig/cairo_operators.cpp
b/synfig-core/src/synfig/cairo_operators.cpp
index 9247835..a0594dd 100644
--- a/synfig-core/src/synfig/cairo_operators.cpp
+++ b/synfig-core/src/synfig/cairo_operators.cpp
@@ -231,6 +231,7 @@ void cairo_paint_with_alpha_operator(cairo_t* acr, float
alpha, Color::BlendMeth
break;
}
+ case Color::BLEND_ADD:
case Color::BLEND_DIVIDE:
{
cairo_push_group(cr);
@@ -273,7 +274,6 @@ void cairo_paint_with_alpha_operator(cairo_t* acr, float
alpha, Color::BlendMeth
cairo_pattern_destroy(pattern);
break;
}
- case Color::BLEND_ADD:
case Color::BLEND_SUBTRACT:
case Color::BLEND_DIFFERENCE:
case Color::BLEND_COLOR:
diff --git a/synfig-core/src/synfig/color.cpp b/synfig-core/src/synfig/color.cpp
index 95d538e..2b39448 100644
--- a/synfig-core/src/synfig/color.cpp
+++ b/synfig-core/src/synfig/color.cpp
@@ -378,6 +378,36 @@ blendfunc_ADD(C &a,C &b,float amount)
return b;
}
+//Specialization for CairoColor
+template <>
+static CairoColor
+blendfunc_ADD(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_SUBTRACT(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