My question is related to Wind power and tikz force.
Thanks to Mark Wibrow I have some nice wind turbines, but I want to scale them and make some dynamic changes. I try to had some new parameters, but it doesn' work. I just add to his original code:
\tikzset{path/.style args={#1 scale #2}{fill, draw=white, ultra thick, line join=round}}
\begin{scope}[scale=#2]
\path [path]
(-.25,0) arc (180:360:.25 and .0625) -- (.0625,3) -- (-.0625,3) -- cycle;
...
\end{scope}
and
It's not working:
<argument> ...set {path/.style args={##1 scale ##2
}{fill, draw=white, ultra ...
l.418 }}
Edit Solved thanks to Ignasi:
\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{calc}
\tikzset{
pics/mysymbol/.style args={#1 scale #2 with #3}{
code={
\tikzset{WinT/.style={%
fill,draw=white,line join=round,#3}}
\begin{scope}[scale=#2]
\path[WinT] (-.25,0) arc (180:360:.25 and .0625)
-- (.0625,3) -- (-.0625,3) -- cycle;
\pgfmathsetmacro{\Rand}{(rand*60 + 1) - 30}
\foreach \i in {90, 210, 330}{
\ifcase#1
\or
\path [WinT, shift=(90:3), rotate=\i+\Rand]
(.5,-.1875) arc (270:90:.5 and .1875)
arc (90:-90:1.5 and .1875);
\or
\path [WinT, shift=(90:3), rotate=\i+\Rand]
(0,0.125) -- (2,0.125) -- (2,0) -- (0.5,-0.375) -- cycle;
\or
\path [WinT, shift=(90:3), rotate=\i+\Rand]
(0,-0.125) arc (180:0:1 and 0.125) -- ++(0,0.125)
arc (0:180:1 and 0.25) -- cycle;
\fi
}
\path [WinT] (0,3) circle [radius=.25];
\end{scope}
}}}
\begin{document}
\begin{tikzpicture}[scale=0.4]
\draw[help lines] (0,-2) grid (20,20) ;
\draw[fill=blue!50, opacity=.5] (1,0) arc (180:90:18) -- ++(0,-2)
arc (90:180:16) --cycle ;
\draw[<->,>=stealth,thick] (1,-1)--(3,-1) node[midway,below]
{\scriptsize 200\,m} ;
\foreach \i in {13,12,...,0} {%
\begin{scope}[shift={($(19,0) + (176-\i*6.35:16.9)$)}]
\path (0,0) pic {mysymbol={1 scale .25 with thick}} ;
\end{scope}
}
\end{tikzpicture}\end{document}
pics
with parameters are declared, a special declaration is needed. Instead ofwind turbine/.pic
you must usepics/wind turbine/.style={code={...
An example: How to create something like a function (procedure, macros, etc.) in TikZ?path
style requires arguments but you are not providing any in the required form such aspath=1 scale 2