samcarter
This problem came up in https://github.com/josephwright/beamer/issues/718 . In other colour models (like rgb, gray etc.) the following code would result in a transparent rectangle. However in cmyk it results in a baby pink shape.

Is there any way to create a transparent fading in cmyk?


\documentclass{standalone}

\usepackage{pgf}
\selectcolormodel{cmyk}

color(0ex)=(pgftransparent!100);%
color(1ex)=(pgftransparent!100)
}

\begin{document}

\fbox{\begin{pgfpicture}
\pgfsetfillcolor{red}%
\pgfpathrectangle{\pgfpoint{0pt}{-1ex}}{\pgfpoint{3cm}{1.2ex}}%
\pgfusepath{fill}%
\end{pgfpicture}}

\end{document}


![document.png](/image?hash=0b21d0f45e94361d9201699c5f2f91ce3e052f9744ea54f2bd83572b6501016e)
samcarter
@zauguin explains where the problem comes from:

> At least for pdf.js and Poppler's cairo backend the underlying issue is that Luminosity softmasks are always calculated in RGB (independent of the colorspace specified for the transparency group) and the used CMYK to RGB conversion does not preserve black.

(quote from https://github.com/pgf-tikz/pgf/issues/1057#issuecomment-939081615)

Thankfully @hmenke and @dcpurton had a suggestion for a workaround: one can use another color model for defining the fading.

The following hack seems to work fine:


\documentclass{standalone}

\usepackage{pgf}
\selectcolormodel{cmyk}

{
\selectcolormodel{gray}
color(0ex)=(pgftransparent!0);%
color(1ex)=(pgftransparent!100)
}
}

\begin{document}

\fbox{\begin{pgfpicture}
\pgfsetfillcolor{red}%
\pgfpathrectangle{\pgfpoint{0pt}{-1ex}}{\pgfpoint{3cm}{2ex}}%

![document.png](/image?hash=6e3d97271a4953e2964ca250d6893a507c806f008f3e55b3fad79518460fb199)