Author: Carlos Lopez <[email protected]>
Date: Wed Apr 17 07:05:04 2013 +0200
Fix blend method DIVIDE for CairoColor.
---
synfig-core/src/synfig/color.cpp | 28 ++++++++++++----------------
1 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/synfig-core/src/synfig/color.cpp b/synfig-core/src/synfig/color.cpp
index 086901e..8e47c98 100644
--- a/synfig-core/src/synfig/color.cpp
+++ b/synfig-core/src/synfig/color.cpp
@@ -672,9 +672,6 @@ blendfunc_DIFFERENCE(CairoColor &a, CairoColor &b, float
amount)
return CairoColor(rc, gc, bc, ac);
}
-
-
-
template <class C>
static C
blendfunc_MULTIPLY(C &a,C &b,float amount)
@@ -748,28 +745,27 @@ blendfunc_DIVIDE(CairoColor &a, CairoColor &b, float
amount)
bb=b.get_b();
ab=b.get_a();
- float alpha=amount*aa/255.0;
- float ahpla=1.0-alpha;
+ const float alpha=amount*aa/255.0;
+ const float ahpla=1.0-alpha;
- if(ab==0)
- return CairoColor();
+ if(alpha<COLOR_EPSILON)
+ return b;
ac=ab;
-
if(ra==0)
- rc=255;
+ rc=rb;
else
- rc=(rb*alpha*aa)/ra + ahpla*rb;
-
+ rc=rb*(alpha*255)/(ra) + ahpla*rb;
+
if(ga==0)
- gc=255;
+ gc=gb;
else
- gc=(gb*alpha*aa)/ga + ahpla*gb;
-
+ gc=gb*(alpha*255)/(ga) + ahpla*gb;
+
if(ba==0)
- bc=255;
+ bc=bb;
else
- bc=(bb*alpha*aa)/ba + ahpla*bb;
+ bc=bb*(alpha*255)/(ba) + ahpla*bb;
return CairoColor(rc, gc, bc, ac);
}
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Synfig-devl mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synfig-devl