# (TikZ or xcolor) lighten color

I am plotting some simple stuff using TikZ like circles and lines. They are colored. I know the color I want to plot with but would like create a new color that is a lighter version of the old.

pseudo-code

lightgray = lighten(gray, 0.5)

where the 2nd parameter is "how much"

-

With the xcolor package you can use red!<number> notation, where <number> represents what percent of that color is to be used. See the package documentation for more options:

To maintain consistency you can also use define your own colors:

\colorlet{ColorPink}{red!10}


as I have done for the last line in the image above.

## Code:

\documentclass{article}
\usepackage{xcolor}
\usepackage{tikz}

\colorlet{ColorPink}{red!10}

\begin{document}
\begin{tikzpicture}
\draw [ultra thick, red   ] (0, 0.0) -- (2, 0.0);
\draw [ultra thick, red!60] (0,-0.5) -- (2,-0.5);
\draw [ultra thick, red!30] (0,-1.0) -- (2,-1.0);
\draw [ultra thick, ColorPink] (0,-1.5) -- (2,-1.5);
\end{tikzpicture}
\end{document}

-
Thanks. Does colorlet consolidate colors with the same name or color? I'm afraid the way I am using it that I'll end up wasting a lot of resources for no reason. – Uiy Mar 20 '12 at 5:47
@Uiy: I do not know, but unless you have numerous different colors I don't think it'll be a problem. You could always post a separate question explaining in detail, exactly how you are using it if you want opinions from those that would know better. – Peter Grill Mar 20 '12 at 22:04
Well, I created a cache so I don't keep on creating new colors... that way I know for sure. – Uiy Mar 20 '12 at 22:43

Using Peter Grill's approach, you can also define commands to automate the process:

\documentclass{article}
\usepackage{xcolor}
\usepackage{tikz}

\colorlet{MyColorOne}{blue!50}

\newcommand{\lightercolor}[3]{% Reference Color, Percentage, New Color Name
\colorlet{#3}{#1!#2!white}
}

\newcommand{\darkercolor}[3]{% Reference Color, Percentage, New Color Name
\colorlet{#3}{#1!#2!black}
}

\lightercolor{MyColorOne}{50}{MyColorOneLight}
\darkercolor{MyColorOne}{50}{MyColorOneDark}

\begin{document}
\begin{tikzpicture}
\draw [ultra thick, MyColorOne] (0, 0.0) -- (2, 0.0) node[right] {Regular};
\draw [ultra thick, MyColorOneLight] (0,-0.5) -- (2,-0.5) node[right] {Lighter};
\draw [ultra thick, MyColorOneDark] (0,-1.0) -- (2,-1.0) node[right] {Darker};
\end{tikzpicture}
\end{document}


-
Basically this is what I'm doing. – Uiy Mar 20 '12 at 5:50