Skip to content

Instantly share code, notes, and snippets.

@greggroth
Created September 1, 2011 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save greggroth/1186244 to your computer and use it in GitHub Desktop.
Save greggroth/1186244 to your computer and use it in GitHub Desktop.
Mathematica:coverflow
pic = Import["ExampleData/rose.gif"];
Module[{width = 28, layers = 6, offset, highlight, slides, img,
data},
offset[x_, slide_] := 15/(1 + Exp[-(x - slide) 3]);
highlight[x_, slide_] :=
0.85 PDF[NormalDistribution[slide, 1], x]/
PDF[NormalDistribution[slide, 1], slide] + 0.15;
img = Table[pic, {n, 1, layers}];
Manipulate[Graphics3D[{
Table[{
Texture[img[[n]]],
Opacity[highlight[n, slide]],
Text[
Style[n, 16], {n + offset[n, slide], -width/2 + 1,
width/2 - 1}],
Polygon[{
{n + offset[n, slide], -width/2, width/2},
{n + offset[n, slide], -width/2, -width/2},
{n + offset[n, slide], width/2, -width/2},
{n + offset[n, slide], width/2, width/2}},
VertexTextureCoordinates -> {{0, 1}, {0, 0}, {1, 0}, {1, 1}}]
},
{n, 1, layers}]},
PlotRange -> {{-1, layers + 20}, {-width/2 - 1,
width/2 + 1}, {-width/2, width/2 + 3}},
Lighting -> {{"Ambient", White}},
Background -> Black,
ViewPoint -> {1, -1.5, .5},
Axes -> None,
Boxed -> False,
ImageSize -> 700],
{{slide, layers + 2, "Slide"}, layers + 2, -3,
ControlType -> Slider, ImageSize -> 500}, SaveDefinitions -> True]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment