Guest User

Untitled

a guest
Feb 25th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. documentclass[tikz, border=5pt]{standalone}
  2. usepackage{tikz,pgfkeys}
  3. makeatletter
  4. defpgfutil@gobble#1{}
  5. pgfkeys{/handlers/.unknown to list/.code=%
  6. let#1pgfutil@gobble
  7. pgfkeysalso{% or pgfkeys{pgfkeyscurrentpath/.cd,
  8. .unknown/.code=% how to handle the difference between 'key' and 'key=value'?
  9. ifxpgfkeyscurrentvaluepgfkeysnovalue
  10. letpgfkeys@temppgfkeyscurrentname
  11. else
  12. expandafterexpandafterexpandafterdefexpandafterexpandafterexpandafterpgfkeys@tempexpandafterexpandafterexpandafter{expandafterpgfkeyscurrentnameexpandafter=expandafter{pgfkeyscurrentvalue}}%
  13. fi
  14. expandafterexpandafterexpandafterdefexpandafterexpandafterexpandafter#1expandafterexpandafterexpandafter{expandafter#1expandafter,pgfkeys@temp},%
  15. .@clear list/.code=let#1pgfutil@gobble}%
  16. }
  17. makeatother
  18.  
  19. pgfkeys{
  20. /cuboid/.is family, /cuboid,
  21. depth/.estore in = cuboidz,
  22. width/.estore in = cuboidx,
  23. height/.estore in = cuboidy,
  24. front/.estore in = cuboidzStyle,
  25. side/.estore in = cuboidxStyle,
  26. top/.estore in = cuboidyStyle,
  27. .unknown to list = cuboidOptions,
  28. default/.style = {width=1, height=1, depth=1, front=, side=, top=, draw},
  29. }
  30.  
  31. newcommand{cuboid}[2][]{
  32. pgfkeys{/cuboid, default, #1}%
  33. begingroup
  34. edefx{%
  35. endgroup
  36. noexpandbegin{scope}[shift={#2}, join=bevel, cuboidOptions]
  37. noexpanddraw[fill,cuboidyStyle] (0,cuboidy,0) -- (cuboidx,cuboidy,0) -- (cuboidx,cuboidy,cuboidz) -- (0,cuboidy,cuboidz) -- cycle;
  38. noexpanddraw[fill,cuboidxStyle] (cuboidx,0,0) -- (cuboidx,cuboidy,0) -- (cuboidx,cuboidy,cuboidz) -- (cuboidx,0,cuboidz) -- cycle;
  39. noexpanddraw[fill,cuboidzStyle] (0,0,cuboidz) -- (cuboidx,0,cuboidz) -- (cuboidx,cuboidy,cuboidz) -- (0,cuboidy,cuboidz) -- cycle;
  40. noexpandend{scope}
  41. noexpandpgfkeys{/cuboid/.@clear list}
  42. }%
  43. x
  44. }
  45.  
  46. begin{document}
  47. tikzstyle{interior}=[fill=blue!50]
  48. begin{tikzpicture}[scale=.7, fill=blue!60, z={(225:.8)}, x={(-10:1)}]
  49. cuboid[front=interior, side=interior]{(0,1.5,0)} cuboid[front=interior, width=2]{(1.25,1.5,0)}
  50. cuboid[side=interior]{(0,1.5,1.5)} cuboid[width=2, front=]{(1.25,1.5,1.5)}
  51. end{tikzpicture}
  52. end{document}
Add Comment
Please, Sign In to add comment