How can I better mimic the graphics at earth.nullschool.net?
I think you might be better off creating Graphics
directly instead of using the StreamPlot style options. In this example I use StreamPlot
just once and extract the coordinates of the arrows, which I use to create Line
objects with VertexColors
. The animation is made by cycling the vertex colors.
plot = StreamPlot[{-1 - x^2 + y, 1 + x - y^2}, {x, -3, 3}, {y, -3, 3}];
splines = Cases[plot, Arrow[data_] :> BSplineFunction[data], -1];
r = Range[0, 1, 0.05];
cols = Opacity[#, White] & /@ r;
lines[i_] := Map[Line[# /@ r, VertexColors -> RotateRight[cols, i]] &, splines]
frames = Table[
Graphics[{Thickness[0.005], CapForm["Round"], lines[i]}, Background -> Lighter@Blue],
{i, Length@r}];
Export["test.gif", frames]
I would like provide an alternative answer using the method of Simon Woods to extract the contour lines. However, in contrast to his approach I prefer to have them as long as possible. This is achieved by the StreamScale -> Full
option.
nlines = 30;
flist = {-1 - x^2 + y, 1 + x - y^2};
xmn = -3;
xmx = 3;
ymn = -3;
ymx = 3;
subint = 3;
plot = StreamPlot[flist, {x, xmn, xmx}, {y, ymn, ymx},
StreamScale -> Full, StreamPoints -> nlines];
p2 = DensityPlot[Norm[flist], {x, xmn, xmx}, {y, ymn, ymx},
ColorFunction -> "DeepSeaColors"];
splines = Cases[plot, Arrow[data_] :> BSplineFunction[data], -1];
len = Length[splines];
t0 = RandomReal[{0, 1}, len];
frames = Table[
Show[p2, {Table[
ParametricPlot[splines[[i]][t], {t, 0, 1},
ColorFunction ->
Function[{x, y, u},
Blend[{Opacity[0.0, Black], Opacity[0.0, Black],
Opacity[0.1, Red], Lighter[Cyan], White},
Mod[subint (u - k) + t0[[i]], 1]]], Axes -> False], {i,
len}]}], {k, 0, 1, 0.01}];
Another example
nlines = 20;
flist = {y, -y + x - x^3};
xmn = -2;
xmx = 2;
ymn = -2;
ymx = 2;
subint = 5;
Thus, distinct features of my approach are:
Use of
StreamScale -> Full
;Background through
DensityPlot
;Randomization of initial times
t0 = RandomReal[{0, 1}, len];
Lines' colours blending, here the number of choices is really limited by your phantasy only.
But what are the differences compared to the original animation? Much larger number of contours in the OP is the major distinction. I guess, MA approach would be only feasible for small maps, for larger ones a compilation might be needed.