Module: synfig/synfig Branch: genete_width_outline Commit: f9d345d2b2609a6bc7af9d9d8c12607cef256902 URL: http://synfig.git.sourceforge.net/git/gitweb.cgi?p=synfig/synfig;a=commit;h=f9d345d2b2609a6bc7af9d9d8c12607cef256902
Author: Carlos Lopez <[email protected]> Date: Mon Jan 3 09:54:05 2011 +0100 Fix create_new_entry member function --- synfig-core/src/synfig/valuenode_wplist.cpp | 33 +++++++++++++++++--------- synfig-core/src/synfig/valuenode_wplist.h | 6 ++++- synfig-core/src/synfig/widthpoint.cpp | 12 +++++++++ synfig-core/src/synfig/widthpoint.h | 3 ++ 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/synfig-core/src/synfig/valuenode_wplist.cpp b/synfig-core/src/synfig/valuenode_wplist.cpp index e68f8a9..e2d165a 100644 --- a/synfig-core/src/synfig/valuenode_wplist.cpp +++ b/synfig-core/src/synfig/valuenode_wplist.cpp @@ -80,6 +80,9 @@ synfig::convert_bline_to_width_list(const ValueBase& bline) } // If the bline is not looped then make the cups type rounded for the // first and last width points. + // In the future when this function is used to convert old blines to + // new wlines the end and start cups should be readed from the oultline + // layer if(!bline.get_loop()) { iter=ret.back(); @@ -174,18 +177,24 @@ ValueNode_WPList::create_list_entry(int index, Time time, Real origin) next=(*list[next_i].value_node)(time); prev=(*list[prev_i].value_node)(time); - etl::hermite<Vector> curve(prev.get_vertex(),next.get_vertex(),prev.get_tangent2(),next.get_tangent1()); - etl::derivative< etl::hermite<Vector> > deriv(curve); - - synfig::WPListPoint WPList_point; - WPList_point.set_vertex(curve(origin)); - WPList_point.set_width((next.get_width()-prev.get_width())*origin+prev.get_width()); - WPList_point.set_tangent1(deriv(origin)*min(1.0-origin,origin)); - WPList_point.set_tangent2(WPList_point.get_tangent1()); - WPList_point.set_split_tangent_flag(false); - WPList_point.set_origin(origin); - - ret.value_node=ValueNode_Composite::create(WPList_point); + synfig::WidthPoint wpoint; + Real ppos(prev.get_position()); + Real npos(next.get_position()); + Real pos(ppos+(npos-ppos)*origin); + Real pwid(prev.get_width()); + Real nwid(next.get_width()); + Real wid(pwid+(nwid-pwid)*origin); + // Setup the position + wpoint.set_position(pos); + // Setup the width + // TODO: if in the future there are different interpolations between + // width points other than linear, use it here. + wpoint.set_width(wid); + // Setup the origin + wpoint.set_origin(origin); + // Note: before and after interpolations are INTERPOLATE by default. + // no need to set up here. + ret.value_node=ValueNode_Composite::create(wpoint); return ret; } diff --git a/synfig-core/src/synfig/valuenode_wplist.h b/synfig-core/src/synfig/valuenode_wplist.h index 646da08..c223f72 100644 --- a/synfig-core/src/synfig/valuenode_wplist.h +++ b/synfig-core/src/synfig/valuenode_wplist.h @@ -65,7 +65,11 @@ public: virtual String link_local_name(int i)const; virtual String get_name()const; virtual String get_local_name()const; - // Inserts a new entry at index with time and origin used for + //! Inserts a new entry at index with time and origin used for + //! \param index the index of the width point where to insert the new one before it + //! \param time the time when inserted when in animation mode + //! \param origin how much close is the inserted to the index (origin=1.0) or to the previous to index (origin=0.0) + //! \return the new List Entry virtual ListEntry create_list_entry(int index, Time time=0, Real origin=0.5); protected: diff --git a/synfig-core/src/synfig/widthpoint.cpp b/synfig-core/src/synfig/widthpoint.cpp index 7dd5370..249184c 100644 --- a/synfig-core/src/synfig/widthpoint.cpp +++ b/synfig-core/src/synfig/widthpoint.cpp @@ -67,6 +67,7 @@ WidthPoint::get_position()const { return position_; } + void WidthPoint::set_position(const Real& x) { @@ -115,3 +116,14 @@ WidthPoint::get_cup_type(int i) return i>0? cup_type_[1]: cup_type_[0]; } +const Real& +WidthPoint::get_origin()const +{ + return origin_; +} + +void +WidthPoint::set_origin(const Real& x) +{ + origin_=x; +} diff --git a/synfig-core/src/synfig/widthpoint.h b/synfig-core/src/synfig/widthpoint.h index edd0e3b..30313b0 100644 --- a/synfig-core/src/synfig/widthpoint.h +++ b/synfig-core/src/synfig/widthpoint.h @@ -45,6 +45,7 @@ private: Real position_; Real width_; int cup_type_[2]; // Before [0] and After[1] cup types + Real origin_; public: @@ -71,6 +72,8 @@ public: int get_cup_type_after(); void set_cup_after(int cupafter); int get_cup_type(int i); + void set_origin(const Real &origin); + const Real& get_origin()const; }; // END of class WidthPoint ------------------------------------------------------------------------------ Gaining the trust of online customers is vital for the success of any company that requires sensitive data to be transmitted over the Web. Learn how to best implement a security strategy that keeps consumers' information secure and instills the confidence they need to proceed with transactions. http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ Synfig-devl mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/synfig-devl
