Here's a node shape that uses the parametric representation of the superellipse. All standard anchors and the border anchors are defined. The rectangularness is controlled using the key superellipse parameter
. A value of 1
is a diamond.
\tikz{
\foreach \parameter in {0.4,0.6,0.8,1,2,...,10}
\node [minimum width=4cm, minimum height=2cm, draw, red,text=black, superellipse, superellipse parameter=\parameter] (a) {};
\begin{tikzpicture}
\node [minimum width=4cm, minimum height=2cm, draw, superellipse, superellipse parameter=4] (a) {};
\foreach \angle in {5,10,...,360}
\draw [orange] (a.\angle) -- (\angle:5cm);
\end{tikzpicture}
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, intersections}
\makeatletter
% fixed exp function.
%
\makeatletter
\let\pgfmath@function@exp\relax % undefine old exp function
\pgfmathdeclarefunction{exp}{1}{%
\begingroup
\pgfmath@xc=#1pt\relax
\pgfmath@yc=#1pt\relax
\ifdim\pgfmath@xc<-9pt
\pgfmath@x=1sp\relax
\else
\ifdim\pgfmath@xc<0pt
\pgfmath@xc=-\pgfmath@xc
\fi
\pgfmath@x=1pt\relax
\pgfmath@xa=1pt\relax
\pgfmath@xb=\pgfmath@x
\pgfmathloop%
\divide\pgfmath@xa by\pgfmathcounter
\pgfmath@xa=\pgfmath@tonumber\pgfmath@xc\pgfmath@xa%
\advance\pgfmath@x by\pgfmath@xa
\ifdim\pgfmath@x=\pgfmath@xb
\else
\pgfmath@xb=\pgfmath@x
\repeatpgfmathloop%
\ifdim\pgfmath@yc<0pt
\pgfmathreciprocal@{\pgfmath@tonumber\pgfmath@x}%
\pgfmath@x=\pgfmathresult pt\relax
\fi
\fi
\pgfmath@returnone\pgfmath@x%
\endgroup
}
\let\pgfmath@function@pow\relax % undefine old exp function
\pgfmathdeclarefunction{pow}{2}{%
\begingroup%
\pgfmath@xa=#1pt%
\pgfmath@xb=#2pt%
\ifdim\pgfmath@xa=0pt
\pgfmath@x=0pt\relax
\else
\afterassignment\pgfmath@x%
\expandafter\c@pgfmath@counta\the\pgfmath@xb\relax%
\ifnum\c@pgfmath@counta<0\relax%
\c@pgfmath@counta=-\c@pgfmath@counta%
\pgfmathreciprocal@{#1}%
\pgfmath@xa=\pgfmathresult pt\relax%
\fi
\ifdim\pgfmath@x=0pt\relax%
\pgfmath@x=1pt\relax%
\pgfmathloop%
\ifnum\c@pgfmath@counta>0\relax%
\ifodd\c@pgfmath@counta%
\pgfmath@x=\pgfmath@tonumber{\pgfmath@x}\pgfmath@xa%
\fi
\ifnum\c@pgfmath@counta>1\relax%
\pgfmath@xa=\pgfmath@tonumber{\pgfmath@xa}\pgfmath@xa%
\fi%
\divide\c@pgfmath@counta by2\relax%
\repeatpgfmathloop%
\else%
\pgfmathln@{#1}%
\pgfmath@x=\pgfmathresult pt\relax%
\pgfmath@x=\pgfmath@tonumber{\pgfmath@xb}\pgfmath@x%
\pgfmathexp@{\pgfmath@tonumber{\pgfmath@x}}%
\pgfmath@x=\pgfmathresult pt\relax%
\fi%
\fi
\pgfmath@returnone\pgf@x%
\endgroup%
}
\pgfkeys{
/pgf/superellipse parameter/.store in=\pgf@superellipse@param,
/pgf/superellipse parameter/.default=2,
/pgf/superellipse parameter
}
\newcommand{\pointonsuperellipse}[3]{ % cornerpoint, parameter, directionpoint
\pgf@process{#1}
\edef\size@x{\the\pgf@x}%
\edef\size@y{\the\pgf@y}%
\pgfintersectionofpaths
{
\pgfpathmoveto{\centerpoint}
\pgfpathlineto{
\pgfpointborderrectangle{#3}{#1}
}
\pgfpathclose
}
{
\pgfplothandlercurveto
\pgfplotfunction{\x}{-180,-170,...,170}{
\pgfpoint{
abs(1 * cos(\x))^(2/#2)*( (cos(\x)>0)*2-1 ) * \size@x
}{
abs(1 * sin(\x))^(2/#2)*( (sin(\x)>0)*2-1 ) * \size@y
}
}
\pgfpathclose
}
\pgfpointintersectionsolution{1}
}
\makeatletter
\pgfdeclareshape{superellipse}
%
% Draws a circle around the text
%
{
\savedmacro\superellipseparameter{\edef\superellipseparameter{\pgf@superellipse@param}}
\savedanchor\centerpoint{%
\pgf@x=.5\wd\pgfnodeparttextbox%
\pgf@y=.5\ht\pgfnodeparttextbox%
\advance\pgf@y by-.5\dp\pgfnodeparttextbox%
}
\savedanchor\radius{%
%
% Caculate ``height radius''
%
\pgf@y=.5\ht\pgfnodeparttextbox%
\advance\pgf@y by.5\dp\pgfnodeparttextbox%
\pgfmathsetlength\pgf@yb{\pgfkeysvalueof{/pgf/inner ysep}}%
\advance\pgf@y by\pgf@yb%
%
% Caculate ``width radius''
%
\pgf@x=.5\wd\pgfnodeparttextbox%
\pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/inner xsep}}%
\advance\pgf@x by\pgf@xb%
%
% Adjust
%
\pgf@x=1.4142136\pgf@x%
\pgf@y=1.4142136\pgf@y%
%
% Adjust hieght, if necessary
%
\pgfmathsetlength\pgf@yc{\pgfkeysvalueof{/pgf/minimum height}}%
\ifdim\pgf@y<.5\pgf@yc%
\pgf@y=.5\pgf@yc%
\fi%
%
% Adjust width, if necessary
%
\pgfmathsetlength\pgf@xc{\pgfkeysvalueof{/pgf/minimum width}}%
\ifdim\pgf@x<.5\pgf@xc%
\pgf@x=.5\pgf@xc%
\fi%
%
% Add outer sep
%
\pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/outer xsep}}%
\pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/outer ysep}}%
\advance\pgf@x by\pgf@xb%
\advance\pgf@y by\pgf@yb%
}
\savedmacro\test{\def\test{2}}
%
% Anchors
%
\anchor{center}{\centerpoint}
\anchor{mid}{\centerpoint\pgfmathsetlength\pgf@y{.5ex}}
\anchor{base}{\centerpoint\pgf@y=0pt}
\anchor{north}
{
\pgf@process{\radius}
\pgf@ya=\pgf@y%
\pgf@process{\centerpoint}
\advance\pgf@y by\pgf@ya
}
\anchor{south}
{
\pgf@process{\radius}
\pgf@ya=\pgf@y%
\pgf@process{\centerpoint}
\advance\pgf@y by-\pgf@ya
}
\anchor{west}
{
\pgf@process{\radius}
\pgf@xa=\pgf@x%
\pgf@process{\centerpoint}
\advance\pgf@x by-\pgf@xa
}
\anchor{mid west}
{%
\pgf@process{\radius}
\pgf@xa=\pgf@x%
\pgf@process{\centerpoint}
\advance\pgf@x by-\pgf@xa%
\pgfmathsetlength\pgf@y{.5ex}
}
\anchor{base west}
{%
\pgf@process{\radius}
\pgf@xa=\pgf@x%
\pgf@process{\centerpoint}
\advance\pgf@x by-\pgf@xa%
\pgf@y=0pt
}
\anchor{north west}
{
\pgf@process{\radius}
\def\angle{135}
\pgf@xa=\pgf@x%
\pgf@ya=\pgf@y%
\pgf@process{\pgfpoint{
abs(cos(\angle))^(2/\superellipseparameter)*( (cos(\angle)>0)*2-1 ) * \pgf@xa
}{
abs(sin(\angle))^(2/\superellipseparameter)*( (sin(\angle)>0)*2-1 ) * \pgf@ya
}}
\pgf@xb=\pgf@x%
\pgf@yb=\pgf@y%
\pgf@process{\centerpoint}
\advance\pgf@x by \pgf@xb
\advance\pgf@y by \pgf@yb
}
\anchor{south west}
{
\pgf@process{\radius}
\def\angle{-135}
\pgf@xa=\pgf@x%
\pgf@ya=\pgf@y%
\pgf@process{\pgfpoint{
abs(cos(\angle))^(2/\superellipseparameter)*( (cos(\angle)>0)*2-1 ) * \pgf@xa
}{
abs(sin(\angle))^(2/\superellipseparameter)*( (sin(\angle)>0)*2-1 ) * \pgf@ya
}}
\pgf@xb=\pgf@x%
\pgf@yb=\pgf@y%
\pgf@process{\centerpoint}
\advance\pgf@x by \pgf@xb
\advance\pgf@y by \pgf@yb
}
\anchor{east}
{%
\pgf@process{\radius}
\pgf@xa=\pgf@x%
\pgf@process{\centerpoint}
\advance\pgf@x by\pgf@xa
}
\anchor{mid east}
{%
\pgf@process{\radius}
\pgf@xa=\pgf@x%
\pgf@process{\centerpoint}
\advance\pgf@x by\pgf@xa%
\pgfmathsetlength\pgf@y{.5ex}
}
\anchor{base east}
{%
\pgf@process{\radius}
\pgf@xa=\pgf@x%
\pgf@process{\centerpoint}
\advance\pgf@x by\pgf@xa%
\pgf@y=0pt
}
\anchor{north east}
{
\pgf@process{\radius}
\def\angle{45}
\pgf@xa=\pgf@x%
\pgf@ya=\pgf@y%
\pgf@process{\pgfpoint{
abs(cos(\angle))^(2/\superellipseparameter)*( (cos(\angle)>0)*2-1 ) * \pgf@xa
}{
abs(sin(\angle))^(2/\superellipseparameter)*( (sin(\angle)>0)*2-1 ) * \pgf@ya
}}
\pgf@xb=\pgf@x%
\pgf@yb=\pgf@y%
\pgf@process{\centerpoint}
\advance\pgf@x by \pgf@xb
\advance\pgf@y by \pgf@yb
}
\anchor{south east}
{
\pgf@process{\radius}
\def\angle{-45}
\pgf@xa=\pgf@x%
\pgf@ya=\pgf@y%
\pgf@process{\pgfpoint{
abs(cos(\angle))^(2/\superellipseparameter)*( (cos(\angle)>0)*2-1 ) * \pgf@xa
}{
abs(sin(\angle))^(2/\superellipseparameter)*( (sin(\angle)>0)*2-1 ) * \pgf@ya
}}
\pgf@xb=\pgf@x%
\pgf@yb=\pgf@y%
\pgf@process{\centerpoint}
\advance\pgf@x by \pgf@xb
\advance\pgf@y by \pgf@yb
}
\anchorborder{
\edef\externalx{\the\pgf@x}%
\edef\externaly{\the\pgf@y}%
\pgf@process{\radius}%
\pgf@xa=\pgf@x%
\pgf@ya=\pgf@y%
\pointonsuperellipse{\pgfpoint{\pgf@xa}{\pgf@ya}}{\superellipseparameter}{\pgfpoint{\externalx}{\externaly}}
\pgf@xa=\pgf@x%
\pgf@ya=\pgf@y%
\centerpoint%
\advance\pgf@x by\pgf@xa%
\advance\pgf@y by\pgf@ya%
}
\backgroundpath
{
\pgf@process{\radius}%
\pgfutil@tempdima=\pgf@x%
\pgfutil@tempdimb=\pgf@y%
\pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/outer xsep}}%
\pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/outer ysep}}%
\advance\pgfutil@tempdima by-\pgf@xb%
\advance\pgfutil@tempdimb by-\pgf@yb%
{
\pgftransformshift{\centerpoint}
\pgfplothandlercurveto
\pgfplotfunction{\x}{-180,-170,...,170}{
\pgfpoint{
abs(1 * cos(\x))^(2/\pgf@superellipse@param)*( (cos(\x)>0)*2-1 ) * \pgfutil@tempdima
}{
abs(1 * sin(\x))^(2/\pgf@superellipse@param)*( (sin(\x)>0)*2-1 ) * \pgfutil@tempdimb
}
}
\pgfpathclose
\pgfgetpath\test
\pgfusepath{stroke}
}
}
}
\def\n{3}
\begin{document}
\begin{tikzpicture}
\node [minimum width=4cm, minimum height=2cm, draw, superellipse, superellipse parameter=4] (a) {};
\foreach \angle in {5,10,...,360}
\draw [orange] (a.\angle) -- (\angle:5cm);
\end{tikzpicture}
\end{document}
As Steven said, you can use
\ifdim\mydim>615pt\relax
\ifdim\mydim<650pt\relax
in range%
\else
above 650%
\fi
\else
below 615%
\fi
If the code for the two out of range cases is the same and you don't want to duplicate it then you can structure it as
\ifdim\ifdim\mydim>615pt\mydim\else\maxdimen\fi<650pt\relax
in range%
\else
out of range%
\fi
Best Answer
No symmetry no Escher's style but ... that look like birds. First you need to save the next code in a file names
bird1.pgf
. It's not exactly the code given by Inkscape. I export the code with LaTeX and PSTricks then I transform the code to get something lighter.It's the first time, I created a vector object with Inkscape. I take an example (.png) and with a bezier tool (pen) I draw the bird. If someone know how to transform a file.png in a file.eps I will be happy. I think it's possible with Inkscape to vectorize a bipmap but I don't know how to do.
For the first birds,I use TikZ so if you don't want to download
tikzrput
andpgfornament
you can comment the last pictures. Then I try with\rput
pgf version and the last I try withpgfornament
.