# Scaling color in PStricks?

Is there a way to scale/remap/transform the colors in a pstricks picture?

More detailed: I have some pstricks code which uses grayscale colors. I want to remap the colors from [0,1] to [a,b], where 0 <= a <= b <= 1.

Obviously I can do any geometrical transformation, like:

\rput(0,0) % translating...
{
\psscalebox{0.166} % scaling...
{
\psset{xunit=.5pt,yunit=.5pt,runit=.5pt} % changing units...
\pspicture*(725,725)
\input{./somepstricks.tex} % including alien pstricks-code
\endpspicture%
}
}


But how can I add a color transformation on somepstricks.tex here as well?

• I could overlay the picture with two transparent black and white layers and achieve any combination of a and b (using opacity property). Problem: In general, it is hard to exactly overlay the elements from somepstricks.tex and nothing else. In the case I don't know the content of the external code, I don't even see a way to realize this.
• Although I don't need it at this point, I would admire some additional features:
• including color remapping (not only gray scale)
• supporting non-linear remapping
• allowing saturation, i.e. allow for a < 0 and b > 1
-
Please always post full documents not just fragments, that allow people to test possible answers. – David Carlisle Apr 4 '14 at 11:47
Usually I provide an MWE, but this would be misleading here. I am not looking for a special but a general solution, like some command or option. If this doesn't lead to a solution, I will post some special case as an example of course. – matheburg Apr 4 '14 at 12:09
Even for a general solution a test case helps:-) I knew pstricks color support quite well last century when I was checking that the latex2e color support was compatible, but I'd be hard pressed to generate an example now, preferably involving some stroke and fill colour. It should be possible to hook into the pstricks macro that generates the postscript colour from the tex representation and cause it to change the emitted colour model parameters. – David Carlisle Apr 4 '14 at 12:53
@DavidCarlisle "last century?" Don't you mean last millennium? – Steven B. Segletes Apr 4 '14 at 23:46

You can redefine the setgray function of PostScript:

\documentclass[a4paper]{article}
\usepackage{pstricks,multido}
\begin{document}

Color range from $0\cdots1$\\
\pspicture(10,4)
\multido{\rA=0.0+0.2,\rB=0.0+0.05}{20}{%
\psline[linewidth=2mm,linecolor={[gray]{\rB}}](0,\rA)(10,\rA)}
\endpspicture

\def\rLeft{0.2 } \def\rRight{0.6 }%  spaces!!
\pstVerb{%  redefine /setgray
/savesetgray /setgray load def
/setgray { % on the stack is the value for gray
\rRight \rLeft sub mul \rLeft add savesetgray } def
}

\bigskip
Color range from $0.2\cdots0.6$\\
\pspicture(10,4)
\multido{\rA=0.0+0.2,\rB=0.0+0.05}{20}{%
\psline[linewidth=2mm,linecolor={[gray]{\rB}}](0,\rA)(10,\rA)}
\endpspicture

\end {document}


-