Advertisement
Matthen

Diamond Illusion

May 12th, 2013
416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. n = 6;
  2. gradient = Graphics[
  3. Rotate[
  4. Inset[ContourPlot[y, {x, 0, 1}, {y, 0, 1}, Axes -> None,
  5. Frame -> None, Contours -> 100, ContourLines -> False,
  6. ColorFunction -> (GrayLevel[0.1 + #1/1.2] &)], {0, 0}, {0,
  7. 0}, {1, 1}]
  8. , Pi/4]
  9. ,
  10. PlotRange -> {{0.2, 0.7}, {0.2, 0.7}}];
  11. piece = Graphics[{Texture[gradient],
  12. Polygon[{{0, 0}, {1/2, -1}, {1, 0}, {1/2, 1}},
  13. VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}]}];
  14. bg = Rasterize[Graphics[
  15. Table[
  16. {Translate[
  17. Inset[piece, {0, 0}, {0, 0}, {2.1, 2.1}], {xshift +
  18. If[EvenQ[yshift], 0.5, 0], yshift}]},
  19. {xshift, n}, {yshift, n}
  20. ]
  21. , Background -> GrayLevel[0.9],
  22. PlotRange -> {{2, n + 1}, {1, n + 1}}]];
  23. frame[t_] := Graphics[{Inset[bg, {0, 0}, {0, 0}, n {1.1, 1.1}],
  24. Translate[
  25. Inset[piece, {0, 0}, {0, 0}, {2.2, 2.2}], {1.65 + 0.5 t,
  26. 1 + t}]}
  27. , PlotRange -> {{0, n - 1}, {0, n + 0.5}}];
  28. Manipulate[frame[t], {t, 0, n - 1}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement