![LaTeX/TikZ 中针对色盲的 ColorADD 符号/代码或其他解决方案](https://linux22.com/image/479941/LaTeX%2FTikZ%20%E4%B8%AD%E9%92%88%E5%AF%B9%E8%89%B2%E7%9B%B2%E7%9A%84%20ColorADD%20%E7%AC%A6%E5%8F%B7%2F%E4%BB%A3%E7%A0%81%E6%88%96%E5%85%B6%E4%BB%96%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88.png)
由于我今年有一名学生无法辨别颜色,所以我认为这可能也是其他人遇到的问题。我能想到的最明显的问题是“他怎么能玩 UNO?”... 而且 UNO 有一个版本,使用由颜色添加来提供帮助。
我找不到任何可以在图形中使用的与 LaTeX/TikZ 等效的东西(例如,如果我绘制一些图形并希望学生告诉我函数,我通常会使用不同的颜色和/或不同的字母。在我的生物学图中,它们通常是彩色的,但由于这不再起作用,我使用了图案)。
但这些是我的解决方案,而 ColorADD 提供的系统似乎更大。
我的问题:有人知道一种常用的通过符号识别/翻译颜色的同等方法吗?还有其他方法可以帮助我完全看不到任何颜色的学生吗?
PS:我遇到了保罗·托尔但这似乎只对红盲或绿盲有用。对我的学生来说,这些都是不同类型的灰色,所以他更喜欢黑白的高对比度解决方案。
答案1
欢迎!可以定义pics
这些符号。这之所以微妙/有趣,是因为组件的颜色和位置取决于是否存在其他组件。本提案通过首先开始调查然后绘制组件来解决这个问题。这样,如果你说
\pic{ADD={red,white,blue}};
你会得到
而如果你添加yellow
,
\pic{ADD={red,white,blue,yellow}};
你得到
如果你white
替换black
这是包含以下及更多示例的完整代码:
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{backgrounds}
\makeatletter% https://tex.stackexchange.com/a/515305/194703
\tikzset{scale line widths/.style={%
/utils/exec=\pgfgettransformentries{\tmpa}{\tmpb}{\tmpc}{\tmpd}{\tmp}{\tmp}%
\pgfmathsetmacro{\myJacobian}{sqrt(abs(\tmpa*\tmpd-\tmpb*\tmpc))}%
\pgfmathsetlength\pgflinewidth{\myJacobian*0.4pt}%
\def\tikz@semiaddlinewidth##1{\pgfmathsetmacro{\my@lw}{\myJacobian*##1}%
\tikz@addoption{\pgfsetlinewidth{\my@lw pt}}\pgfmathsetlength\pgflinewidth{\my@lw pt}},%
thin}}
\makeatother
\newif\ifADDcontainsyellow
\newif\ifADDcontainsblack
\tikzset{pics/ADD/.style={code={
\tikzset{ADD survey/.cd,#1}
\tikzset{ADD/.cd,#1}
}},
/tikz/ADD survey/.cd,
white/.code={},blue/.code={},red/.code={},
yellow/.code={\ADDcontainsyellowtrue},black/.code={\ADDcontainsblacktrue},
/tikz/ADD/.cd,
white/.code={\draw[rounded corners=3pt,scale line widths,line width=0.6mm]
(-0.47,-0.47) rectangle (0.47,0.47);},
black/.code={\begin{scope}[on background layer]
\fill[black] [rounded corners=3pt] (-0.5,-0.5) rectangle (0.5,0.5);
\end{scope}},
red/.code={\fill[rounded corners=1.8pt] \ifADDcontainsblack [white]\fi
(-0.3,-0.25) \ifADDcontainsyellow ++(120:0.1) \fi
|- ++ (0.5,0.5) --
cycle;},
blue/.code={\fill[rounded corners=1.8pt] \ifADDcontainsblack [white]\fi
(-0.2,-0.25) \ifADDcontainsyellow ++(-60:0.1) \fi -| ++ (0.5,0.5) --
cycle;},
yellow/.code={\draw[line cap=round,scale line widths,line width=0.7mm]
\ifADDcontainsblack [white]\fi (-0.35,-0.35) -- (0.35,0.35);}}
\begin{document}
\begin{tikzpicture}
\path pic{ADD={red,white,blue}}
(1.5,0) pic{ADD={red,white,blue,yellow}}
(3,0) pic{ADD={red,black,blue}}
(4.5,0) pic{ADD={blue,yellow,red,black}}
(6,0) pic{ADD={red,blue}};
\end{tikzpicture}
\end{document}
正如你所见,
\path (<x>,<y>) pic{ADD=...};
您将符号移动到坐标。前言的某些部分只是为了确保可扩展性。
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{backgrounds,venn}
\makeatletter% https://tex.stackexchange.com/a/515305/194703
\tikzset{scale line widths/.style={%
/utils/exec=\pgfgettransformentries{\tmpa}{\tmpb}{\tmpc}{\tmpd}{\tmp}{\tmp}%
\pgfmathsetmacro{\myJacobian}{sqrt(abs(\tmpa*\tmpd-\tmpb*\tmpc))}%
\pgfmathsetlength\pgflinewidth{\myJacobian*0.4pt}%
\def\tikz@semiaddlinewidth##1{\pgfmathsetmacro{\my@lw}{\myJacobian*##1}%
\tikz@addoption{\pgfsetlinewidth{\my@lw pt}}\pgfmathsetlength\pgflinewidth{\my@lw pt}},%
thin}}
\makeatother
\newif\ifADDcontainsyellow
\newif\ifADDcontainsblack
\tikzset{pics/ADD/.style={code={
\tikzset{ADD survey/.cd,#1}
\tikzset{ADD/.cd,#1}
}},
/tikz/ADD survey/.cd,
white/.code={},blue/.code={},red/.code={},
yellow/.code={\ADDcontainsyellowtrue},black/.code={\ADDcontainsblacktrue},
/tikz/ADD/.cd,
white/.code={\draw[rounded corners=3pt,scale line widths,line width=0.6mm]
(-0.47,-0.47) rectangle (0.47,0.47);},
black/.code={\begin{scope}[on background layer]
\fill[black] [rounded corners=3pt] (-0.5,-0.5) rectangle (0.5,0.5);
\end{scope}},
red/.code={\fill[rounded corners=1.8pt] \ifADDcontainsblack [white]\fi
(-0.3,-0.25) \ifADDcontainsyellow ++(120:0.1) \fi
|- ++ (0.5,0.5) --
cycle;},
blue/.code={\fill[rounded corners=1.8pt] \ifADDcontainsblack [white]\fi
(-0.2,-0.25) \ifADDcontainsyellow ++(-60:0.1) \fi -| ++ (0.5,0.5) --
cycle;},
yellow/.code={\draw[line cap=round,scale line widths,line width=0.7mm]
\ifADDcontainsblack [white]\fi (-0.35,-0.35) -- (0.35,0.35);}}
\begin{document}
\begin{tikzpicture}[Venn diagram={offset angle=60,
all labels/.style={opacity=0},
radius=1.4cm,distance=1cm}]
\begin{scope}
\clip[current reverse clip,venn/set=A];
\clip[current reverse clip,venn/set=B];
\fill[red,venn/set=C];
\end{scope}
\begin{scope}
\clip[current reverse clip,venn/set=C];
\clip[current reverse clip,venn/set=A];
\fill[blue,venn/set=B];
\end{scope}
\begin{scope}
\clip[current reverse clip,venn/set=B];
\clip[current reverse clip,venn/set=C];
\fill[yellow,venn/set=A];
\end{scope}
\path[fill=green,venn/and={A and B}];
\path[fill=orange,venn/and={A and C}];
\path[fill=purple,venn/and={B and C}];
\begin{scope}
\clip[venn/set=A];
\clip[venn/set=B];
\fill[venn/set=C];
\end{scope}
\path[scale=0.7,transform shape] (-150:2) pic{ADD={yellow}}
(-30:2) pic{ADD={blue}} (90:2) pic{ADD={red}}
(-90:1.3) pic{ADD={yellow,blue}}
(150:1.3) pic{ADD={yellow,red}}
(30:1.3) pic{ADD={blue,red}} ;
\end{tikzpicture}
\end{document}