Episode 5
One Coat of Paint Too Many
Duck attempts to go to his mark on the stage, but the giant star is in the way.






















Episode transcript
A digital backdrop
Duck is standing on the white space of the aqua monitor. Robot is outside the monitor with his painting controls.
Duck: My stage needs a backdrop!
Robot is pointing at the top of the history stack.
HISTORY: EMPTY. CANVAS: BLANK
Robot: No painting actions so far
Robot sets blue for the color of the digital canvas.
BOTTOM [BLUE] TOP
Duck: Blue for the sky.
Robot draws a stripe over blue. There's a STRIPE action card on top of BLUE in the history stack.
BOTTOM [BLUE, STRIPE] TOP
Robot: A stripe
The star takes the stage
BOTTOM [BLUE, STRIPE, STAR] TOP
Duck attempts to go to his mark on the stage, but the giant star is in the way.
Duck: This is where I'm supposed to be.
Robot points at the bottom (the oldest) BLUE action in the history stack.
BLUE is oldest. STAR is newest. NO UNDO YET
Robot stops trying to grab BLUE.
Undo the top action
STAR is on top of STRIPE, STRIPE is on top of BLUE. The star is visible on the canvas.
The canvas is now blue again with the stripe. Duck is standing on the newly-exposed stage mark.
UNDO STAR → BOTTOM [BLUE, STRIPE] TOP
Duck: The star is gone! I've got space again!
History stack contains two cards, the top one is STRIPE, and the bottom one is BLUE. Robot points to the new top card.
Robot: STRIPE is top now.
Duck points at stripe on the canvas. Robot walks towards undo button. The canvas stays the same for now.
Duck: one more undo please.
Back through the history
BOTTOM [BLUE, STRIPE] TOP. NO UNDO YET
So all you see on the digital canvas is the blue background. The only history card there is BLUE.
UNDO STRIPE → [BLUE]
Duck: Just blue.
Duck looks at the blue canvas (plain).
Robot: The last action is BLUE
Canvas is now empty.
UNDO BLUE → EMPTY
Duck: We are back where we started.
A clear stage
HISTORY: EMPTY. CANVAS: BLANK
Robot: Stack is empty.
No action in stack means editor doesn't do anything more.
Duck: So there's nothing left to undo
NEW ACTIONS: BLUE → STRIPE. BOTTOM [BLUE, STRIPE] TOP
Robot: Blue and stripe. We won't put a star.
Duck does an extreme bow against the clear stage mark in the completed blue and stripe background. Robot claps from off monitor.
Duck: That's a big enough stage for my awesome bow!
Last in, first out (LIFO)
A stack allows things to be put on and taken off the top. To put something on top, use push. To take off the most recently added thing, use pop. This is called last in, first out (LIFO).
Even after undoing the star, the blue and stripe actions before that still exist. Each time you undo, it steps backwards through the actions taken.
In this story, we have a stack of reversible things you can do with digital painting. The most recently added action is what gets removed when you do an undo. There are several possible ways that real editors might keep track of their undo stuff.
Try a new history
DRAW CIRCLE → DRAW SQUARE → DRAW TRIANGLE → UNDO TRIANGLE → DRAW HEART
Answer
The heart is the most recently recorded action. So undoing removes the heart.
REMAINING: CIRCLE, SQUARE. UNDO SQUARE → CIRCLE. UNDO CIRCLE → EMPTY
Stop when the stack is empty.
Sources
Paul E. Black, “stack”, NIST Dictionary of Algorithms and Data Structures (opens in a new tab)