Skip to content

Commit

Permalink
PGF shapes: trek elbow and trek cursor.
Browse files Browse the repository at this point in the history
These basic shapes are used to compose most of the Trek theme.
  • Loading branch information
lancelet committed Aug 5, 2013
1 parent e0bb932 commit 6d2d212
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 0 deletions.
53 changes: 53 additions & 0 deletions design/beamer-trek-design.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
\documentclass{scrartcl}
\usepackage{import}
\usepackage{tikz}

\import{../theme/}{trek-shapes.tex}

\begin{document}

\begin{figure}
\begin{center}
\begin{tikzpicture}
\draw (0,0) node
[trek cursor,
trek/cursor/height=2cm,
trek/cursor/width=5cm,
fill=black!10,
thick] {};
\draw [|<->|] (-5mm,0) -- (-5mm,2cm) node [midway,left] {height};
\draw [|<->|] (0mm,-5mm) -- (5cm,-5mm) node [midway,below] {width};
\draw (0,0) circle (1mm);
\end{tikzpicture}
\caption{Shape: ``trek cursor''.}
\label{fig:shape-trek-cursor}
\end{center}
\end{figure}

\begin{figure}
\begin{center}
\begin{tikzpicture}
\draw (0,0) node
[trek elbow,
trek/elbow/width=50mm,
trek/elbow/height=20mm,
trek/elbow/bar height=10mm,
trek/elbow/sidebar width=20mm,
trek/elbow/outer radius=10mm,
trek/elbow/inner radius=5mm,
fill=black!10,
thick] {};
\draw (0,0) circle (1mm);
\draw [|<->|] (5mm,0) -- (5mm,10mm) node [midway,right] {bar height};
\draw [|<->|] (-55mm,-10mm) -- (-55mm,10mm) node [midway,left] {height};
\draw [|<->|] (-50mm,-15mm) -- (-30mm,-15mm) node [midway,below] {sidebar width};
\draw [|<->|] (-50mm,-24mm) -- (0mm,-24mm) node [midway,below] {width};
\draw (-28mm,-1mm) node [anchor=north west] {inner radius};
\draw (-50mm,11mm) node [anchor=south west] {outer radius};
\end{tikzpicture}
\caption{Shape: ``trek elbow''.}
\label{fig:shape-trek-elbow}
\end{center}
\end{figure}

\end{document}
81 changes: 81 additions & 0 deletions theme/trek-shapes.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
\RequirePackage{tikz}

\makeatletter

% Trek cursor shape
\pgfkeys{/tikz/trek/cursor/width/.initial = 20mm}
\pgfkeys{/tikz/trek/cursor/height/.initial = 7.5mm}
\pgfdeclareshape{trek cursor}
{
\saveddimen\width{\pgf@x = \pgfkeysvalueof{/tikz/trek/cursor/width}}
\saveddimen\height{\pgf@x = \pgfkeysvalueof{/tikz/trek/cursor/height}}
\savedanchor\centerpoint{
\pgf@x = 0.5\wd\pgfnodeparttextbox
\pgf@y = 0.5\ht\pgfnodeparttextbox
}
\anchor{center}{\centerpoint}

\backgroundpath{
\newlength\@radius
\@radius = \height
\divide \@radius by 2
\pgf@xa = \width
\advance \pgf@xa by -\@radius
\pgf@ya = \height
\pgf@xb = \pgf@xa
\pgf@yb = 0mm
\pgfpathmoveto{\pgfpoint{0}{0}}
\pgfpathlineto{\pgfpoint{0}{\height}}
\pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@ya}}
\pgfpatharcto{\height/2}{\height/2}{0}{0}{0}{\pgfpoint{\pgf@xb}{\pgf@yb}}
\pgfpathclose
\pgfusepath{fill,draw}
}
}

% Trek elbow shape
\pgfkeys{/tikz/trek/elbow/bar height/.initial = 7.5mm}
\pgfkeys{/tikz/trek/elbow/outer radius/.initial = 3mm}
\pgfkeys{/tikz/trek/elbow/inner radius/.initial = 1mm}
\pgfkeys{/tikz/trek/elbow/sidebar width/.initial = 5mm}
\pgfkeys{/tikz/trek/elbow/width/.initial = 30mm}
\pgfkeys{/tikz/trek/elbow/height/.initial = 10mm}
\pgfdeclareshape{trek elbow}
{
\saveddimen\barheight{\pgf@x = \pgfkeysvalueof{/tikz/trek/elbow/bar height}}
\saveddimen\outerradius{\pgf@x = \pgfkeysvalueof{/tikz/trek/elbow/outer radius}}
\saveddimen\innerradius{\pgf@x = \pgfkeysvalueof{/tikz/trek/elbow/inner radius}}
\saveddimen\sidebarwidth{\pgf@x = \pgfkeysvalueof{/tikz/trek/elbow/sidebar width}}
\saveddimen\width{\pgf@x = \pgfkeysvalueof{/tikz/trek/elbow/width}}
\saveddimen\height{\pgf@x = \pgfkeysvalueof{/tikz/trek/elbow/height}}
\savedanchor\centerpoint{
\pgf@x = 0.5\wd\pgfnodeparttextbox
\pgf@y = 0.5\ht\pgfnodeparttextbox
}
\anchor{center}{\centerpoint}

\backgroundpath{
\pgf@xa = -\width
\advance \pgf@xa by \outerradius
\pgf@ya = \barheight
\advance \pgf@ya by -\outerradius
\pgf@yb = -\height
\advance \pgf@yb by \barheight
\pgf@xb = -\width
\advance \pgf@xb by \sidebarwidth
\pgf@xc = \pgf@xb
\advance \pgf@xc by \innerradius
\pgfpathmoveto{\pgfpoint{0}{0}}
\pgfpathlineto{\pgfpoint{0}{\barheight}}
\pgfpathlineto{\pgfpoint{\pgf@xa}{\barheight}}
\pgfpatharcto{\outerradius}{\outerradius}{0}{0}{1}{\pgfpoint{-\width}{\pgf@ya}}
\pgfpathlineto{\pgfpoint{-\width}{\pgf@yb}}
\pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@yb}}
\pgfpathlineto{\pgfpoint{\pgf@xb}{-\innerradius}}
\pgfpatharcto{\innerradius}{\innerradius}{0}{0}{0}{\pgfpoint{\pgf@xc}{0}}
\pgfpathclose
\pgfusepath{fill,draw}
}
}

\makeatother

0 comments on commit 6d2d212

Please sign in to comment.