1

I’m trying to construct png icons following the method explained here. Below is an example file that needs to be adjusted because part of the border is eaten up (all the upper part and the very end of the rightmost part). How should I fix this ?

\documentclass[convert={density=300,size=4600x800,outext=.png}]{standalone}
%\documentclass[a4paper]{article}

\usepackage{tikz}
\usepackage{calc}
\begin{document}
\pagestyle{empty}

% "Nouveau" in green f=23/4

 \noindent\begin{tikzpicture}[x=0.25cm,y=0.25cm]
 % Proportionality constants
  \newcommand*{\jay}{0.25}%
  \newcommand*{\kay}{2}%
 \newcommand*{\hay}{3}%
 \newcommand*{\way}{4}%
  \newcommand*{\bay}{3.5}%
 % Fundamental coordinates of points or vectors
  \newcommand*{\xv}{-0.5*\jay}%
  \newcommand*{\yv}{2*\jay}%
  \newcommand*{\xfive}{0*\jay}%
  \newcommand*{\yfive}{0*\jay}%
  % Deduced coordinates
 \pgfmathsetmacro{\xu}{\bay*\yv}% 
 \pgfmathsetmacro{\yu}{-\bay*\xv}% 
 \pgfmathsetmacro{\xsix}{\xfive+\way*\xu}% 
 \pgfmathsetmacro{\ysix}{\yfive+\way*\yu}% 
 \pgfmathsetmacro{\xten}{\xfive+2*\xv}% 
 \pgfmathsetmacro{\yten}{\yfive+2*\yv}% 
\pgfmathsetmacro{\xeleven}{\xten+\way*\xu}% 
 \pgfmathsetmacro{\yeleven}{\yten+\way*\yu}% 
\pgfmathsetmacro{\xone}{\xsix+\xv}% 
 \pgfmathsetmacro{\yone}{\ysix+\yv}% 
\pgfmathsetmacro{\xtwo}{\xone+\xu}% 
 \pgfmathsetmacro{\ytwo}{\yone+\yu}% 
\pgfmathsetmacro{\xthree}{\xtwo+\kay*\xu}% 
 \pgfmathsetmacro{\ythree}{\ytwo+\kay*\yu}% 
\pgfmathsetmacro{\xtwentytwo}{\xtwo-\hay*\xv}% 
 \pgfmathsetmacro{\ytwentytwo}{\ytwo-\hay*\yv}% 
\pgfmathsetmacro{\xtwentythree}{\xtwentytwo+\kay*\xu}% 
 \pgfmathsetmacro{\ytwentythree}{\ytwentytwo+\kay*\yu}% 
\pgfmathsetmacro{\xseventeen}{\xtwentytwo-\xv}% 
 \pgfmathsetmacro{\yseventeen}{\ytwentytwo-\yv}% 
 \pgfmathsetmacro{\xeighteen}{\xseventeen+\kay*\xu}% 
 \pgfmathsetmacro{\yeighteen}{\yseventeen+\kay*\yu}% 
 \pgfmathsetmacro{\xseven}{\xtwo+\hay*\xv}% 
 \pgfmathsetmacro{\yseven}{\ytwo+\hay*\yv}% 
 \pgfmathsetmacro{\xeight}{\xseven+\kay*\xu}% 
 \pgfmathsetmacro{\yeight}{\yseven+\kay*\yu}% 
 \pgfmathsetmacro{\xtwelve}{\xseven+\xv}% 
 \pgfmathsetmacro{\ytwelve}{\yseven+\yv}% 
  \pgfmathsetmacro{\xthirteen}{\xtwelve+\kay*\xu}% 
 \pgfmathsetmacro{\ythirteen}{\ytwelve+\kay*\yu}% 
 \pgfmathsetmacro{\xfour}{\xthree+\hay*\yv}% 
 \pgfmathsetmacro{\yfour}{\ythree-\hay*\xv}% 
 \pgfmathsetmacro{\xnine}{\xfour+\yv}% 
 \pgfmathsetmacro{\ynine}{\yfour-\xv}% 
 \pgfmathsetmacro{\xfourteen}{\xfive+\xv-\yv}% 
 \pgfmathsetmacro{\yfourteen}{\yfive+\xv+\yv}% 
  \coordinate (A1) at (\xone,\yone);
  \coordinate (A2) at (\xtwo,\ytwo);
  \coordinate (A3) at (\xthree,\ythree);
  \coordinate (A4) at (\xfour,\yfour);
  \coordinate (A5) at (\xfive,\yfive);
  \coordinate (A6) at (\xsix,\ysix);  
  \coordinate (A7) at (\xseven,\yseven);
  \coordinate (A8) at (\xeight,\yeight);  
  \coordinate (A9) at (\xnine,\ynine);   
  \coordinate (A10) at (\xten,\yten);    
