Guest User

Untitled

a guest
May 4th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. documentclass[border=5pt, multi, tikz]{standalone}
  2. usetikzlibrary{quotes,arrows.meta}
  3. tikzset{
  4. annotated cuboid/.pic={
  5. tikzset{%
  6. every edge quotes/.append style={midway, auto},
  7. /cuboid/.cd,
  8. #1
  9. }
  10. draw [every edge/.append style={pic actions, densely dashed, opacity=.5}, pic actions]
  11. (0,0,0) coordinate (o) -- ++(-cubescale*cubex,0,0) coordinate (a) -- ++(0,-cubescale*cubey,0) coordinate (b) edge coordinate [pos=1] (g) ++(0,0,-cubescale*cubez) -- ++(cubescale*cubex,0,0) coordinate (c) -- cycle
  12. (o) -- ++(0,0,-cubescale*cubez) coordinate (d) -- ++(0,-cubescale*cubey,0) coordinate (e) edge (g) -- (c) -- cycle
  13. (o) -- (a) -- ++(0,0,-cubescale*cubez) coordinate (f) edge (g) -- (d) -- cycle;
  14. path [every edge/.append style={pic actions, |-|}]
  15. (b) +(0,-5pt) coordinate (b1) edge ["cubex cubeunits"'] (b1 -| c)
  16. (b) +(-5pt,0) coordinate (b2) edge ["cubey cubeunits"] (b2 |- a)
  17. (c) +(3.5pt,-3.5pt) coordinate (c2) edge ["cubez cubeunits"'] ([xshift=3.5pt,yshift=-3.5pt]e)
  18. ;
  19. },
  20. /cuboid/.search also={/tikz},
  21. /cuboid/.cd,
  22. width/.store in=cubex,
  23. height/.store in=cubey,
  24. depth/.store in=cubez,
  25. units/.store in=cubeunits,
  26. scale/.store in=cubescale,
  27. width=10,
  28. height=10,
  29. depth=10,
  30. units=cm,
  31. scale=.1,
  32. }
  33. begin{document}
  34. begin{tikzpicture}
  35. pic {annotated cuboid};
  36. pic [fill=magenta, text=blue, draw=blue] at (5,0) {annotated cuboid={width=30, height=5, depth=10}};
  37. pic [fill=green, text=green!50!black, draw=green!25!black] at (5,-2) {annotated cuboid={width=6, height=20, depth=15, units=mm}};
  38. pic at (1,-3) {annotated cuboid={width=150, height=200, depth=250, scale=.01, units=m}};
  39. pic [fill=cyan, text=blue!75!cyan, draw=blue!75!cyan] at (-3,-2) {annotated cuboid={width=15, height=18, depth=13.5, units=}};
  40. end{tikzpicture}
  41. end{document}
Add Comment
Please, Sign In to add comment