# Making a Square Animation [closed]

Can I use mathematica to show an animation of

1. A 2x2 square
2. ..with its lower left quadrant colored
3. ..then with all of the square colored ?
• What have you tried so far? Have you looked at ListAnimate, at Rectangle, etc? Where are you stuck? – Carl Lange Aug 2 '19 at 17:21

There are many ways to do this in Mathematica. Here's one example:

ListAnimate[{
ArrayPlot[{{0, 0}, {0, 0}}],
ArrayPlot[{{0, 0}, {1, 0}}],
ArrayPlot[{{1, 1}, {1, 1}}]
}]


Here is another way:

frames = Table[
Graphics[{EdgeForm[Thick], White, Rectangle[{0, 0}, {2, 2}], Black,
Rectangle[{0, 0}, p]}],
{p, {{0, 0}, {1, 1}, {2, 2}}}];

ListAnimate[frames]


n = 5;
array = ConstantArray[0, {n, n}];

frames = Table[ArrayPlot[MapAt[Red &, array, {;; k, ;; k}],
DataReversed -> True, Mesh -> All], {k, Range[0, n]}];

Export["arrayplot.gif", frames, "DisplayDurations" -> 1];


ListAnimate[frames]


Alternatively, using Rectangles as in MelaGo's answer:

frames = Table[Graphics[{Red, Rectangle[{0, 0}, {k, k}]},
Frame -> True,
FrameTicks -> False, PlotRange -> {{0, n}, {0, n}},
GridLines -> Automatic,
Method -> {"GridLinesInFront" -> True}], {k, 0, n}];

ListAnimate @ frames


same picture