Re: [dk-tug] tikz igen

Martin Heller <[email protected]>
Newsgroups gmane.comp.tex.danish
Message-ID <[email protected]>
Lars Madsen wrote, on 27-09-2011 22:34:
> Nogen ideer?

\documentclass{article}
\usepackage{tikz}
\newlength\roundedcornerradius
\pgfkeys{%
	/rounded corner 
rectangle/radius/.code=\pgfmathsetlength{\roundedcornerradius}{#1},
	/rounded corner rectangle/radius=5pt
}
\makeatletter
\pgfdeclareshape{rounded corner rectangle}{%
	\inheritsavedanchors[from=rectangle] % this is nearly a rectangle
	\inheritanchorborder[from=rectangle]
	\foreach \anchor in {center,north west,north,north east,east,south 
east,south,south west,west} {%
		\inheritanchor[from=rectangle]{\anchor}
	}%
	\backgroundpath{%
	\southwest \pgf@xa=\pgf@x \pgf@ya=\pgf@y
	\northeast \pgf@xb=\pgf@x \pgf@yb=\pgf@y
	\pgf@xc=\pgf@xb \advance\pgf@xc by-\roundedcornerradius
	\pgf@yc=\pgf@yb \advance\pgf@yc by-\roundedcornerradius
	\pgfpathmoveto{\pgfpoint{\pgf@xa}{\pgf@ya}}
	\pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@yb}}
	\pgfpathlineto{\pgfpoint{\pgf@xc}{\pgf@yb}}
	\pgfpatharc{90}{0}{\roundedcornerradius}
	\pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@ya}}
	\pgfpathclose
	}%
}%
\makeatother

\begin{document}

\begin{tikzpicture}[every node/.style=draw]
	\node[rounded corner rectangle] (x) {Test};
	\node[%
		rounded corner rectangle,below=1cm,
		/rounded corner rectangle/radius=10pt
	] (y) at (x.south) {Test};
\end{tikzpicture}

\end{document}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.