Skip to content

Instantly share code, notes, and snippets.

@Liam0205
Created January 21, 2016 08:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Liam0205/9d11b44979ef52e02cab to your computer and use it in GitHub Desktop.
Save Liam0205/9d11b44979ef52e02cab to your computer and use it in GitHub Desktop.
\documentclass[tikz]{standalone}%
\usetikzlibrary{fit,calc,shadows,backgrounds,positioning}
\tikzset{
polaroid/.cd,
at/.store in=\polaroidat,
at={0,0},
graphics options/.store in=\polaroidgraphicsoptions,
graphics options=,
rotate/.store in=\polaroidrotate,
rotate=0,
caption/.store in=\polaroidcaption,
caption=,
caption distance/.store in=\polaroidcaptiondistance,
caption distance=1mm,
top margin/.store in=\polaroidtopmargin,
bottom margin/.store in=\polaroidbottommargin,
left margin/.store in=\polaroidleftmargin,
right margin/.store in=\polaroidrightmargin,
vmargin/.style={top margin=#1,bottom margin=#1},
hmargin/.style={left margin=#1,right margin=#1},
margin/.style={vmargin=#1,hmargin=#1},
margin=1cm,
caption default/.style={font=\bfseries,node distance=1mm},
caption options/.style={caption default/.append style={#1}},
frame default/.style={draw,inner sep=0},
frame options/.style={frame default/.append style={#1}},
}
\newcommand\polaroidset[1]{\tikzset{polaroid/.cd,#1}}
\newcommand\polaroid[2][]{
\bgroup
\tikzset{polaroid/.cd,#1}
\pgfmathsetmacro\polaroidrotate{\polaroidrotate}
\begin{scope}[shift={(\polaroidat)},rotate=\polaroidrotate]
\node[rotate=\polaroidrotate,inner sep=0]
(shoot) {\expandafter\includegraphics\expandafter[\polaroidgraphicsoptions]{#2}};
\path (shoot.north) ++(0,\polaroidtopmargin) coordinate (polaroid top);
\path (shoot.south) ++(0,{-1*(\polaroidbottommargin)}) coordinate (polaroid bottom);
\path (shoot.west) ++({-1*(\polaroidleftmargin)},0) coordinate (polaroid left);
\path (shoot.east) ++(\polaroidrightmargin,0) coordinate (polaroid right);
\node[rotate fit=\polaroidrotate,fit=(polaroid top)(polaroid bottom)(polaroid left)(polaroid right),polaroid/frame default]{};
\node[rotate=\polaroidrotate,inner sep=0]
(shoot) {\expandafter\includegraphics\expandafter[\polaroidgraphicsoptions]{#2}};
\coordinate (caption center) at ($(shoot.south)!-1 * \polaroidcaptiondistance!(shoot.north)$);
\node[anchor=north,rotate=\polaroidrotate,polaroid/caption default]
(caption) at (caption center) {\polaroidcaption};
\end{scope}
\egroup
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment