PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Tikz circuits einzelne Bauteile Farbig



Fretschi
08-10-2023, 22:07
Moin,

habe jetzt eine etwas spezielle Frage. Die pgfmanual doku hat keine Lösung parat, aber vielleicht jemand von euch!

Wie bekomme ich nur einzelne Spulen in BrickRed gefärbt?

Sorry dass es soviel an Code ist.

Danke für Hilfe

Grüße Fretschi



\documentclass[ paper=a4,
BCOR = 12mm,
pointlessnumbers,
DIV=15
]
{scrbook} %scrartcl, scrreprt, scrbook
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{charter}
\usepackage[onehalfspacing]{setspace}
\usepackage{graphicx}
\usepackage[table,xcdraw,dvipsnames]{xcolor}
\usepackage[europeanvoltages,europeanresistors,americaninducto rs,siunitx]{circuitikz}
\usetikzlibrary{matrix}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{positioning,quotes}
\usetikzlibrary{circuits.ee.IEC}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary {decorations.pathreplacing}
\usetikzlibrary {patterns,patterns.meta}
\newcommand\spiral{}% Just for safety so \def won't overwrite something
\def\spiral[#1](#2)(#3:#4:#5){% \spiral[draw options](placement)(end angle:revolutions:final radius)
\pgfmathsetmacro{\domain}{pi*#3/180+#4*2*pi}
\draw [#1,shift={(#2)}, domain=0:\domain,variable=\t,smooth,samples=int(\d omain/0.08)] plot ({\t r}: {#5*\t/\domain})
}
\tikzstyle{background rectangle}=
[thick,draw=\lightgray, fill=white!99!black, rounded corners]
\tikzset{
Pfeil/.style={thick,shorten >=#1,shorten <=#1,->}, % für Peile
UPfeil/.style={blue,Pfeil=#1,font={\sffamily\itshape}},% für Spannungspfeile
IPfeil/.style={red,Pfeil=#1,font={\ttfamily\itshape}} % für Strompfeile
}
\tikzset{circuit declare symbol = ammeter}
\tikzset{set ammeter graphic ={draw,generic circle IEC, minimum size=5mm,info=center:A}}
%
\tikzset{circuit declare symbol = voltmeter}
\tikzset{set voltmeter graphic ={draw,generic circle IEC, minimum size=5mm,info=center:V}}

\begin{document}

\begin{tikzpicture}[%show background rectangle,
circuit ee IEC, circuit symbol lines/.style={draw,thick},
font=\sffamily\upshape,
>=latex, % Voreinstellung für Pfeilspitzen
scale=0.8
]
\matrix (S) [
matrix of nodes, nodes in empty cells,
inner sep=0pt, outer sep=-.5\pgflinewidth,
column sep=7mm, row sep = 7mm,
nodes={minimum width=0pt}
]
{
&&&&&&&&&&&&&&&&&& \\
&&&&&&&&&&&&&&&&&& \\
&&&&&&&&&&&&&&&&&& \\
&&&&&&&&&&&&&&&&&& \\
&&&&&&&&&&&&&&&&&& \\
&&&&&&&&&&&&&&&&&& \\
};

%Orientierungshilfen
%\foreach \zeilen in {1,...,5}
% \foreach \spalten in {1,...,19}{%
%\node at (S-\zeilen-\spalten){+}; % Orientierungshilfe +
%\node[red, left] at (S-\zeilen-1){\zeilen}; %Orientierungshilfe Zeilennummer
%\node[red, above] at (S-1-\spalten){\spalten}; %Orientierungshilfe Spaltennummer
%};%

\draw (S-2-1) -- (S-2-3) to [inductor={info={},info'={$\mathsf{_{}}$}}] (S-4-3) -- (S-4-1);
\draw (S-3-1) node{230 V $\approx$};

\draw (S-2-8) to [diode={info={},info'={}}]
(S-3-9) to [diode={info={},info'={}}]
(S-4-8) to [diode={info={},info'={}}]
(S-3-7) to [diode={info={},info'={}}]
(S-2-8);

\draw (S-1-5) node{
\begin{tikzpicture}
\draw[LimeGreen,-latex] (0,-0.5) --++ (0,1);
\draw[LimeGreen,-latex] (0,0) --++ (1.25,0);
\draw[LimeGreen] (0,0) sin++(0.25,0.25) cos++(0.25,-.25) sin++ (0.25,-0.25) cos++(0.25,.25);
\draw[BrickRed] (0.25,0.125)node{$+$};
\draw[Blue] (0.75,-0.125)node{$-$};
\end{tikzpicture}
};

\draw (S-5-5) node{
\begin{tikzpicture}
\draw[LimeGreen,-latex] (0,-0.5) --++ (0,1);
\draw[LimeGreen,-latex] (0,0) --++ (1.25,0);
\draw[LimeGreen] (0,0) sin++(0.25,-0.25) cos++(0.25,.25) sin++ (0.25,0.25) cos++(0.25,-.25);
\draw[blue] (0.25,-0.125)node{$-$};
\draw[BrickRed] (0.75,0.125)node{$+$};
\end{tikzpicture}
};

\draw (S-2-8) -- ([yshift=-1.2em]S-1-8.center) -- ([yshift=-1.2em]S-1-6.center) -- (S-2-6) -- (S-2-4) to [inductor={info={},info'={$\mathsf{_{}}$}}] (S-4-4) -- (S-4-6) -- ([yshift=-1.2em]S-4-6.center) -- ([yshift=-1.2em]S-4-8.center) -- (S-4-8);

\draw (S-3-7) -- (S-5-7) -- (S-5-10) -- (S-4-10) -- (S-4-14) to [capacitor={info={},info'={}}] (S-2-14) -- (S-2-8);

\draw (S-5-12) node{
\begin{tikzpicture}
\draw[blue,-latex] (0,0) --++ (0,-0.5);
\draw[blue,-latex] (0,0) --++ (1.25,0);
\draw[blue] (0,0) sin++(0.25,-0.25) cos++(0.25,.25) sin++ (0.25,-0.25) cos++(0.25,.25);
\draw[blue] (0.25,-0.125)node{$-$};
\draw[blue] (0.75,-0.125)node{$-$};
\end{tikzpicture}
};
\draw (S-1-12) node{
\begin{tikzpicture}
\draw[BrickRed,-latex] (0,0) --++ (0,0.5);
\draw[BrickRed,-latex] (0,0) --++ (1.25,0);
\draw[BrickRed] (0,0) sin++(0.25,0.25) cos++(0.25,-.25) sin++ (0.25,0.25) cos++(0.25,-.25);
\draw[BrickRed] (0.25,0.125)node{$+$};
\draw[BrickRed] (0.75,0.125)node{$+$};
\end{tikzpicture}
};

%Die folgenden beiden Spulen bitte in BrickRed
\draw[BrickRed] (S-2-13) to [inductor, ={info={},info'={}}] (S-2-11);
\draw[BrickRed] (S-4-13) to [inductor,style={red}, ={info={},info'={$\mathsf{_{}}$}}] (S-4-11);

\draw (S-2-14) -- (S-2-17) to [resistor={info'={},info'={}}] (S-4-17) -- (S-4-14);

\draw[fill=black] (S-2-8) circle (2pt)
(S-4-8) circle (2pt)
(S-3-7) circle (2pt)
(S-2-14) circle (2pt)
(S-4-14) circle (2pt)
;
\draw (S-3-18) node[anchor=west] {
\begin{tikzpicture}
\draw[Mulberry,-latex] (0,0) --++ (2.25,0);
\draw[Mulberry,-latex] (0,0) --++ (0,1.25);

\draw[Mulberry,dashed] (0,0.5) sin++(0.5,0.5) cos++ (0.5,-1) sin++ (0.5,1) cos++(0.5,-1) ;
\draw[Mulberry] (0,0.5) sin++(0.5,0.5) cos++ (0.75,-0.25) sin++ (0.25,0.25) cos++(0.75,-0.25) ;
\end{tikzpicture}
};
\end{tikzpicture}
\end{document}

klops
09-10-2023, 10:07
Einfach color=BrickRed bei den Parametern des inductor ergänzen, wobei man color= auch weglassen und einfach nur BrickRed angeben kann.


\documentclass[ paper=a4,% ist Voreinstellung und damit überflüssig
BCOR = 12mm,
numbers=noenddot,% pointlessnumbers ist veraltet und sollte
% nicht mehr verwendet werden (siehe ggf. die
% Warnung in der log-Datei):
DIV=15
]
{scrbook} %scrartcl, scrreprt, scrbook
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}% Wird seit LaTeX 2018/04/01 nicht mehr benötigt
\usepackage{charter}
\usepackage[onehalfspacing]{setspace}% Vielleicht besser setspaceenhanced verwenden.
\usepackage{graphicx}
\usepackage[table,xcdraw,dvipsnames]{xcolor}
\usepackage[europeanvoltages,europeanresistors,americaninducto rs,siunitx]{circuitikz}
\usetikzlibrary{matrix}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{positioning,quotes}
\usetikzlibrary{circuits.ee.IEC}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary {decorations.pathreplacing}
\usetikzlibrary {patterns,patterns.meta}
\newcommand\spiral{}% Just for safety so \def won't overwrite something
\def\spiral[#1](#2)(#3:#4:#5){% \spiral[draw options](placement)(end angle:revolutions:final radius)
\pgfmathsetmacro{\domain}{pi*#3/180+#4*2*pi}
\draw [#1,shift={(#2)}, domain=0:\domain,variable=\t,smooth,samples=int(\d omain/0.08)] plot ({\t r}: {#5*\t/\domain})
}
\tikzstyle{background rectangle}=
[thick,draw=\lightgray, fill=white!99!black, rounded corners]
\tikzset{
Pfeil/.style={thick,shorten >=#1,shorten <=#1,->}, % für Peile
UPfeil/.style={blue,Pfeil=#1,font={\sffamily\itshape}},% für Spannungspfeile
IPfeil/.style={red,Pfeil=#1,font={\ttfamily\itshape}} % für Strompfeile
}
\tikzset{circuit declare symbol = ammeter}
\tikzset{set ammeter graphic ={draw,generic circle IEC, minimum size=5mm,info=center:A}}
%
\tikzset{circuit declare symbol = voltmeter}
\tikzset{set voltmeter graphic ={draw,generic circle IEC, minimum size=5mm,info=center:V}}

\begin{document}

\begin{tikzpicture}[%show background rectangle,
circuit ee IEC, circuit symbol lines/.style={draw,thick},
font=\sffamily\upshape,
>=latex, % Voreinstellung für Pfeilspitzen
scale=0.8
]
\matrix (S) [
matrix of nodes, nodes in empty cells,
inner sep=0pt, outer sep=-.5\pgflinewidth,
column sep=7mm, row sep = 7mm,
nodes={minimum width=0pt}
]
{
&&&&&&&&&&&&&&&&&& \\
&&&&&&&&&&&&&&&&&& \\
&&&&&&&&&&&&&&&&&& \\
&&&&&&&&&&&&&&&&&& \\
&&&&&&&&&&&&&&&&&& \\
&&&&&&&&&&&&&&&&&& \\
};

%Orientierungshilfen
%\foreach \zeilen in {1,...,5}
% \foreach \spalten in {1,...,19}{%
%\node at (S-\zeilen-\spalten){+}; % Orientierungshilfe +
%\node[red, left] at (S-\zeilen-1){\zeilen}; %Orientierungshilfe Zeilennummer
%\node[red, above] at (S-1-\spalten){\spalten}; %Orientierungshilfe Spaltennummer
%};%

\draw (S-2-1) -- (S-2-3) to [inductor={info={},info'={$\mathsf{_{}}$}}] (S-4-3) -- (S-4-1);
\draw (S-3-1) node{230 V $\approx$};

\draw (S-2-8) to [diode={info={},info'={}}]
(S-3-9) to [diode={info={},info'={}}]
(S-4-8) to [diode={info={},info'={}}]
(S-3-7) to [diode={info={},info'={}}]
(S-2-8);

\draw (S-1-5) node{
\begin{tikzpicture}
\draw[LimeGreen,-latex] (0,-0.5) --++ (0,1);
\draw[LimeGreen,-latex] (0,0) --++ (1.25,0);
\draw[LimeGreen] (0,0) sin++(0.25,0.25) cos++(0.25,-.25) sin++ (0.25,-0.25) cos++(0.25,.25);
\draw[BrickRed] (0.25,0.125)node{$+$};
\draw[Blue] (0.75,-0.125)node{$-$};
\end{tikzpicture}
};

\draw (S-5-5) node{
\begin{tikzpicture}
\draw[LimeGreen,-latex] (0,-0.5) --++ (0,1);
\draw[LimeGreen,-latex] (0,0) --++ (1.25,0);
\draw[LimeGreen] (0,0) sin++(0.25,-0.25) cos++(0.25,.25) sin++ (0.25,0.25) cos++(0.25,-.25);
\draw[blue] (0.25,-0.125)node{$-$};
\draw[BrickRed] (0.75,0.125)node{$+$};
\end{tikzpicture}
};

\draw (S-2-8) -- ([yshift=-1.2em]S-1-8.center) -- ([yshift=-1.2em]S-1-6.center) -- (S-2-6) -- (S-2-4) to [inductor={info={},info'={$\mathsf{_{}}$}}] (S-4-4) -- (S-4-6) -- ([yshift=-1.2em]S-4-6.center) -- ([yshift=-1.2em]S-4-8.center) -- (S-4-8);

\draw (S-3-7) -- (S-5-7) -- (S-5-10) -- (S-4-10) -- (S-4-14) to [capacitor={info={},info'={}}] (S-2-14) -- (S-2-8);

\draw (S-5-12) node{
\begin{tikzpicture}
\draw[blue,-latex] (0,0) --++ (0,-0.5);
\draw[blue,-latex] (0,0) --++ (1.25,0);
\draw[blue] (0,0) sin++(0.25,-0.25) cos++(0.25,.25) sin++ (0.25,-0.25) cos++(0.25,.25);
\draw[blue] (0.25,-0.125)node{$-$};
\draw[blue] (0.75,-0.125)node{$-$};
\end{tikzpicture}
};
\draw (S-1-12) node{
\begin{tikzpicture}
\draw[BrickRed,-latex] (0,0) --++ (0,0.5);
\draw[BrickRed,-latex] (0,0) --++ (1.25,0);
\draw[BrickRed] (0,0) sin++(0.25,0.25) cos++(0.25,-.25) sin++ (0.25,0.25) cos++(0.25,-.25);
\draw[BrickRed] (0.25,0.125)node{$+$};
\draw[BrickRed] (0.75,0.125)node{$+$};
\end{tikzpicture}
};

%Die folgenden beiden Spulen bitte in BrickRed
\draw[BrickRed] (S-2-13) to [inductor={color=BrickRed,info={},info'={}}] (S-2-11);
\draw[BrickRed] (S-4-13) to [inductor={BrickRed,info={},info'={$\mathsf{_{}}$}}] (S-4-11);

\draw (S-2-14) -- (S-2-17) to [resistor={info'={},info'={}}] (S-4-17) -- (S-4-14);

\draw[fill=black] (S-2-8) circle (2pt)
(S-4-8) circle (2pt)
(S-3-7) circle (2pt)
(S-2-14) circle (2pt)
(S-4-14) circle (2pt)
;
\draw (S-3-18) node[anchor=west] {
\begin{tikzpicture}
\draw[Mulberry,-latex] (0,0) --++ (2.25,0);
\draw[Mulberry,-latex] (0,0) --++ (0,1.25);

\draw[Mulberry,dashed] (0,0.5) sin++(0.5,0.5) cos++ (0.5,-1) sin++ (0.5,1) cos++(0.5,-1) ;
\draw[Mulberry] (0,0.5) sin++(0.5,0.5) cos++ (0.75,-0.25) sin++ (0.25,0.25) cos++(0.75,-0.25) ;
\end{tikzpicture}
};
\end{tikzpicture}
\end{document}


BTW: Zur Markierung von LaTeX-Code besser nicht den Button für PHP-Code, sondern den #-Button für Code verwenden.

Fretschi
09-10-2023, 10:47
Cool :-)

läuft.

Danke!