Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- documentclass[tikz, border=5pt]{standalone}
- usepackage{tikz,pgfkeys}
- makeatletter
- defpgfutil@gobble#1{}
- pgfkeys{/handlers/.unknown to list/.code=%
- let#1pgfutil@gobble
- pgfkeysalso{% or pgfkeys{pgfkeyscurrentpath/.cd,
- .unknown/.code=% how to handle the difference between 'key' and 'key=value'?
- ifxpgfkeyscurrentvaluepgfkeysnovalue
- letpgfkeys@temppgfkeyscurrentname
- else
- expandafterexpandafterexpandafterdefexpandafterexpandafterexpandafterpgfkeys@tempexpandafterexpandafterexpandafter{expandafterpgfkeyscurrentnameexpandafter=expandafter{pgfkeyscurrentvalue}}%
- fi
- expandafterexpandafterexpandafterdefexpandafterexpandafterexpandafter#1expandafterexpandafterexpandafter{expandafter#1expandafter,pgfkeys@temp},%
- .@clear list/.code=let#1pgfutil@gobble}%
- }
- makeatother
- pgfkeys{
- /cuboid/.is family, /cuboid,
- depth/.estore in = cuboidz,
- width/.estore in = cuboidx,
- height/.estore in = cuboidy,
- front/.estore in = cuboidzStyle,
- side/.estore in = cuboidxStyle,
- top/.estore in = cuboidyStyle,
- .unknown to list = cuboidOptions,
- default/.style = {width=1, height=1, depth=1, front=, side=, top=, draw},
- }
- newcommand{cuboid}[2][]{
- pgfkeys{/cuboid, default, #1}%
- begingroup
- edefx{%
- endgroup
- noexpandbegin{scope}[shift={#2}, join=bevel, cuboidOptions]
- noexpanddraw[fill,cuboidyStyle] (0,cuboidy,0) -- (cuboidx,cuboidy,0) -- (cuboidx,cuboidy,cuboidz) -- (0,cuboidy,cuboidz) -- cycle;
- noexpanddraw[fill,cuboidxStyle] (cuboidx,0,0) -- (cuboidx,cuboidy,0) -- (cuboidx,cuboidy,cuboidz) -- (cuboidx,0,cuboidz) -- cycle;
- noexpanddraw[fill,cuboidzStyle] (0,0,cuboidz) -- (cuboidx,0,cuboidz) -- (cuboidx,cuboidy,cuboidz) -- (0,cuboidy,cuboidz) -- cycle;
- noexpandend{scope}
- noexpandpgfkeys{/cuboid/.@clear list}
- }%
- x
- }
- begin{document}
- tikzstyle{interior}=[fill=blue!50]
- begin{tikzpicture}[scale=.7, fill=blue!60, z={(225:.8)}, x={(-10:1)}]
- cuboid[front=interior, side=interior]{(0,1.5,0)} cuboid[front=interior, width=2]{(1.25,1.5,0)}
- cuboid[side=interior]{(0,1.5,1.5)} cuboid[width=2, front=]{(1.25,1.5,1.5)}
- end{tikzpicture}
- end{document}
Add Comment
Please, Sign In to add comment