Message Boards Message Boards

[GIF] Moving bars illusion

enter image description here

These bars are moving at a constant speed together, but it looks as if they move to the right in an alternating fashionÂ…

Code:

size={sizex,sizey}={600,400};
n=16;
bars=sizex Subdivide[-1/2,1/2,2n-1];
width=N[bars[[2]]-bars[[1]]];
bars=Rectangle[{#1,-sizey/2},{#2,sizey/2}]&@@@Partition[bars,2];
cols={Lighter[Yellow,1/5],Darker[Blue,1/5]};
heights=N[sizey Subdivide[-1/2,1/2,Length[cols]+1][[2;;-2]]];
ClearAll[CreateScene]
CreateScene[\[Alpha]_]:=Module[{recs},
    recs=MapThread[{#1,Rectangle[{\[Alpha] sizex-2 width,#2-width/2},{\[Alpha] sizex+2 width,#2+width/2}]}&,{cols,heights}];
    Rasterize[Graphics[{bars,recs},PlotRange->({{-1,1},{-1,1}}size/2),PlotRangePadding->0],"Image",RasterSize->size,ImageSize->size]
]

Manipulate[CreateScene[a], {a, -0.6, 0.6}]

enjoy!

POSTED BY: Sander Huisman
6 Replies

It would seem to me that bw bars produce an effect similar to a strobe light.

enter image description here -- you have earned Featured Contributor Badge enter image description here

Your exceptional post has been selected for our editorial column Staff Picks http://wolfr.am/StaffPicks and Your Profile is now distinguished by a Featured Contributor Badge and is displayed on the Featured Contributor Board. Thank you, keep it coming, and consider contributing to the The Notebook Archive!

POSTED BY: EDITORIAL BOARD
Posted 8 years ago

I am impressed. Perhaps a suggestion, put another screen below the first one without the black bars so we can see the rectangles move together at the same speed.

POSTED BY: BJ Miller
Posted 8 years ago

Maybe this explains my wife's exclamation that the other driver "came out of nowhere." Now that I think of it, I think the other driver was in a yellow car. Hmm...

POSTED BY: Mark Greenberg
Posted 8 years ago
POSTED BY: David Keith

Hadn't thought about that analogy! great!

POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract