如何使用 tikz 绘制理发店标志牌?

如何使用 tikz 绘制理发店标志牌?

我有以下代码来绘制多条彩色线条。我不想画直线,而是想画一个包含五种颜色的细条纹的理发店立柱。

请注意,我不是在寻找任何 3D 的东西,只是对角条纹。就像这样 ///////

这看起来像这样:

在此处输入图片描述

我该怎么做呢?

\documentclass{standalone}
\usepackage{tikz}
%\usetikzlibrary{...}
\definecolor{pink}{RGB}{255,128,128} 
\definecolor{light-gray}{gray}{0.98}
\definecolor{darkgreen}{RGB}{0,64,0}
\definecolor{lightgray}{gray}{0.75}
\definecolor{lightred}{RGB}{255,160,160} 
\definecolor{lightblue}{RGB}{200,200,255}
\definecolor{lightgreen}{RGB}{170,255,170}
\definecolor{lightyellow}{RGB}{255,255,160}
\definecolor{pink}{RGB}{255,128,128} 
\definecolor{lightpurple}{RGB}{255,180,255}
\definecolor{greenblue}{RGB}{180,255,255}
\definecolor{lightorange}{RGB}{255,200,180}
\definecolor{yellowgreen}{RGB}{230,230,180}
\begin{document}
\begin{tikzpicture}

\def\opacity{0.75}
\def\xcellsa{{{"2","1","0"},{"5","4","3"},{"8","7","6"}}}

\def\bitsencoding{{
    {"","0","1","2","3","4","5","6","7","...","504","505","506","507","508","509","510","511"},
    {"0:","0","1","0","1","0","1","0","1","...","0","1","0","1","0","1","0","1"},
    {"1:","0","0","1","1","0","0","1","1","...","0","0","1","1","0","0","1","1"},
    {"2:","0","0","0","0","1","1","1","1","...","0","0","0","0","1","1","1","1"},
    {"...","...","","","","","","","","","","","","","","","",""},
    {"8:","0","0","0","0","0","0","0","0","...","1","1","1","1","1","1","1","1"},
}}

%neighbor grid
\draw[step=1,black, opacity=\opacity, fill opacity=0] (0,0) grid ({3},{3});
\draw[fill = lightred] (0,0) rectangle (1,1);
\draw[fill = lightpurple] (0,1) rectangle (1,2);
\draw[fill = lightblue] (0,2) rectangle (1,3);
\draw[fill = lightorange] (1,0) rectangle (2,1);
\draw[fill = white] (1,1) rectangle(2,2);
\draw[fill = greenblue] (1,2) rectangle (2,3);
\draw[fill = lightyellow] (2,0) rectangle (3,1);
\draw[fill = yellowgreen] (2,1) rectangle (3,2);
\draw[fill = lightgreen] (2,2) rectangle (3,3); 

\foreach \xa in {2,1,0}
\foreach \ya in {2,1,0}
{
  \node[align=center] at ({\xa+0.5},{\ya+0.5}) {\pgfmathparse{\xcellsa[2-\ya][\xa]}\pgfmathresult};
}

\node at (1.5,3.5) {pixel positions};
\node at (9.85,3.5) {encoding per constellation};
\begin{scope}[xscale = 0.7, yscale=0.5]
\fill[fill = lightgreen] (5,4) rectangle ({17+6},5);
\fill[fill = greenblue] (5,3) rectangle ({17+6},4);
\fill[fill = lightblue] (5,2) rectangle ({17+6},3);
%I want this part to be replaced with a barber pole containing the five colors
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\fill[fill = yellowgreen] (5,1.8) rectangle ({17+6},2.0);
\fill[fill = white]        (5,1.6) rectangle ({17+6},1.8);
\fill[fill = lightpurple] (5,1.4) rectangle ({17+6},1.6);
\fill[fill = lightyellow] (5,1.2) rectangle ({17+6},1.4);
\fill[fill = lightorange] (5,1) rectangle ({17+6},1.2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\fill[fill = lightred] (5,0) rectangle ({17+6},1);
%bit encoding
\foreach \ya in {5,4,3,2,1,0}
\foreach \xa in {17,16,...,0}
{
  \node[align=center] at ({\xa+5.50},{\ya+0.5}) {\pgfmathparse{\bitsencoding[5-\ya][\xa]}\pgfmathresult};  
}
\node[anchor=west] at (4.7,6.5) {pixel/constellation};
\draw[thick,->,>=stealth] (5.43, 6.1) -- (5.43, 5.2);
\draw[thick,->,>=stealth] (9.2, 6.5) -- (10.1, 6.5);

\end{scope}
\end{tikzpicture}
\end{document}

编辑
这是我使用@marmot 的答案想出的解决方案。

\documentclass{standalone}
\usepackage{tikz}
%\usetikzlibrary{...}
\definecolor{pink}{RGB}{255,128,128} 
\definecolor{light-gray}{gray}{0.98}
\definecolor{darkgreen}{RGB}{0,64,0}
\definecolor{lightgray}{gray}{0.90}
\definecolor{lightred}{RGB}{255,160,160} 
\definecolor{lightblue}{RGB}{200,200,255}
\definecolor{lightgreen}{RGB}{170,255,170}
\definecolor{lightyellow}{RGB}{255,255,160}
\definecolor{pink}{RGB}{255,128,128} 
\definecolor{lightpurple}{RGB}{255,180,255}
\definecolor{greenblue}{RGB}{180,255,255}
\definecolor{lightorange}{RGB}{255,200,180}
\definecolor{yellowgreen}{RGB}{230,230,180}
\begin{document}
\begin{tikzpicture}

\def\opacity{0.75}
\def\xcellsa{{{"2","1","0"},{"5","4","3"},{"8","7","6"}}}

\def\bitsencoding{{
    {"","0","1","2","3","4","5","6","7","...","504","505","506","507","508","509","510","511"},
    {"0:","0","1","0","1","0","1","0","1","...","0","1","0","1","0","1","0","1"},
    {"1:","0","0","1","1","0","0","1","1","...","0","0","1","1","0","0","1","1"},
    {"2:","0","0","0","0","1","1","1","1","...","0","0","0","0","1","1","1","1"},
    {"...","...","","","","","","","","","","","","","","","",""},
    {"8:","0","0","0","0","0","0","0","0","...","1","1","1","1","1","1","1","1"},
}}

%neighbor grid
\draw[step=1,black, opacity=\opacity, fill opacity=0] (0,0) grid ({3},{3});
\draw[fill = lightred] (0,0) rectangle (1,1);
\draw[fill = lightpurple] (0,1) rectangle (1,2);
\draw[fill = lightblue] (0,2) rectangle (1,3);
\draw[fill = lightorange] (1,0) rectangle (2,1);
\draw[fill = lightgray] (1,1) rectangle(2,2);
\draw[fill = greenblue] (1,2) rectangle (2,3);
\draw[fill = lightyellow] (2,0) rectangle (3,1);
\draw[fill = yellowgreen] (2,1) rectangle (3,2);
\draw[fill = lightgreen] (2,2) rectangle (3,3); 

\foreach \xa in {2,1,0}
\foreach \ya in {2,1,0}
{
  \node[align=center] at ({\xa+0.5},{\ya+0.5}) {\pgfmathparse{\xcellsa[2-\ya][\xa]}\pgfmathresult};
}


\node at (1.5,3.5) {pixel positions};
\node at (9.85,3.5) {encoding per constellation};
\begin{scope}[xscale = 0.7, yscale=0.5]
\fill[fill = lightgreen] (5,4) rectangle ({17+6},5);
\fill[fill = greenblue] (5,3) rectangle ({17+6},4);
\fill[fill = lightblue] (5,2) rectangle ({17+6},3);

%\fill[fill = yellowgreen] (5,1.8) rectangle ({17+6},2.0);
%\fill[fill = white]        (5,1.6) rectangle ({17+6},1.8);
%\fill[fill = lightpurple] (5,1.4) rectangle ({17+6},1.6);
%\fill[fill = lightyellow] (5,1.2) rectangle ({17+6},1.4);
%\fill[fill = lightorange] (5,1) rectangle ({17+6},1.2);
\fill[fill = lightred] (5,0) rectangle ({17+6},1);
%bit encoding
\foreach \ya in {5,4,3,2,1,0}
\foreach \xa in {17,16,...,0}
{
  \node[align=center] at ({\xa+5.50},{\ya+0.5}) {\pgfmathparse{\bitsencoding[5-\ya][\xa]}\pgfmathresult};  
}
\node[anchor=west] at (4.7,6.5) {pixel/constellation};
\draw[thick,->,>=stealth] (5.43, 6.1) -- (5.43, 5.2);
\draw[thick,->,>=stealth] (9.2, 6.5) -- (10.1, 6.5);

\clip(5,1) rectangle ({17+6},2);
\foreach \Q in {0,1,2,3,4,5,6,7}
\foreach \X [count=\Y] in
{yellowgreen,lightgray,lightpurple,lightyellow,lightorange}
{\draw[color=\X,line width=4mm] (\Y*0.6+\Q*3+1,0.1) -- ++(0.9,2.5);}
\foreach \ya in {1}
\foreach \xa in {17,16,...,0}
{
  \node[align=center] at ({\xa+5.50},{\ya+0.5}) {\pgfmathparse{\bitsencoding[5-\ya][\xa]}\pgfmathresult};  
}


\end{scope}
\end{tikzpicture}
\end{document}

答案1

实现这种事情绝对很简单。但是请注意,我从您的 MWE 中唯一使用的就是一些颜色。这是因为我不知道理发店的立柱应该扮演什么角色。

\documentclass[tikz,border=3.14mm]{standalone}
\definecolor{pink}{RGB}{255,128,128} 
\definecolor{light-gray}{gray}{0.98}
\definecolor{darkgreen}{RGB}{0,64,0}
\definecolor{lightgray}{gray}{0.75}
\definecolor{lightred}{RGB}{255,160,160} 
\definecolor{lightblue}{RGB}{200,200,255}
\definecolor{lightgreen}{RGB}{170,255,170}
\definecolor{lightyellow}{RGB}{255,255,160}
\definecolor{pink}{RGB}{255,128,128} 
\definecolor{lightpurple}{RGB}{255,180,255}
\definecolor{greenblue}{RGB}{180,255,255}
\definecolor{lightorange}{RGB}{255,200,180}
\definecolor{yellowgreen}{RGB}{230,230,180}
\begin{document}
\begin{tikzpicture}
\clip(0,0) rectangle (2.5,1);
\foreach \X [count=\Y] in
{pink,darkgreen,lightred,lightblue,lightgreen,lightyellow,pink,lightpurple}
{\draw[color=\X,line width=4mm] (\Y*4mm-8mm,-0.1) -- ++(0.5,1.2);}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容