Author: Carlos Lopez <genet...@gmail.com>
Date:   Mon Apr  8 22:20:37 2013 +0200

New member get_cairo_color for NoiseDistort

---

 synfig-core/src/modules/mod_noise/distort.cpp |   86 ++++++++++++++++---------
 synfig-core/src/modules/mod_noise/distort.h   |    3 +
 2 files changed, 58 insertions(+), 31 deletions(-)

diff --git a/synfig-core/src/modules/mod_noise/distort.cpp 
b/synfig-core/src/modules/mod_noise/distort.cpp
index a2642fe..2dfbde1 100644
--- a/synfig-core/src/modules/mod_noise/distort.cpp
+++ b/synfig-core/src/modules/mod_noise/distort.cpp
@@ -77,53 +77,65 @@ NoiseDistort::NoiseDistort():
        Layer::fill_static(voc);
 }
 
-inline Color
-NoiseDistort::color_func(const Point &point, float /*supersample*/,Context 
context)const
+inline Point
+NoiseDistort::point_func(const Point &point)const
 {
-       Color ret(0,0,0,0);
-
        float x(point[0]/size[0]*(1<<detail));
        float y(point[1]/size[1]*(1<<detail));
-
+       
        int i;
        Time time;
        time=speed*curr_time;
        RandomNoise::SmoothType temp_smooth(smooth);
        RandomNoise::SmoothType smooth((!speed && temp_smooth == 
RandomNoise::SMOOTH_SPLINE) ? RandomNoise::SMOOTH_FAST_SPLINE : temp_smooth);
-
+       
+       Vector vect(0,0);
+       for(i=0;i<detail;i++)
        {
-               Vector vect(0,0);
-               for(i=0;i<detail;i++)
+               vect[0]=random(smooth,0+(detail-i)*5,x,y,time)+vect[0]*0.5;
+               vect[1]=random(smooth,1+(detail-i)*5,x,y,time)+vect[1]*0.5;
+               
+               if(vect[0]<-1)vect[0]=-1;if(vect[0]>1)vect[0]=1;
+               if(vect[1]<-1)vect[1]=-1;if(vect[1]>1)vect[1]=1;
+               
+               if(turbulent)
                {
-                       
vect[0]=random(smooth,0+(detail-i)*5,x,y,time)+vect[0]*0.5;
-                       
vect[1]=random(smooth,1+(detail-i)*5,x,y,time)+vect[1]*0.5;
-
-                       if(vect[0]<-1)vect[0]=-1;if(vect[0]>1)vect[0]=1;
-                       if(vect[1]<-1)vect[1]=-1;if(vect[1]>1)vect[1]=1;
-
-                       if(turbulent)
-                       {
-                               vect[0]=abs(vect[0]);
-                               vect[1]=abs(vect[1]);
-                       }
-
-                       x/=2.0f;
-                       y/=2.0f;
+                       vect[0]=abs(vect[0]);
+                       vect[1]=abs(vect[1]);
                }
+               
+               x/=2.0f;
+               y/=2.0f;
+       }
+       
+       if(!turbulent)
+       {
+               vect[0]=vect[0]/2.0f+0.5f;
+               vect[1]=vect[1]/2.0f+0.5f;
+       }
+       vect[0]=(vect[0]-0.5f)*displacement[0];
+       vect[1]=(vect[1]-0.5f)*displacement[1];
+       
+       return point+vect;
+}
 
-               if(!turbulent)
-               {
-                       vect[0]=vect[0]/2.0f+0.5f;
-                       vect[1]=vect[1]/2.0f+0.5f;
-               }
-               vect[0]=(vect[0]-0.5f)*displacement[0];
-               vect[1]=(vect[1]-0.5f)*displacement[1];
+inline Color
+NoiseDistort::color_func(const Point &point, float /*supersample*/,Context 
context)const
+{
+       Color ret(0,0,0,0);
+       ret=context.get_color(point_func(point));
+       return ret;
+}
 
-               ret=context.get_color(point+vect);
-       }
+inline CairoColor
+NoiseDistort::cairocolor_func(const Point &point, float 
/*supersample*/,Context context)const
+{
+       CairoColor ret(0,0,0,0);
+       ret=context.get_cairocolor(point_func(point));
        return ret;
 }
 
+
 inline float
 NoiseDistort::calc_supersample(const synfig::Point &/*x*/, float /*pw*/,float 
/*ph*/)const
 {
@@ -251,6 +263,17 @@ NoiseDistort::get_color(Context context, const Point 
&point)const
                return 
Color::blend(color,context.get_color(point),get_amount(),get_blend_method());
 }
 
+CairoColor
+NoiseDistort::get_cairocolor(Context context, const Point &point)const
+{
+       const CairoColor color(cairocolor_func(point,0,context));
+       
+       if(get_amount()==1.0 && get_blend_method()==Color::BLEND_STRAIGHT)
+               return color;
+       else
+               return 
CairoColor::blend(color,context.get_cairocolor(point),get_amount(),get_blend_method());
+}
+
 Rect
 NoiseDistort::get_bounding_rect(Context context)const
 {
@@ -265,6 +288,7 @@ NoiseDistort::get_bounding_rect(Context context)const
        return bounds;
 }
 
+
 /*
 bool
 NoiseDistort::accelerated_render(Context context,Surface *surface,int quality, 
const RendDesc &renddesc, ProgressCallback *cb)const
diff --git a/synfig-core/src/modules/mod_noise/distort.h 
b/synfig-core/src/modules/mod_noise/distort.h
index cecb157..62e9d7f 100644
--- a/synfig-core/src/modules/mod_noise/distort.h
+++ b/synfig-core/src/modules/mod_noise/distort.h
@@ -60,6 +60,8 @@ private:
        mutable synfig::Time curr_time;
 
        synfig::Color color_func(const synfig::Point &x, float 
supersample,synfig::Context context)const;
+       synfig::CairoColor cairocolor_func(const synfig::Point &x, float 
supersample,synfig::Context context)const;
+       synfig::Point point_func(const synfig::Point &point)const;
 
        float calc_supersample(const synfig::Point &x, float pw,float ph)const;
 
@@ -69,6 +71,7 @@ public:
        virtual bool set_param(const synfig::String &param, const 
synfig::ValueBase &value);
        virtual synfig::ValueBase get_param(const synfig::String &param)const;
        virtual synfig::Color get_color(synfig::Context context, const 
synfig::Point &pos)const;
+       virtual synfig::CairoColor get_cairocolor(synfig::Context context, 
const synfig::Point &pos)const;
        //virtual bool accelerated_render(synfig::Context 
context,synfig::Surface *surface,int quality, const synfig::RendDesc &renddesc, 
synfig::ProgressCallback *cb)const;
        synfig::Layer::Handle hit_check(synfig::Context context, const 
synfig::Point &point)const;
        virtual void set_time(synfig::Context context, synfig::Time time)const;


------------------------------------------------------------------------------
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
Synfig-devl@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synfig-devl

Reply via email to