Author: Carlos Lopez <[email protected]>
Date: Sun Jan 15 19:58:27 2012 +0100
Add width grow parameter to Advanced Outline and allow Context to pass it to
that type of layer.
---
.../src/modules/mod_geometry/advanced_outline.cpp | 34 +++++++++++++++-----
.../src/modules/mod_geometry/advanced_outline.h | 21 +++++++-----
synfig-core/src/modules/mod_geometry/outline.cpp | 2 +-
synfig-core/src/synfig/context.cpp | 7 +++-
4 files changed, 44 insertions(+), 20 deletions(-)
diff --git a/synfig-core/src/modules/mod_geometry/advanced_outline.cpp
b/synfig-core/src/modules/mod_geometry/advanced_outline.cpp
index 45c1ebf..fccb713 100644
--- a/synfig-core/src/modules/mod_geometry/advanced_outline.cpp
+++ b/synfig-core/src/modules/mod_geometry/advanced_outline.cpp
@@ -47,6 +47,7 @@
#include <synfig/valuenode_wplist.h>
#include <synfig/valuenode_dilist.h>
#include <synfig/valuenode_composite.h>
+#include <synfig/valuenode_const.h>
#endif
@@ -84,6 +85,7 @@ Advanced_Outline::Advanced_Outline()
dash_enabled_=false;
old_version=false;
fast_=false;
+ width_grow_=0.0f;
clear();
vector<BLinePoint> bline_point_list;
@@ -163,6 +165,7 @@ Advanced_Outline::sync()
int dstart_tip(WidthPoint::TYPE_FLAT),
dend_tip(WidthPoint::TYPE_FLAT);
const bool blineloop(bline_.get_loop());
const bool wplistloop(wplist_.get_loop());
+ const Real multiplier(exp(width_grow_.get(Real())));
int bline_size(bline.size());
int wplist_size(wplist.size());
// biter: first blinepoint of the current bezier
@@ -724,7 +727,7 @@ Advanced_Outline::sync()
p=hipos;
wnext->set_width(widthpoint_interpolate(i, n, p, smoothness_));
}
- add_tip(side_a, side_b, curve(q), unitary,
*wnext);
+ add_tip(side_a, side_b, curve(q), unitary,
*wnext, multiplier);
// Update wplist iterators
witer=wnext;
switer=swnext;
@@ -760,7 +763,7 @@ Advanced_Outline::sync()
Real p(ipos);
if(!fast_)
p=hipos;
- add_cusp(side_a,
side_b, bnext->get_vertex(), first_tangent, deriv(1.0-CUSP_TANGENT_ADJUST),
expand_+width_*0.5*widthpoint_interpolate(i, n, p, smoothness_));
+ add_cusp(side_a,
side_b, bnext->get_vertex(), first_tangent, deriv(1.0-CUSP_TANGENT_ADJUST),
multiplier*(expand_+width_*0.5*widthpoint_interpolate(i, n, p, smoothness_)));
}
}
// ... and get out of the main loop.
@@ -866,7 +869,7 @@ Advanced_Outline::sync()
Real p(ipos);
if(!fast_)
p=hipos;
- add_cusp(side_a, side_b,
biter->get_vertex(), deriv(CUSP_TANGENT_ADJUST), last_tangent,
expand_+width_*0.5*widthpoint_interpolate(i, n, p, smoothness_));
+ add_cusp(side_a, side_b,
biter->get_vertex(), deriv(CUSP_TANGENT_ADJUST), last_tangent,
multiplier*(expand_+width_*0.5*widthpoint_interpolate(i, n, p, smoothness_)));
}
middle_corner=false;
// This avoid to calculate derivative on q=0
@@ -915,7 +918,7 @@ Advanced_Outline::sync()
}
ww=wnext->get_width();
}
- const Real w(expand_+width_*0.5*ww);
+ const Real
w(multiplier*(expand_+width_*0.5*ww));
side_a.push_back(p+d*w);
side_b.push_back(p-d*w);
// if we haven't passed the position of
the second blinepoint
@@ -945,7 +948,7 @@ Advanced_Outline::sync()
Real po(ipos);
if(!fast_)
po=hipos;
- const Real
w(expand_+width_*0.5*widthpoint_interpolate(i, n, po, smoothness_));
+ const Real
w(multiplier*(expand_+width_*0.5*widthpoint_interpolate(i, n, po,
smoothness_)));
side_a.push_back(p+d*w);
side_b.push_back(p-d*w);
// Update iterators
@@ -1002,7 +1005,7 @@ Advanced_Outline::sync()
done_tip=false;
}
else
-
w=(expand_+width_*0.5*widthpoint_interpolate(i, n, po, smoothness_));
+
w=(multiplier*(expand_+width_*0.5*widthpoint_interpolate(i, n, po,
smoothness_)));
side_a.push_back(p+d*w);
side_b.push_back(p-d*w);
ipos = ipos + step;
@@ -1043,6 +1046,13 @@ Advanced_Outline::set_param(const String & param, const
ValueBase &value)
IMPORT_AS(homogeneous_,"homogeneous");
IMPORT_AS(dash_enabled_, "dash_enabled");
IMPORT_AS(fast_, "fast");
+ if(param=="width_grow" && value.get_type() == ValueBase::TYPE_REAL)
+ {
+ connect_dynamic_param("width_grow",
ValueNode_Const::create(value));
+ width_grow_=value;
+ return true;
+ }
+
if(param=="smoothness" && value.get_type()==ValueBase::TYPE_REAL)
{
if(value > 1.0) smoothness_=1.0;
@@ -1104,6 +1114,8 @@ Advanced_Outline::get_param(const String& param)const
EXPORT_AS(homogeneous_, "homogeneous");
EXPORT_AS(dash_enabled_,"dash_enabled");
EXPORT_AS(fast_, "fast");
+ EXPORT_AS(width_grow_, "width_grow");
+
EXPORT_NAME();
EXPORT_VERSION();
if(param=="vector_list")
@@ -1193,6 +1205,12 @@ Advanced_Outline::get_param_vocab()const
.set_hint("dash")
.set_description(_("Distance to Offset the Dash Items"))
);
+ ret.push_back(ParamDesc("width_grow")
+ .set_local_name(_("Width Grow"))
+ .set_description(_("Increases width value logaritmically"))
+ .not_critical()
+ .hidden()
+ );
return ret;
}
@@ -1288,9 +1306,9 @@ Advanced_Outline::bezier_to_bline(Real bezier_pos, Real
origin, Real bezier_size
}
void
-Advanced_Outline::add_tip(std::vector<Point> &side_a, std::vector<Point>
&side_b, const Point vertex, const Vector tangent, const WidthPoint wp)
+Advanced_Outline::add_tip(std::vector<Point> &side_a, std::vector<Point>
&side_b, const Point vertex, const Vector tangent, const WidthPoint wp, Real m)
{
- Real w(expand_+width_*0.5*wp.get_width());
+ Real w(m*(expand_+width_*0.5*wp.get_width()));
// Side Before
switch (wp.get_side_type_before())
{
diff --git a/synfig-core/src/modules/mod_geometry/advanced_outline.h
b/synfig-core/src/modules/mod_geometry/advanced_outline.h
index 4f1139d..2ae05c0 100644
--- a/synfig-core/src/modules/mod_geometry/advanced_outline.h
+++ b/synfig-core/src/modules/mod_geometry/advanced_outline.h
@@ -48,22 +48,25 @@ class Advanced_Outline : public synfig::Layer_Polygon
{
SYNFIG_LAYER_MODULE_EXT
private:
-
+ // Parameters
synfig::ValueBase bline_;
- synfig::ValueBase wplist_;
- synfig::ValueBase dilist_;
+ synfig::Real width_;
+ synfig::Real expand_;
WidthPoint::SideType start_tip_;
WidthPoint::SideType end_tip_;
int cusp_type_;
- bool loop_;
- synfig::Real width_;
- synfig::Real expand_;
Real smoothness_;
bool homogeneous_;
- Real dash_offset_;
+ synfig::ValueBase wplist_;
+ bool fast_;
bool dash_enabled_;
+ synfig::ValueBase dilist_;
+ Real dash_offset_;
+ synfig::ValueBase width_grow_; // hidden, not critical
+ //
+ bool loop_;
bool old_version;
- bool fast_;
+
public:
enum CuspType
@@ -91,7 +94,7 @@ private:
bool connect_bline_to_dilist(etl::loose_handle<ValueNode> x);
Real bline_to_bezier(Real bline_pos, Real origin, Real bezier_size);
Real bezier_to_bline(Real bezier_pos, Real origin, Real bezier_size);
- void add_tip(std::vector<Point> &side_a, std::vector<Point> &side_b,
const Point vertex, const Vector tangent, const WidthPoint wp);
+ void add_tip(std::vector<Point> &side_a, std::vector<Point> &side_b,
const Point vertex, const Vector tangent, const WidthPoint wp, Real m=1.0);
void add_cusp(std::vector<Point> &side_a, std::vector<Point> &side_b,
const Point vertex, const Vector curr, const Vector last, Real width);
};
diff --git a/synfig-core/src/modules/mod_geometry/outline.cpp
b/synfig-core/src/modules/mod_geometry/outline.cpp
index da79b19..9503383 100644
--- a/synfig-core/src/modules/mod_geometry/outline.cpp
+++ b/synfig-core/src/modules/mod_geometry/outline.cpp
@@ -172,7 +172,7 @@ Outline::sync()
try {
#if 1
const bool loop(bline.get_loop());
- const Real multiplier=exp(width_grow);
+ const Real multiplier(exp(width_grow.get(Real())));
ValueNode_BLine::Handle bline_valuenode;
if (bline.get_contained_type() == ValueBase::TYPE_SEGMENT)
{
diff --git a/synfig-core/src/synfig/context.cpp
b/synfig-core/src/synfig/context.cpp
index d77013e..f0f8c16 100644
--- a/synfig-core/src/synfig/context.cpp
+++ b/synfig-core/src/synfig/context.cpp
@@ -373,12 +373,15 @@ Context::set_outline_grow(Real grow)
if((*context)->active())
{
// it's a outline layer,
- if((*context)->get_name() == "outline")
+ if((*context)->get_name() == "outline"
+ ||
+ (*context)->get_name() == "advanced_outline"
+ )
{
// Set up a writer lock
RWLock::WriterLock
lock((*context)->get_rw_lock());
if(!(*context)->set_param("width_grow", grow))
-
synfig::error("Context::set_outline_grow(): outline didn't accept param
width_grow");
+
synfig::error("Context::set_outline_grow(): %s didn't accept param width_grow",
(*context)->get_name().c_str());
}
}
++context;
------------------------------------------------------------------------------
RSA(R) Conference 2012
Mar 27 - Feb 2
Save $400 by Jan. 27
Register now!
http://p.sf.net/sfu/rsa-sfdev2dev2
_______________________________________________
Synfig-devl mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synfig-devl