Author: Carlos Lopez <[email protected]>
Date:   Mon Apr  8 21:02:56 2013 +0200

CairoColor: add specialization for Blend mode COMPOSITE

---

 synfig-core/src/synfig/color.cpp |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/synfig-core/src/synfig/color.cpp b/synfig-core/src/synfig/color.cpp
index 6f4d9c2..68b3f33 100644
--- a/synfig-core/src/synfig/color.cpp
+++ b/synfig-core/src/synfig/color.cpp
@@ -282,6 +282,37 @@ blendfunc_COMPOSITE(C &src,C &dest,float amount)
        return dest;
 }
 
+//Specialization for CairoColor
+template <>
+CairoColor
+blendfunc_COMPOSITE(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()*amount;
+       
+       rb=b.get_r();
+       gb=b.get_g();
+       bb=b.get_b();
+       ab=b.get_a();
+       
+       ac=aa+(ab*(255-aa))/255;
+       if(ac==0) return CairoColor::alpha();
+       
+       rc=(ra*aa+rb*ab*(255-aa)/255)/255;
+       gc=(ga*aa+gb*ab*(255-aa)/255)/255;
+       bc=(ba*aa+bb*ab*(255-aa)/255)/255;
+       
+       return CairoColor(rc, gc, bc, ac);
+
+}
+
+
 template <class C>
 static C
 blendfunc_STRAIGHT(C &src,C &bg,float amount)


------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Synfig-devl mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synfig-devl

Reply via email to