2048.tex 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. \documentclass[tikz]{standalone}
  2. \renewcommand\familydefault{\sfdefault}
  3. \usepackage{tikz}
  4. \usetikzlibrary{fit,backgrounds}
  5. %
  6. \definecolor{grid color}{HTML}{BBADA0}
  7. \definecolor{pixel 0}{HTML}{CCC0B3}
  8. \definecolor{pixel 2}{HTML}{EEE4DA}
  9. \definecolor{pixel 4}{HTML}{EDE0C8}
  10. \definecolor{pixel 8}{HTML}{F2B179}
  11. \definecolor{pixel 16}{HTML}{F59563}
  12. \definecolor{pixel 32}{HTML}{F67C5F}
  13. \definecolor{pixel 64}{HTML}{F65E3B}
  14. \definecolor{pixel 128}{HTML}{EDCF72}
  15. \definecolor{pixel 256}{HTML}{EDCC61}
  16. \definecolor{pixel 512}{HTML}{EDC850}
  17. \definecolor{pixel 1024}{HTML}{EDC53F}
  18. \definecolor{pixel 2048}{HTML}{EDC22E}
  19. \definecolor{pixel 4096}{HTML}{3E3933}
  20. %
  21. \definecolor{small color}{HTML}{776E65}
  22. \definecolor{big color}{HTML}{F9F6F2}
  23. %
  24. \tikzset{
  25. case 2048 base/.style={minimum size=9mm,rounded corners=.3mm,text=#1,inner sep=0},
  26. %
  27. case 2048 LARGE/.style={font=\LARGE\bfseries\sffamily,case 2048 base=#1},
  28. case 2048 Large/.style={font=\Large\bfseries\sffamily,case 2048 base=#1},
  29. case 2048 large/.style={font=\large\bfseries\sffamily,case 2048 base=#1},
  30. case 2048 normal/.style={font=\normalsize\bfseries\sffamily,case 2048 base=#1},
  31. %
  32. case 2048 0/.style={case 2048 Large=black,fill=pixel 0,node contents={}},
  33. case 2048 2/.style={case 2048 Large=small color,fill=pixel 2,node contents={2}},
  34. case 2048 4/.style={case 2048 Large=small color,fill=pixel 4,node contents={4}},
  35. case 2048 8/.style={case 2048 Large=big color,fill=pixel 8,node contents={8}},
  36. case 2048 16/.style={case 2048 Large=big color,fill=pixel 16,node contents={16}},
  37. case 2048 32/.style={case 2048 Large=big color,fill=pixel 32,node contents={32}},
  38. case 2048 64/.style={case 2048 Large=big color,fill=pixel 64,node contents={64}},
  39. case 2048 128/.style={case 2048 large=big color,fill=pixel 128,node contents={128}},
  40. case 2048 256/.style={case 2048 large=big color,fill=pixel 256,node contents={256}},
  41. case 2048 512/.style={case 2048 large=big color,fill=pixel 512,node contents={512}},
  42. case 2048 1024/.style={case 2048 normal=big color,fill=pixel 1024,node contents={1024}},
  43. case 2048 2048/.style={case 2048 normal=big color,fill=pixel 2048,node contents={2048}},
  44. case 2048 4096/.style={case 2048 normal=big color,fill=pixel 4096,node contents={4096}},
  45. }
  46. \begin{document}
  47. \begin{tikzpicture}
  48. \def\pixels{
  49. {0,2,32,64},
  50. {256,8,512,4},
  51. {1024,2048,4,16},
  52. {4096,16,128,2},
  53. }
  54. \foreach \line [count=\y] in \pixels {
  55. \foreach \pix [count=\x] in \line {
  56. \path (\x,-\y) node[name=c2048-\x-\y,case 2048 \pix];
  57. }
  58. }
  59. \begin{scope}[on background layer]
  60. \node[fill=grid color,fit=(c2048-1-1)(c2048-4-4),
  61. inner sep=1mm,rounded corners=.3mm]{};
  62. \end{scope}
  63. \end{tikzpicture}
  64. \end{document}