I would like to draw an orange box with green diagonal stripes in it, where the whole thing should be a bit transparent. I used this as a baseline for creating the pattern. Now, I'm wondering, why the green stripes do not get transparent if I write opacity=0.35
as in the last line of the tikzpicture-block. I already tried to define my own transparent green color like this:
\definecolor{my_green_opac}{RGBA}{181,230,29,0.35};
But then I get an error. I already had a look at the xcolor package, but it seems like there is no RGBA definition. Is there another way to get the stripes as transparent as the orange box?
\documentclass{scrbook}
\usepackage{tikz}
\usepackage{tkz-graph}
%\usepackage{tikz,fullpage}
\usetikzlibrary{arrows,arrows.meta, matrix, shapes, calc, fit, decorations.pathmorphing, quotes, shadows,intersections, patterns}
%\usepackage{tkz-berge}
\usepackage{mwe,tikz}\usepackage[percent]{overpic}
% defining the new dimensions and parameters
\newlength{\hatchspread}
\newlength{\hatchthickness}
\newlength{\hatchshift}
\newcommand{\hatchcolor}{}
% declaring the keys in tikz
\tikzset{hatchspread/.code={\setlength{\hatchspread}{#1}},
hatchthickness/.code={\setlength{\hatchthickness}{#1}},
hatchshift/.code={\setlength{\hatchshift}{#1}},% must be >= 0
hatchcolor/.code={\renewcommand{\hatchcolor}{#1}}}
% setting the default values
\tikzset{hatchspread=3pt,
hatchthickness=0.4pt,
hatchshift=0pt,% must be >= 0
hatchcolor=black}
% declaring the pattern
\pgfdeclarepatternformonly[\hatchspread,\hatchthickness,\hatchshift,\hatchcolor]% variables
{custom north west lines}% name
{\pgfqpoint{\dimexpr-2\hatchthickness}{\dimexpr-2\hatchthickness}}% lower left corner
{\pgfqpoint{\dimexpr\hatchspread+2\hatchthickness}{\dimexpr\hatchspread+2\hatchthickness}}% upper right corner
{\pgfqpoint{\dimexpr\hatchspread}{\dimexpr\hatchspread}}% tile size
{% shape description
\pgfsetlinewidth{\hatchthickness}
\pgfpathmoveto{\pgfqpoint{0pt}{\dimexpr\hatchspread+\hatchshift}}
\pgfpathlineto{\pgfqpoint{\dimexpr\hatchspread+0.15pt+\hatchshift}{-0.15pt}}
\ifdim \hatchshift > 0pt
\pgfpathmoveto{\pgfqpoint{0pt}{\hatchshift}}
\pgfpathlineto{\pgfqpoint{\dimexpr0.15pt+\hatchshift}{-0.15pt}}
\fi
\pgfsetstrokecolor{\hatchcolor}
% \pgfsetdash{{1pt}{1pt}}{0pt}% dashing cannot work correctly in all situation this way
\pgfusepath{stroke}
}
%---------------------------------------------------------
\def\cHeight{0.5}
\def\cWidth{4}
\newcommand{\cigarOne}[2]{
\pgfmathtruncatemacro\result{\cWidth/2}
\fill[draw=orange,pattern=north east lines,pattern color=black, pattern width= 4pt, opacity=0.35] (#1,#2) rectangle (\result+#1,#2-\cHeight);
% \filldraw[pattern=crosshatch dots] (\result+#1,#2) rectangle (#1+\cWidth,#2-\cHeight);
}
%---------------------------------------------------------
\begin{document}
\begin{tikzpicture}
\definecolor{my_orange}{RGB}{243, 171, 0};
\definecolor{my_green}{RGB}{181,230,29};
\draw[preaction={fill=my_orange, opacity=0.35},pattern=custom north west lines,hatchspread=10pt,hatchcolor=my_green, hatchthickness=3pt, opacity=0.35] (0,0) rectangle +(3,4);
\end{tikzpicture}
\end{document}