summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 61c459d)
raw | patch | inline | side by side (parent: 61c459d)
author | buliabyak <buliabyak@users.sourceforge.net> | |
Thu, 18 May 2006 21:27:19 +0000 (21:27 +0000) | ||
committer | buliabyak <buliabyak@users.sourceforge.net> | |
Thu, 18 May 2006 21:27:19 +0000 (21:27 +0000) |
src/nodepath.cpp | patch | blob | history | |
src/nodepath.h | patch | blob | history | |
src/preferences-skeleton.h | patch | blob | history |
diff --git a/src/nodepath.cpp b/src/nodepath.cpp
index 2e5b24c62ca6f233c748dc48e524b7885d3f1ba1..46f1095ac8ea34ddcafc53f50c6585980d4ade21 100644 (file)
--- a/src/nodepath.cpp
+++ b/src/nodepath.cpp
@@ -998,14 +998,20 @@ curve; the parameter alpha determines how blunt (alpha > 1) or sharp (alpha < 1)
near x = 0.
*/
double
-sculpt_profile (double x, double alpha)
+sculpt_profile (double x, double alpha, guint profile)
{
if (x >= 1)
return 0;
- if (prefs_get_int_attribute("tools.nodes", "sculpt_profile_linear", 0) == 1) {
+ if (x <= 0)
+ return 1;
+
+ switch (profile) {
+ case SCULPT_PROFILE_LINEAR:
return 1 - x;
- } else {
+ case SCULPT_PROFILE_BELL:
return (0.5 * cos (M_PI * (pow(x, alpha))) + 0.5);
+ case SCULPT_PROFILE_ELLIPTIC:
+ return sqrt(1 - x*x);
}
}
@@ -1049,6 +1055,8 @@ sp_nodepath_selected_nodes_sculpt(Inkscape::NodePath::Path *nodepath, Inkscape::
if (pressure > 0.5)
alpha = 1/alpha;
+ guint profile = prefs_get_int_attribute("tools.nodes", "sculpting_profile", SCULPT_PROFILE_BELL);
+
if (sp_nodepath_selection_get_subpath_count(nodepath) <= 1) {
// Only one subpath has selected nodes:
// use linear mode, where the distance from n to node being dragged is calculated along the path
@@ -1117,9 +1125,9 @@ sp_nodepath_selected_nodes_sculpt(Inkscape::NodePath::Path *nodepath, Inkscape::
n_range += bezier_length (n_node->p.other->origin, n_node->p.other->n.origin, n_node->p.origin, n_node->origin);
if (n_node->selected) {
sp_nodepath_move_node_and_handles (n_node,
- sculpt_profile (n_range / n_sel_range, alpha) * delta,
- sculpt_profile ((n_range + NR::L2(n_node->n.origin - n_node->origin)) / n_sel_range, alpha) * delta,
- sculpt_profile ((n_range - NR::L2(n_node->p.origin - n_node->origin)) / n_sel_range, alpha) * delta);
+ sculpt_profile (n_range / n_sel_range, alpha, profile) * delta,
+ sculpt_profile ((n_range + NR::L2(n_node->n.origin - n_node->origin)) / n_sel_range, alpha, profile) * delta,
+ sculpt_profile ((n_range - NR::L2(n_node->p.origin - n_node->origin)) / n_sel_range, alpha, profile) * delta);
}
if (n_node == p_node) {
n_going = false;
@@ -1134,9 +1142,9 @@ sp_nodepath_selected_nodes_sculpt(Inkscape::NodePath::Path *nodepath, Inkscape::
p_range += bezier_length (p_node->n.other->origin, p_node->n.other->p.origin, p_node->n.origin, p_node->origin);
if (p_node->selected) {
sp_nodepath_move_node_and_handles (p_node,
- sculpt_profile (p_range / p_sel_range, alpha) * delta,
- sculpt_profile ((p_range - NR::L2(p_node->n.origin - p_node->origin)) / p_sel_range, alpha) * delta,
- sculpt_profile ((p_range + NR::L2(p_node->p.origin - p_node->origin)) / p_sel_range, alpha) * delta);
+ sculpt_profile (p_range / p_sel_range, alpha, profile) * delta,
+ sculpt_profile ((p_range - NR::L2(p_node->n.origin - p_node->origin)) / p_sel_range, alpha, profile) * delta,
+ sculpt_profile ((p_range + NR::L2(p_node->p.origin - p_node->origin)) / p_sel_range, alpha, profile) * delta);
}
if (p_node == n_node) {
n_going = false;
@@ -1172,9 +1180,9 @@ sp_nodepath_selected_nodes_sculpt(Inkscape::NodePath::Path *nodepath, Inkscape::
if (node->selected) {
if (direct_range > 1e-6) {
sp_nodepath_move_node_and_handles (node,
- sculpt_profile (NR::L2(node->origin - n->origin) / direct_range, alpha) * delta,
- sculpt_profile (NR::L2(node->n.origin - n->origin) / direct_range, alpha) * delta,
- sculpt_profile (NR::L2(node->p.origin - n->origin) / direct_range, alpha) * delta);
+ sculpt_profile (NR::L2(node->origin - n->origin) / direct_range, alpha, profile) * delta,
+ sculpt_profile (NR::L2(node->n.origin - n->origin) / direct_range, alpha, profile) * delta,
+ sculpt_profile (NR::L2(node->p.origin - n->origin) / direct_range, alpha, profile) * delta);
} else {
sp_nodepath_move_node_and_handles (node, delta, delta, delta);
}
diff --git a/src/nodepath.h b/src/nodepath.h
index 2b8243f5b612b693055428b87da84df62f65641e..10e241b6ad2546eeb684a8df259240a2df46770e 100644 (file)
--- a/src/nodepath.h
+++ b/src/nodepath.h
} // namespace NodePath
} // namespace Inkscape
+enum {
+ SCULPT_PROFILE_LINEAR,
+ SCULPT_PROFILE_BELL,
+ SCULPT_PROFILE_ELLIPTIC
+};
+
// Do function documentation in nodepath.cpp
Inkscape::NodePath::Path * sp_nodepath_new (SPDesktop * desktop, SPItem * item, bool show_handles);
void sp_nodepath_destroy (Inkscape::NodePath::Path * nodepath);
index d709173d85f2d3c6b50eaf387ddfafa52d053df9..830e0fa76983ec130d7d1741d29dbbc2b26f3192 100644 (file)
" usepressure=\"0\" usetilt=\"0\" keep_selected=\"1\"/>\n"
" <eventcontext id=\"text\" usecurrent=\"0\" gradientdrag=\"1\"\n"
" style=\"fill:black;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;font-style:normal;font-weight:normal;font-size:12px;\" selcue=\"1\"/>\n"
-" <eventcontext id=\"nodes\" selcue=\"1\" gradientdrag=\"1\"/>\n"
+" <eventcontext id=\"nodes\" selcue=\"1\" gradientdrag=\"1\" show_handles=\"1\" sculpting_profile=\"1\" />\n"
" <eventcontext id=\"gradient\" selcue=\"1\"/>\n"
" <eventcontext id=\"zoom\" selcue=\"1\" gradientdrag=\"0\"/>\n"
" <eventcontext id=\"dropper\" selcue=\"1\" gradientdrag=\"1\"/>\n"