Continuing toward my goal pf getting a calligraphic signature pane pursuant to this answer (https://mathematica.stackexchange.com/a/13376/43662). I have produced the code below. The user writes using the mouse with the button held down. Subsequent presses produce new lines. Color and pen shape and angle are chosen.
Update
I am trying to combine with BSplineFunction in order to smoothen the angles and make the curves flow more evenly. It is better but can be improved.
The code for the angular panel:
mouseHandler := Block[{},
(pos = MousePosition["Graphics"];
btn = CurrentValue[{"MouseButtonTest", 1}];
If[btn, (
If[pos =!= None, AppendTo[posList[maxLine], pos]];
posList[maxLine] = DeleteDuplicates@posList[maxLine];),
(*else increment line counter and max line counter*)
If[Length@posList[maxLine] > 3,
maxLine++]];
If[maxLine == 100, Break];
)]
calligraphicLine[pts_List, baseThickness_, maxThickness_,
direction_] := ({Thickness[(Abs@
Sin[Mod[ArcTan @@ Subtract @@ # + direction, 2 Pi]])*
maxThickness + baseThickness], Line[#]} & /@
Partition[pts, 2, 1])
Table[posList[i] = {}, {i, 100}];
posList[1] = Table[{-10 - i, -i}, {i, 4}]; maxLine = 1;
colr = RGBColor[0., 0.5, 0.9];
thinX = .001; thickX = .015; angle = 5.48;
Column[{Row@{
ColorSlider[Dynamic[colr]],
Column[{"\tNib Thin Dimension\t" Slider[
Dynamic[thinX], {0.0001, .01}],
"\tNib Thick dimenson\t" Slider[Dynamic[thickX], {.01, .025}],
"\tNib Angle\t\t\t" Slider[Dynamic[angle], {0, 2 Pi}]}]
},
Dynamic[Graphics[{colr, Dynamic@Table[
calligraphicLine[posList[i], thinX, thickX, angle]
, {i, maxLine}],
Black
,(*Dynamic@*)Table[
Point[posList[i]]
, {i, maxLine}]
}, Frame -> False, FrameTicks -> False,
AspectRatio -> Automatic,
ImageSize -> Large, PlotRange -> {{-3, 3}, {-2, 2}}]]
}]
Dynamic[mouseHandler]
To get the smoother lines, I follow it with
Show@Table[
ParametricPlot[BSplineFunction[posList[i], SplineDegree -> 5][t]
, {t, 0, 1}, PlotPoints -> 4 60, PlotRange -> {{-3, 3}, {-2, 2}},
PlotStyle -> colr, Axes -> False] /.
Line[pts_] :> calligraphicLine[pts, thinX, thickX, angle]
, {i, 2, maxLine - 1}]
For example, panel one and two might be, panel one:
and panel two:
The ends have blotches and the curves, while better, are not realistic.


