7

Is there a package that can be used to draw images that resemble a screenshot with tikz. For example, if I take the following screenshot

enter image description here

Is there a package that does this in tikz or is it a case of drawing the appropriate shapes from scratch?

KatyB
  • 2,871
  • related: http://tex.stackexchange.com/questions/60422/how-to-export-svg-to-tikz/60666#60666. What you're asking for is very difficult, and I doubt a really good solution exists. If there were one, I would already have "vectorised" all my pictures... – jub0bs Feb 25 '14 at 11:35
  • What's the intended use of such package? Are just trying to get a screenshot that can be scaled arbitrarily? Are you trying to create mock ui elements for illustration? Could the drawing be recreated manually from basic components? Do you need perfect resemblance? Does it need to work on windows only? – Bordaigorl Feb 25 '14 at 12:00
  • 3
    Perhaps something like this is what you are after? MATLAB like command box – Alan Munn Feb 25 '14 at 13:08

1 Answers1

24

You can do this using either the tcolorbox or the mdframed packages. Here's some example code using tcolorbox (some details can be improved, but this is left as an exercise):

\documentclass{article}
\usepackage{fourier}
\usepackage{tcolorbox}
\tcbuselibrary{most}
\usetikzlibrary{shapes.geometric}

\definecolor{blue1}{RGB}{176,209,244}
\definecolor{gray1}{RGB}{212,219,239}
\definecolor{gray2}{RGB}{239,239,239}
\definecolor{red1}{RGB}{187,71,54}

\newtcolorbox{notepad}[1][Untitled]{
freelance,
coltitle=black,
fonttitle=\footnotesize,
frame code={
  \draw[rounded corners=2pt,fill=blue1] 
    ([xshift=-2pt]frame.north west) --
    ([xshift=2pt]frame.north east) --
    ([xshift=2pt,yshift=-2pt]frame.south east) --
    ([xshift=-2pt,yshift=-2pt]frame.south west) -- cycle;
  \node[anchor=north west,xshift=1.5pt] 
    at (frame.north west)  
    {\includegraphics[height=10pt]{notepad.png}};  
  \node[draw,fill=red1,anchor=north east,inner ysep=0pt,text width=10pt,minimum height=8pt] 
  at ([xshift=-1.5pt]frame.north east) (close) {};
  \node[draw,fill=gray1,anchor=north east,inner ysep=0pt,text width=10pt,minimum height=8pt] 
  at ([xshift=\pgflinewidth]close.north west) (minim) {};
  \node[draw,fill=gray1,anchor=north east,inner ysep=0pt,text width=10pt,minimum height=8pt] 
  at ([xshift=\pgflinewidth]minim.north west) (hide) {};
  \draw[double,fill=gray1] 
    ([xshift=-2pt,yshift=-2pt]minim.center) rectangle 
    ([xshift=2pt,yshift=2pt]minim.center);
  \draw[fill=white] 
    ([xshift=-3pt,yshift=-1pt]hide.center) rectangle 
    ([xshift=3pt,yshift=-2.2pt]hide.center);
  \draw[fill=white,rotate=45] 
    ([xshift=-3pt,yshift=-0.8pt]close.center) rectangle 
    ([xshift=3pt,yshift=0.8pt]close.center);
  \draw[fill=white,rotate=135] 
    ([xshift=-3pt,yshift=-0.8pt]close.center) rectangle 
    ([xshift=3pt,yshift=0.8pt]close.center);
  \draw[draw=none,fill=white,rotate=45] 
    ([xshift=-3pt+\pgflinewidth,yshift=-0.8pt+\pgflinewidth]close.center) rectangle 
    ([xshift=3pt-\pgflinewidth,yshift=0.8pt-\pgflinewidth]close.center);
  },
  title code={
    \draw[fill=gray1] 
      (title.south west) rectangle 
      ([yshift=10pt]title.south east);
    \node[anchor=south west,inner ysep=0pt,xshift=1.5pt] 
      at (title.south west) 
      {\footnotesize File\quad Edit\quad Format\quad View\quad Help};
  },
  bottomtitle=12pt,
interior titled code={
  \draw[fill=white] 
    (interior.north west) --
    (interior.north east) --
    (interior.south east) --
    (interior.south west) -- cycle;
  \draw[fill=gray2,draw=gray!30] 
    ([xshift=-7pt,yshift=-\pgflinewidth]interior.north east) rectangle 
    ([xshift=-\pgflinewidth,yshift=7+\pgflinewidth]interior.south east);    
  \draw[fill=gray2,draw=gray!30] 
    ([yshift=7pt,xshift=\pgflinewidth]interior.south west) rectangle 
    ([xshift=-7pt-\pgflinewidth,yshift=+\pgflinewidth]interior.south east);
  \node[isosceles triangle,fill=black!70,minimum height=1cm,minimum width=2cm, shape border rotate=180, isosceles triangle stretches,scale=0.105] 
    at ([yshift=3.5pt,xshift=4pt]interior.south west) {};      
  \node[isosceles triangle,fill=black!70,minimum height=1cm,minimum width=2cm, shape border rotate=0, isosceles triangle stretches,scale=0.105] 
    at ([yshift=3.5pt,xshift=-11pt]interior.south east) {};      
  \node[isosceles triangle,fill=black!70,minimum height=1cm,minimum width=2cm, shape border rotate=90, isosceles triangle stretches,scale=0.105] 
    at ([xshift=-3.5pt,yshift=-5pt]interior.north east) {};      
  \node[isosceles triangle,fill=black!70,minimum height=1cm,minimum width=2cm, shape border rotate=-90, isosceles triangle stretches,scale=0.105] 
    at ([xshift=-3.5pt,yshift=12pt]interior.south east) {};      
  \draw[fill=gray2,draw=gray!30] 
    ([yshift=7pt,xshift=-7pt]interior.south east) rectangle 
    ([xshift=-\pgflinewidth,yshift=+\pgflinewidth]interior.south east);
  \fill[gray1!94!black]
    ([yshift=\pgflinewidth,xshift=-\pgflinewidth]interior.south east) --   
    ([yshift=7pt,xshift=-\pgflinewidth]interior.south east) --   
    ([xshift=-7pt,yshift=\pgflinewidth]interior.south east) -- cycle;  
  },
  title={\hspace*{11pt}#1-Notepad},
  height=8cm,
  left=1.5pt,
  right=8.5pt,
}
\begin{document}

\begin{notepad}
text text
\end{notepad}

\begin{notepad}[Document]
text text
\end{notepad}

\end{document}

enter image description here

Gonzalo Medina
  • 505,128