\coordinate (A11) at (\xeleven,\yeleven);    
\coordinate (A12) at (\xtwelve,\ytwelve);    
\coordinate (A13) at (\xthirteen,\ythirteen);    
\coordinate (A14) at (\xfourteen,\yfourteen);    
\coordinate (A17) at (\xseventeen,\yseventeen);   
\coordinate (A18) at (\xeighteen,\yeighteen);   
\coordinate (A22) at (\xtwentytwo,\ytwentytwo);  
\coordinate (A23) at (\xtwentythree,\ytwentythree);    
  \fill[fill=green] (A14) -- (A5) -- (A6) -- (A11) -- (A10) -- cycle;
  \fill[fill=green] (A6) -- (A17) -- (A22) -- (A1) -- cycle;
  \fill[fill=green] (A17) -- (A18) -- (A23) -- (A22) -- cycle;
 \fill[fill=green] (A7) -- (A8) -- (A13) -- (A12) -- cycle;
 %\draw (A23) -- (A4) -- (A8);
% \draw (A23) .. controls (A14) .. (A4);
 \pgfmathsetmacro{\dee}{\hay*(veclen(\xv,\yv))}% 
 \pgfmathsetmacro{\deetwo}{(\hay+1)*(veclen(\xv,\yv))}% 
 \pgfmathsetmacro{\anglestart}{atan2(\xtwentythree-\xthree,\ytwentythree-\ythree)}%
 \pgfmathsetmacro{\angletarget}{atan2(\xeight-\xthree,\yeight-\ythree)}%
 \fill[fill=green]  (A23) arc (\anglestart:\angletarget:\dee) -- (A13) arc (\angletarget:\anglestart:\deetwo) -- (A23);
 %\draw[step=0.1cm,gray] (-1,0) grid (15,6);
  %\draw [step=1cm] (-1,0) grid (15,6);
\coordinate (C1) at (3.4,5);
\coordinate (C2) at (4,4);
\coordinate (C3) at (5,3.6);    
\coordinate (C4) at (6,4.5);    
\coordinate (C5) at (7,4.7);
\coordinate (C6) at (8,4);
\coordinate (C7) at (8.6,3);
\coordinate (C25) at (9,2.7);    
\coordinate (C8) at (10,2.4);    
\coordinate (C9) at (11,2.8);
\coordinate (C10) at (11.5,2);    
\coordinate (C11) at (12,1);
\coordinate (C12) at (12.4,0.3);   
\coordinate (C13) at (12.6,0.3);    
\coordinate (C14) at (12.2,1);    
\coordinate (C15) at (11.7,2);
\coordinate (C16) at (11,3.1);    
\coordinate (C17) at (10,2.6);
\coordinate (C18) at (9,2.9);    
\coordinate (C26) at (8.2,4);
\coordinate (C19) at (8,4.3);
\coordinate (C20) at (7,4.9);    
\coordinate (C21) at (6,4.7);
\coordinate (C22) at (5,3.8);   
\coordinate (C23) at (4,4.2);    
\coordinate (C24) at (3.6,5);   
\filldraw plot [smooth cycle] coordinates { (C1)  (C2)  (C3) (C4) (C5) (C6) (C7) (C25) (C8) (C9) (C10)  
(C11) (C12) (C13) (C14) (C15) (C16) (C17) (C18) (C26) (C19) (C20) (C21) (C22) (C23) (C24)};
 \fill[fill=green] (A1) -- (A7) -- (A12) -- (A11) -- cycle;
% \draw [step=0.1cm] (-28,-4) grid (16,12);
%\draw [step=1cm] (-28,-4) grid (16,12);
% \draw (0,0) node {$\bullet$};
 \draw (A5)++(-20,2.5) node[scale=3] {\sf\Huge\textcolor{green}{nouveau}};
  \newcommand*{\xzed}{-140*\jay}%
  \newcommand*{\yzed}{-10*\jay}%
  \newcommand*{\xzedtwo}{50*\jay}%
  \newcommand*{\dusttwo}{20*\jay}%
 \coordinate (Z1) at (\xzed,\yzed);
 \coordinate (Z2) at (\xzedtwo,\yzed);
 \coordinate (Z3) at (\xzedtwo,\yzed+2*\dusttwo);
 \coordinate (Z4) at (\xzed,\yzed+2*\dusttwo);  
 \draw (Z1)  -- (Z2) arc(-90:90:\dusttwo) (Z3) -- (Z4) arc(90:270:\dusttwo) (Z1) ;
\end{tikzpicture}



\end{document}
user40960
  • 811
  • without \pagestyle{empty} and \noindent and using convert from command line in windows it works for me. Although the line surrounding the icon goes over the lamp(?). – Ignasi Oct 23 '14 at 17:58
  • Don't use \sf. It was deprecated 20 years ago. Use \sffamily or \textsf{} instead. – cfr Oct 23 '14 at 18:18
  • @Ignasi "the line surrounding the icon goes over the lamp" is precisely the problem I want to fix. It seems using \noindent or \pagestyle{empty} changes nothing about that – user40960 Oct 23 '14 at 18:28
  • Was this code generated by another program? – John Kormylo Oct 23 '14 at 21:29
  • @JohnKormylo This one wasn't, though I do use programs sometimes to generate some TikZ code – user40960 Oct 24 '14 at 05:30
  • Therefore the problem is your TiKZ code and not standalone's clipping capability. – Ignasi Oct 24 '14 at 06:40

1 Answers1

2

Do you want something like this?

enter image description here

The main problem in your code was on last line

\draw (Z1)  -- (Z2) arc(-90:90:\dusttwo) (Z3) -- (Z4) arc(90:270:\dusttwo) (Z1) ;

the radius \dusttwo was to short, instead of 20*\jay I've used 22*\jay (adjust it according your taste). Your command draws two paths (Z1) -- (Z2) arc(-90:90:\dusttwo) followed by (Z3) -- (Z4) arc(90:270:\dusttwo) (Z1). There's no reason for such division, one path is enough:

 \draw (Z1)  -- (Z2) arc(-90:90:22*\jay) coordinate (aux) -- (aux-|Z1) arc(90:270:22*\jay);

Some other comments:

