0% found this document useful (0 votes)
63 views

Color Extensions With The Xcolor Package - Pstricks Examples

This document provides examples of using color extensions with the xcolor package in LaTeX documents. It includes 5 figures demonstrating techniques like modifying line colors in diagrams, moving between colors, explicitly specifying colors in loops, using color series, and interacting with native PostScript code to display gamma-corrected wavelengths. The examples require packages like pstricks, pst-slpe, multido, pst-fill, and allow customizing colors and diagrams.

Uploaded by

kerredai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views

Color Extensions With The Xcolor Package - Pstricks Examples

This document provides examples of using color extensions with the xcolor package in LaTeX documents. It includes 5 figures demonstrating techniques like modifying line colors in diagrams, moving between colors, explicitly specifying colors in loops, using color series, and interacting with native PostScript code to display gamma-corrected wavelengths. The examples require packages like pstricks, pst-slpe, multido, pst-fill, and allow customizing colors and diagrams.

Uploaded by

kerredai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Color extensions with the xcolor package —

pstricks examples
Dr. Uwe Kern∗

v2.12 (2016/05/11)

This document is not suitable for pdfLATEX! Please use LATEX + dvips etc.

Figure 1: Modified version of an example from the pstricks manual; requires


pst-tree

\begin{pspicture}(-0.5,-2)(3,2)
\cnode(0,0){.5cm}{root}
\cnode*[linecolor=red](3,1.5){4pt}{A}
\cnode*[linecolor=red!72.5375!blue](3,0){4pt}{B}
\cnode*[linecolor=-red](3,-1.5){4pt}{C}
\psset{nodesep=3pt}
\ncline[linecolor=green!50!red]{root}{A}
\ncline[linecolor=blue]{root}{B}
\ncline[linecolor=-green!50!red]{root}{C}
\end{pspicture}

Figure 2: Moving from one color to its complement; requires pst-slpe


\begin{pspicture}(4,1)
\psframe[fillstyle=slope,
slopeangle=30,
slopebegin=red!72.5375!blue,
slopeend=-red!72.5375!blue](4,1)
\end{pspicture}

∗ This file is part of the xcolor distribution which can be downloaded from the CTAN mirrors

(macros/latex/contrib/xcolor/) or the homepage www.ukern.de/tex/xcolor.html. Please


send error reports and suggestions for improvements to [email protected].

1
Figure 3: Explicit color specification via a loop command; requires multido

\psset{unit=1.75}%
\begin{pspicture}(0,-1)(2,1)
\multido{\rHue=0.00+0.01}{100}%
{\pscircle[linewidth=0.01,
linecolor={[hsb]{\rHue,1,1}}](1,0){\rHue}}
\end{pspicture}

Figure 4: Color series — modified version of an example from the pst-fill manual;
note that the \multirput command does not give the desired result here
\newcommand*\Sheep
{\begin{pspicture}(3,1.5)
\pscustom[liftpen=2,fillstyle=solid,fillcolor=sheep!!+]%
{\pscurve(0.5,-0.2)(0.6,0.5)(0.2,1.3)(0,1.5)(0,1.5)
(0.4,1.3)(0.8,1.5)(2.2,1.9)(3,1.5)(3,1.5)(3.2,1.3)
(3.6,0.5)(3.4,-0.3)(3,0)(2.2,0.4)(0.5,-0.2)}
\pscircle*(2.65,1.25){0.12\psunit}% Eye
\psccurve*(3.5,0.3)(3.35,0.45)(3.5,0.6)(3.6,0.4)% Muzzle
\pscurve(3,0.35)(3.3,0.1)(3.6,0.05)% Mouth
\pscurve(2.3,1.3)(2.1,1.5)(2.15,1.7)
\pscurve(2.1,1.7)(2.35,1.6)(2.45,1.4)% Ear
\end{pspicture}}
\definecolorseries
{sheep}{rgb}{step}[rgb]{.95,.85,.55}{.17,.47,.37}
\resetcolorseries{sheep}
\psset{unit=0.4}
\begin{pspicture}(-3,-6)(0,7.5)
\Multido{\ry=6.0+-1.5}{5}%
{\rput(0,\ry){\Multido{}{5}{\Sheep}}}
\resetcolorseries{sheep}%
\multirput(-6,-6)(3,0)5{\Sheep}
\end{pspicture}

2
Figure 5: Interaction with native PostScript code — γ-corrected wavelengths
\newcount\WL \unitlength.75pt
\def\WaveToPS#1%
{\definecolor{tmp}{rgb:wave}{#1}\extractcolorspecs{tmp}\tmpm\tmpc
\expandafter\WaveToPSi\tmpc,}
\def\WaveToPSi#1,#2,#3,{\pstVerb{/Red{#1}def /Green{#2}def /Blue{#3}def}}
\def\DisplayBar#1#2%
{\linethickness{1.25\unitlength}\WL=360
\pstVerb{/Gamma{#1}def}%
\multiput(360,#2)(1,0){456}%
{\WaveToPS{\the\WL}{\color{lambda}\line(0,1){50}}\global\advance\WL1}%
\linethickness{0.25\unitlength}\WL=360
\multiput(360,#2)(20,0){23}%
{\picture(0,0)
\line(0,-1){5}\multiput(5,0)(5,0){3}{\line(0,-1){2.5}}%
\put(0,-10){\makebox(0,0){\the\WL}}\global\advance\WL20
\endpicture}%
\put(350,#2){\makebox(0,50)[r]{\small$\gamma$\,=\,#1}}}
\pstVerb{/Corr{dup 0 gt {Gamma exp}if}def}
\definecolor[ps]{lambda}{rgb}{Red Corr Green Corr Blue Corr}%
\begin{picture}(510,345)(310,-10)
\sffamily\tiny
\DisplayBar{0.4}{0}%
\DisplayBar{0.6}{70}%
\DisplayBar{0.8}{140}%
\DisplayBar{1.0}{210}%
\DisplayBar{1.2}{280}%
\end{picture}

γ = 1.2

360 380 400 420 440 460 480 500 520 540 560 580 600 620 640 660 680 700 720 740 760 780 800

γ = 1.0

360 380 400 420 440 460 480 500 520 540 560 580 600 620 640 660 680 700 720 740 760 780 800

γ = 0.8

360 380 400 420 440 460 480 500 520 540 560 580 600 620 640 660 680 700 720 740 760 780 800

γ = 0.6

360 380 400 420 440 460 480 500 520 540 560 580 600 620 640 660 680 700 720 740 760 780 800

γ = 0.4

360 380 400 420 440 460 480 500 520 540 560 580 600 620 640 660 680 700 720 740 760 780 800

You might also like