SVG viewports

   



Colors and Their Components

Color is the sine qua non ('without that which') of graphics. Imagine if you can what graphics or art would be like without any color. Apart from watching film noir, could anyone look forward to such an impoverished state of affairs?

In the SVG world, a color can be defined in four ways. One way is an (R,G,B) triplet of (base ten) integers, which specify values for its red component, green component, and blue component, respectively. For example, the color red is represented as (255,0,0). The values for R, G, and B are independent of each other, and each one is a decimal integer between 0 and 255. Consequently, there are 256x256x256 = 16,777,216 possible colors combinations. The human eye cannot distinguish between every pair of possible colors, which means that interesting shading effects can be achieved. Note that the color white has all colors present, while the color black is actually the absence of all color. Several examples are given below:

White: (R, G, B) = (255, 255, 255) Black: (R, G, B) = (0,  0,  0) Red:   (R, G, B) = (255, 0,  0) Green: (R, G, B) = (0,  255, 0) Blue:  (R, G, B) = (0,  0,  255)

As the values of (R, G, B) decrease from a maximum of 255 to a minimum of 0, the associated color will darken. This behavior is consistent with the fact that white is (255, 255, 255) and black is (0, 0, 0).

A second way to specify SVG colors involves listing the relative weights of the (R, G, B) components as a percentage between 0 and 100. For example, the color red is represented as rgb(100%,0%,0%).

A third way to specify SVG colors involves a string of six hexadecimal digits. Most of the SVG code in this book uses this technique. For example, the string '#FF0000' represents the color red. Notice that the first pair of hexadecimal digits is the hexadecimal representation of the number 255. The other two pairs of hexadecimal digits correspond to the G component and the B component, respectively. For example, the SVG color with (R, G, B) values of (128, 96, 48) corresponds to the SVG color '#806030.' The fourth way of specifying SVG colors is the subject of the next topic.



   



Fundamentals of SVG Programming. Concepts to Source Code
Fundamentals of SVG Programming: Concepts to Source Code (Graphics Series)
ISBN: 1584502983
EAN: 2147483647
Year: 2003
Pages: 362

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net