xkcdStyle = {FontFamily -> "Comic Sans MS", 16};
xkcdLabel[{str_String, {x1_, y1_}, {xo_, yo_}}] := Module[{x2, y2},
x2 = x1 + xo; y2 = y1 + yo;
{
Inset[
Style[str, xkcdStyle],
{x2, y2},
{1.2*Sign[x1 - x2], Sign[y1 - y2] Boole[x1 == x2]}
],
Thick,
BezierCurve[{{0.9*x1 + 0.1*x2, 0.9*y1 + 0.1*y2}, {x1, y2}, {x2, y2}}]
}
];
xkcdRules = {
EdgeForm[ef : Except[None]] :> EdgeForm[Flatten@{ef, Thick, Black}],
Style[x_, st_] :> Style[x, xkcdStyle],
Pane[s_String] :> Pane[Style[s, xkcdStyle]],
{h_Hue, l_Line} :> {Thickness[0.02], White, l, Thick, h, l},
Grid[{{g_Graphics, s_String}}] :> Grid[{{g, Style[s, xkcdStyle]}}],
Rule[PlotLabel, lab_] :> Rule[PlotLabel, Style[lab, xkcdStyle]]
};
xkcdShow[plot_] := Show[plot, AxesStyle -> Thick, LabelStyle -> xkcdStyle] /. xkcdRules;
xkcdShow[Labeled[plot_, rest__]] := Labeled[
Show[plot, AxesStyle -> Thick, LabelStyle -> xkcdStyle], rest ] /. xkcdRules;
xkcdDistort[plot_] := Module[{r, ix, iy},
r = ImagePad[Rasterize@plot, 10, Padding -> White];
{ix, iy} = Table[
RandomImage[{-1, 1}, ImageDimensions@r] ~ ImageConvolve ~ GaussianMatrix[10],
{2}
];
ImagePad[
ImageTransformation[r, # + 15 {ImageValue[ix, #], ImageValue[iy, #]} &, DataRange -> Full],
-5
]
];
xkcdConvert[plot_] := xkcdDistort[xkcdShow[plot]];
xkcdConvert[Plot[Sin[x], {x, 0, 4 Pi}]]
numbers = {
123,
123.123,
2^^101.101,
35^^WolframLanguage,
16^^dead.Beef,
123`,
1.381`,
16^^9fe.c3`7,
3.0`+7,
3`7,
3.000000000000000000000`7,
3.000000000000000000`-7,
3.98`5*^3,
16^^dead.beef``+4*^-3,
0.0000000001*^10,
35^^small*^-10,
10000000000*^-10
}
{ \[Gamma], \[CapitalEAcute], \[DoubleLeftRightArrow], \[FormalEpsilon], my\[CapitalEAcute]Variable }
xkcdLabel[{str_String, {x1_Integer, y1_Real}, {_Real, _List}}]
If[# > 5, #, ## &[]] & /@ Range[10]
In[1]:= func::usage = "A Usage message"
Out[1]= "A Usage message"