File: default.txt

package info (click to toggle)
highlight.js 10.7.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,332 kB
  • sloc: javascript: 41,059; makefile: 157; python: 29; sh: 20
file content (79 lines) | stat: -rw-r--r-- 2,276 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
(* Real-world example from StackExchange *)
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}]]

(* Features *)

(* The Wolfram Language supports a variety of different number input forms *)
(* All numbers below are correct numbers! *)

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
}

(* Named Characters are matched as normal symbols *)
{ \[Gamma],  \[CapitalEAcute], \[DoubleLeftRightArrow], \[FormalEpsilon], my\[CapitalEAcute]Variable }

(* Patterns and Slots *)
xkcdLabel[{str_String, {x1_Integer, y1_Real}, {_Real, _List}}]
If[# > 5, #, ## &[]] & /@ Range[10]

(* Usage and other messages, In/Out *)
In[1]:= func::usage = "A Usage message"
Out[1]= "A Usage message"