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/dyna-draw-context.cpp | |
| 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/dyna-draw-context.cpp')
| -rw-r--r-- | src/dyna-draw-context.cpp | 17 |
1 files changed, 17 insertions, 0 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); |
