SVGColors  Overview

Nick Galbreath
Copyright © 2005
Version  1.0.1
http://dots101.com/release/4/

SVGColors provides a new set of color names in Mathematica based on the Scalable Vector Graphics (SVG)  standards specification (and the CSS3 specification).  Examples and a color comparison chart are given below, but keep in mind:

There is a namespace collision with Tan (the color vs. tangent).  You can use the tanget with "System`Tan`" or by removing the color Remove["SVGColors`Tan"];

SVGColors are always defined as RGBColors,even for Black, White and grays (e.g. Black is RGBColor[0.,0.,0.] not GrayLevel[0])

Colors with the same name in SVGColors, Graphics`Colors and System` may be different.Most of the time the difference is slight (within 1/255 per channel),but some colors are quite different.In particular,look at Brown,Green,Orange,and Pink.

You can always use the original color definitions in the kernel or from Graphics`Colors` by using the full context (e.g. System`Black, Graphics`Colors`Beige)

Graphics`Colors` Differences

When working with Graphics`Color, load SVGColors last, or make sure that it is first in the $ContextPath

<< Graphics`Colors`
<< dots101`SVGColors`
$ContextPath

If you are running under 5.1, basic colors like Blue, will appear black in the table below.  These colors are now defined in the kernel (System`) and not in Graphcis`Color.

gc  =   AllSVGColors;

      
If[
        ToExpression[$VersionNumber]  >=  
          5.1, 
Scan[(gc   =  
                DeleteCases[gc,  #]) &,  
          KernalColors]];

    
\(Off[General::shdw]; \  (*\ 
      you\ may\ to\ do\ this\ to\ prevent\ being\ hassled\ by\ warning\ messages\ *) 
TableForm[
      Map[{
DisplayForm[
              RowBox[\ {StyleForm["■", \ 
                    FontColor -> 
                      ToExpression["Graphics`Colors`" <> #], \ 
                    FontSize -> 
                      30\ ], 
StyleForm["■", \ FontColor -> ToExpression["SVGColors`" <> #], \ 
                    FontSize -> 
                      30\ ]}]], 
ToExpression["Graphics`Colors`" <> #], 
            ToExpression["SVGColors`" <> #]} &, \ gc], \ 
      TableHeadings -> {gc, {\ "Color", \ "Graphics`Colors` value", \ "SVGColors` value"}}]\)
On[General::shdw];

Kernel Colors Differences

In Mathematica 5.1, some "basic" colors were moved from the Graphics`Colors` package into the kernel.   The "Color" column  contains two squares.  The first is System color, and the second is the SVGColor.  If you are running a version before 5.1, the System color will  apear black.

You can always use the original System definitions,by using the full context explicity (e.g. System`Black)

\(\(\(KernalColors\  = \ {"Black", \ "Blue", \ "Brown", \ "Gray", \ "Green", \ "Magenta", \ "Orange", \ "Pink", \ "Purple", \ "Red", \ "White", \ "Yellow"};\)\(
\)
    \)\)
\(If[ToExpression[$VersionNumber]\  >= \ 
        5.1, 
TableForm[
        Map[{DisplayForm[
                RowBox[{\ \ StyleForm["■", \ 
                      FontColor -> ToExpression["System`" <> #], 
                      FontSize -> 
                        30\ ], 
StyleForm["■", \ 
                      FontColor -> 
                        ToExpression["SVGColors`" <> #], \ 
                      FontSize -> 
                        30]}]], 
ToExpression["System`" <> #], 
ToExpression["SVGColors`" <> #]} &, \ 
          KernalColors], \ 
        TableHeadings -> {KernalColors, {\ "Color", \ "System` value", \ "SVGColors` value"}}]]\)

Namespace Collision with Tan

In the SVG specification, "Tan" is  a color.  This causes a minor collision in Mathematic since "Tan" is the tangent.   To use the access the old Tan, use "System`Tan",  or remove the color.

Tan

System`Tan[
      0.1]

Remove["SVGColors`Tan"]

Tan[
      0.1]

Tangent  :=  System`Tan

    Tangent[0.1]