diff options
| author | MenTaLguY <mental@rydia.net> | 2006-09-04 03:37:42 +0000 |
|---|---|---|
| committer | mental <mental@users.sourceforge.net> | 2006-09-04 03:37:42 +0000 |
| commit | 8281ae00d124ba9ee36c864d8f1a8413f35becee (patch) | |
| tree | 9dfa928a01b590138476643c7d4d2ceea17bcfd8 /src | |
| parent | reduce DYNA_EPSILON further, as artifacts still occur frequently with the sma... (diff) | |
| download | inkscape-8281ae00d124ba9ee36c864d8f1a8413f35becee.tar.gz inkscape-8281ae00d124ba9ee36c864d8f1a8413f35becee.zip | |
add support for rounded caps with the calligraphy tool
(bzr r1673)
Diffstat (limited to 'src')
| -rw-r--r-- | src/dyna-draw-context.cpp | 17 | ||||
| -rw-r--r-- | src/dyna-draw-context.h | 1 | ||||
| -rw-r--r-- | src/preferences-skeleton.h | 2 |
3 files changed, 19 insertions, 1 deletions
diff --git a/src/dyna-draw-context.cpp b/src/dyna-draw-context.cpp index 3eb84570d..1dbb91785 100644 --- a/src/dyna-draw-context.cpp +++ b/src/dyna-draw-context.cpp @@ -162,6 +162,7 @@ sp_dyna_draw_context_init(SPDynaDrawContext *ddc) ddc->vel_thin = 0.1; ddc->flatness = 0.9; + ddc->cap_rounding = 0.0; ddc->abs_width = false; ddc->keep_selected = true; @@ -228,6 +229,7 @@ sp_dyna_draw_context_setup(SPEventContext *ec) sp_event_context_read(ec, "usetilt"); sp_event_context_read(ec, "abs_width"); sp_event_context_read(ec, "keep_selected"); + sp_event_context_read(ec, "cap_rounding"); ddc->is_drawing = false; @@ -268,6 +270,8 @@ sp_dyna_draw_context_set(SPEventContext *ec, gchar const *key, gchar const *val) ddc->abs_width = (val && strcmp(val, "0")); } else if (!strcmp(key, "keep_selected")) { ddc->keep_selected = (val && strcmp(val, "0")); + } else if (!strcmp(key, "cap_rounding")) { + ddc->cap_rounding = ( val ? g_ascii_strtod (val, NULL) : 0.0 ); } //g_print("DDC: %g %g %g %g\n", ddc->mass, ddc->drag, ddc->angle, ddc->width); @@ -690,13 +694,26 @@ set_to_accumulated(SPDynaDrawContext *dc) } static void +add_cap(SPCurve *curve, NR::Point const &from, NR::Point const &to, + double rounding) +{ + NR::Point vec = rounding * NR::rot90( ( to - from ) / sqrt(2.0) ); + + if ( NR::L2(vec) > DYNA_EPSILON ) { + sp_curve_curveto(curve, from + vec, to + vec, to); + } +} + +static void accumulate_calligraphic(SPDynaDrawContext *dc) { if ( !sp_curve_empty(dc->cal1) && !sp_curve_empty(dc->cal2) ) { sp_curve_reset(dc->accumulated); /* Is this required ?? */ SPCurve *rev_cal2 = sp_curve_reverse(dc->cal2); sp_curve_append(dc->accumulated, dc->cal1, FALSE); + add_cap(dc->accumulated, sp_curve_last_point(dc->cal1), sp_curve_first_point(rev_cal2), dc->cap_rounding); sp_curve_append(dc->accumulated, rev_cal2, TRUE); + add_cap(dc->accumulated, sp_curve_last_point(rev_cal2), sp_curve_first_point(dc->cal1), dc->cap_rounding); sp_curve_closepath(dc->accumulated); sp_curve_unref(rev_cal2); diff --git a/src/dyna-draw-context.h b/src/dyna-draw-context.h index 27d3291da..638767270 100644 --- a/src/dyna-draw-context.h +++ b/src/dyna-draw-context.h @@ -94,6 +94,7 @@ struct SPDynaDrawContext double vel_thin; double flatness; double tremor; + double cap_rounding; Inkscape::MessageContext *_message_context; diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h index 111fc6bf1..1992f07cf 100644 --- a/src/preferences-skeleton.h +++ b/src/preferences-skeleton.h @@ -63,7 +63,7 @@ static char const preferences_skeleton[] = " <eventcontext id=\"calligraphic\" style=\"fill:black;fill-opacity:1;fill-rule:nonzero;stroke:none;\"\n" " mass=\"0.02\" drag=\"1\" angle=\"30\" width=\"0.15\" thinning=\"0.1\" flatness=\"0.9\" usecurrent=\"1\"\n" " usepressure=\"0\" usetilt=\"0\" keep_selected=\"1\"/>\n" -" <eventcontext id=\"text\" usecurrent=\"0\" gradientdrag=\"1\"\n" +" <eventcontext id=\"text\" usecurrent=\"0\" gradientdrag=\"1\" cap_rounding=\"0.0\"\n" " font_sample=\"AaBbCcIiPpQq12369$\342\202\254\302\242?.;/()\"\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\" show_handles=\"1\" sculpting_profile=\"1\" />\n" |
