Mouse motion heat map is an great way to study spatial attention distribution, styles of movement, reaction, etc. I am trying to design a code that visualizes such heat map. The requirements: 1) It must be real fast and 2) it must run for long time - no memory overload, etc. Simply collecting data points from 'MousePosition' in a list would probably run into a memory and slow interpolating graphics problems (unless you guys can prove otherwise ;-) ). So I came up with the idea of collecting data in an 'ArrayPlot'. This is pretty fast:
Manipulate[
IC = If[MousePosition["Graphics"] == None, IC, "fake",
Chop@Mod[IC + splash[100, 20] @@
Floor[{100 - #2, #1} & @@ MousePosition["Graphics"]], 10^6]];
ArrayPlot[IC, PlotRange -> All, PlotRangePadding -> 0,
Frame -> False, ImageSize -> 400, ColorFunction -> "TemperatureMap"]
, FrameMargins -> 0, AppearanceElements -> None
, Initialization :> (
IC = SparseArray[{{1, 1} -> 0., 100 {1, 1} -> 0.}];
splash[n_, r_][x_, y_] :=
SparseArray[Flatten[Table[{1 + Mod[i, n], 1 + Mod[j, n]} ->
1. Exp[-((i - x)^2 + (j - y)^2)/(n/10.)], {i, x - r,
x + r}, {j, y - r, y + r}]~
Join~{{1, 1} -> 0., n {1, 1} -> 0.}, 1]])]
This is an insight into how handwriting proceeds through time, where the hand spends more time, which part are more difficult to draw:
And here some very basic type of further analysis or visualization:
Column[ListPlot[#, PlotRange -> All, PlotRangePadding -> 0,
Frame -> True, ImageSize -> 600, ColorFunction -> "DarkRainbow",
Joined -> True, PlotStyle -> Opacity[.3],
AspectRatio -> 1/5] & /@ {IC, Transpose@IC}, Spacings -> .05]
My questions are: is there more efficient and fast approach? what interesting Mathematica stats we could try? what cool apps we can make (games, writing, etc.)?
All approaches are welcome.