The code worked for me without \usepackage{calc} (don't confuse it with \usetikzlibrary{calc}, which was neither not necessary)

If you use standalone class for an isolated tikzpicture there is no need for \pagestyle{empty} and \noindent which introduced a little shift in final result.

And, if you need it, you can also introduce a border=... option in standalone which will be considered before clipping the result. I've not used here, it's just information.

\documentclass[convert={density=300,size=4600x800,outext=.png}]{standalone}
%\documentclass[a4paper]{article}

\usepackage{tikz}
%\usepackage{calc}
\begin{document}
\begin{tikzpicture}[x=0.25cm,y=0.25cm]
 % Proportionality constants
  \newcommand*{\jay}{0.25}%
  \newcommand*{\kay}{2}%
 \newcommand*{\hay}{3}%
 \newcommand*{\way}{4}%
  \newcommand*{\bay}{3.5}%
 % Fundamental coordinates of points or vectors
  \newcommand*{\xv}{-0.5*\jay}%
  \newcommand*{\yv}{2*\jay}%
  \newcommand*{\xfive}{0*\jay}%
  \newcommand*{\yfive}{0*\jay}%
  % Deduced coordinates
 \pgfmathsetmacro{\xu}{\bay*\yv}% 
 \pgfmathsetmacro{\yu}{-\bay*\xv}% 
 \pgfmathsetmacro{\xsix}{\xfive+\way*\xu}% 
 \pgfmathsetmacro{\ysix}{\yfive+\way*\yu}% 
 \pgfmathsetmacro{\xten}{\xfive+2*\xv}% 
 \pgfmathsetmacro{\yten}{\yfive+2*\yv}% 
\pgfmathsetmacro{\xeleven}{\xten+\way*\xu}% 
 \pgfmathsetmacro{\yeleven}{\yten+\way*\yu}% 
\pgfmathsetmacro{\xone}{\xsix+\xv}% 
 \pgfmathsetmacro{\yone}{\ysix+\yv}% 
\pgfmathsetmacro{\xtwo}{\xone+\xu}% 
 \pgfmathsetmacro{\ytwo}{\yone+\yu}% 
\pgfmathsetmacro{\xthree}{\xtwo+\kay*\xu}% 
 \pgfmathsetmacro{\ythree}{\ytwo+\kay*\yu}% 
\pgfmathsetmacro{\xtwentytwo}{\xtwo-\hay*\xv}% 
 \pgfmathsetmacro{\ytwentytwo}{\ytwo-\hay*\yv}% 
\pgfmathsetmacro{\xtwentythree}{\xtwentytwo+\kay*\xu}% 
 \pgfmathsetmacro{\ytwentythree}{\ytwentytwo+\kay*\yu}% 
\pgfmathsetmacro{\xseventeen}{\xtwentytwo-\xv}% 
 \pgfmathsetmacro{\yseventeen}{\ytwentytwo-\yv}% 
 \pgfmathsetmacro{\xeighteen}{\xseventeen+\kay*\xu}% 
 \pgfmathsetmacro{\yeighteen}{\yseventeen+\kay*\yu}% 
 \pgfmathsetmacro{\xseven}{\xtwo+\hay*\xv}% 
 \pgfmathsetmacro{\yseven}{\ytwo+\hay*\yv}% 
 \pgfmathsetmacro{\xeight}{\xseven+\kay*\xu}% 
 \pgfmathsetmacro{\yeight}{\yseven+\kay*\yu}% 
 \pgfmathsetmacro{\xtwelve}{\xseven+\xv}% 
 \pgfmathsetmacro{\ytwelve}{\yseven+\yv}% 
  \pgfmathsetmacro{\xthirteen}{\xtwelve+\kay*\xu}% 
 \pgfmathsetmacro{\ythirteen}{\ytwelve+\kay*\yu}% 
 \pgfmathsetmacro{\xfour}{\xthree+\hay*\yv}% 
 \pgfmathsetmacro{\yfour}{\ythree-\hay*\xv}% 
 \pgfmathsetmacro{\xnine}{\xfour+\yv}% 
 \pgfmathsetmacro{\ynine}{\yfour-\xv}% 
 \pgfmathsetmacro{\xfourteen}{\xfive+\xv-\yv}% 
 \pgfmathsetmacro{\yfourteen}{\yfive+\xv+\yv}% 
  \coordinate (A1) at (\xone,\yone);
  \coordinate (A2) at (\xtwo,\ytwo);
  \coordinate (A3) at (\xthree,\ythree);
  \coordinate (A4) at (\xfour,\yfour);
  \coordinate (A5) at (\xfive,\yfive);
  \coordinate (A6) at (\xsix,\ysix);  
  \coordinate (A7) at (\xseven,\yseven);
  \coordinate (A8) at (\xeight,\yeight);  
  \coordinate (A9) at (\xnine,\ynine);   
  \coordinate (A10) at (\xten,\yten);    
\coordinate (A11) at (\xeleven,\yeleven);    
\coordinate (A12) at (\xtwelve,\ytwelve);    
\coordinate (A13) at (\xthirteen,\ythirteen);    
\coordinate (A14) at (\xfourteen,\yfourteen);    
\coordinate (A17) at (\xseventeen,\yseventeen);   
\coordinate (A18) at (\xeighteen,\yeighteen);   
\coordinate (A22) at (\xtwentytwo,\ytwentytwo);  
\coordinate (A23) at (\xtwentythree,\ytwentythree);    
  \fill[fill=green] (A14) -- (A5) -- (A6) -- (A11) -- (A10) -- cycle;
  \fill[fill=green] (A6) -- (A17) -- (A22) -- (A1) -- cycle;
  \fill[fill=green] (A17) -- (A18) -- (A23) -- (A22) -- cycle;
 \fill[fill=green] (A7) -- (A8) -- (A13) -- (A12) -- cycle;
 %\draw (A23) -- (A4) -- (A8);
% \draw (A23) .. controls (A14) .. (A4);
 \pgfmathsetmacro{\dee}{\hay*(veclen(\xv,\yv))}% 
 \pgfmathsetmacro{\deetwo}{(\hay+1)*(veclen(\xv,\yv))}% 
 \pgfmathsetmacro{\anglestart}{atan2(\xtwentythree-\xthree,\ytwentythree-\ythree)}%
 \pgfmathsetmacro{\angletarget}{atan2(\xeight-\xthree,\yeight-\ythree)}%
 \fill[fill=green]  (A23) arc (\anglestart:\angletarget:\dee) -- (A13) arc (\angletarget:\anglestart:\deetwo) -- (A23);
 %\draw[step=0.1cm,gray] (-1,0) grid (15,6);
  %\draw [step=1cm] (-1,0) grid (15,6);
\coordinate (C1) at (3.4,5);
\coordinate (C2) at (4,4);
\coordinate (C3) at (5,3.6);    
\coordinate (C4) at (6,4.5);    
\coordinate (C5) at (7,4.7);
\coordinate (C6) at (8,4);
\coordinate (C7) at (8.6,3);
\coordinate (C25) at (9,2.7);    
\coordinate (C8) at (10,2.4);    
\coordinate (C9) at (11,2.8);
\coordinate (C10) at (11.5,2);    
\coordinate (C11) at (12,1);
\coordinate (C12) at (12.4,0.3);   
\coordinate (C13) at (12.6,0.3);    
\coordinate (C14) at (12.2,1);    
\coordinate (C15) at (11.7,2);
\coordinate (C16) at (11,3.1);    
\coordinate (C17) at (10,2.6);
\coordinate (C18) at (9,2.9);    
\coordinate (C26) at (8.2,4);
\coordinate (C19) at (8,4.3);
\coordinate (C20) at (7,4.9);    
\coordinate (C21) at (6,4.7);
\coordinate (C22) at (5,3.8);   
\coordinate (C23) at (4,4.2);    
\coordinate (C24) at (3.6,5);   
\filldraw plot [smooth cycle] coordinates { (C1)  (C2)  (C3) (C4) (C5) (C6) (C7) (C25) (C8) (C9) (C10)  
(C11) (C12) (C13) (C14) (C15) (C16) (C17) (C18) (C26) (C19) (C20) (C21) (C22) (C23) (C24)};
 \fill[fill=green] (A1) -- (A7) -- (A12) -- (A11) -- cycle;
% \draw [step=0.1cm] (-28,-4) grid (16,12);
%\draw [step=1cm] (-28,-4) grid (16,12);
% \draw (0,0) node {$\bullet$};
 \draw (A5)++(-20,2.5) node[scale=3] {\sf\Huge\textcolor{green}{nouveau}};
  \newcommand*{\xzed}{-140*\jay}%
  \newcommand*{\yzed}{-10*\jay}%
  \newcommand*{\xzedtwo}{50*\jay}%
  \newcommand*{\dusttwo}{20*\jay}%
 \coordinate (Z1) at (\xzed,\yzed);
 \coordinate (Z2) at (\xzedtwo,\yzed);
 \coordinate (Z3) at (\xzedtwo,\yzed+2*\dusttwo);
 \coordinate (Z4) at (\xzed,\yzed+2*\dusttwo);  
% \draw (Z1)  -- (Z2) arc(-90:90:\dusttwo) (Z3) -- (Z4) arc(90:270:\dusttwo) (Z1) ;
 \draw (Z1)  -- (Z2) arc(-90:90:22*\jay) coordinate (aux) -- (aux-|Z1) arc(90:270:22*\jay);
\end{tikzpicture}
\end{document}
Ignasi
  • 136,588