Managing Color in Styles, Shapes, and Files

3 4

When you are designing masters, you need to consider how the color of the master will look on different user systems. You can apply color to a shape using either the Microsoft Visio color palette or a custom color that you define. The method you choose affects how the shape appears if used in another document. You can apply color to a shape in the following ways:

  • By applying a color from the Visio color palette, you choose an index of one of the palette's colors. The Visio engine records only the index to the color palette, not the color itself.
  • By defining an RGB (red, green, blue) or HSL (hue, saturation, luminosity) value, either in the Colors dialog box or as a formula, you apply a custom color to a shape.

In Microsoft Visio 2002, you can also apply transparency as part of the setting for foreground and background fill and shadow colors, and line, character, text block, or layer colors.

Note


Beginning with Visio 2002, the Visio engine uses a 32-bit color model, which makes over 16 million colors available in a Visio drawing. This true-color model also makes it possible for transparency to be applied to various color settings such as fill color, line color, text, and shadows.

Earlier versions of Visio support a palette-based color model. In the palette-based color model, as many as 253 different colors could be chosen for a given document—24 of these colors belong to the Visio logical color palette, and the remaining 229 are available for custom colors. Colors are stored by index in a color table that is part of the document.

In Visio 2002, colors are stored with each shape as RGB values; each cell for a shape can explicitly store a 24-bit color in the form of an RGB formula. For backward compatibility, Visio 2002 still maintains a document color table (maximum of 253 indexed colors) in addition to the explicit RGB color values.

The ShapeSheet (r) window displays cell color formulas exactly as they are entered. In Visio 2002, values are displayed as the index value for logical colors (the first 24 entries in the color table are reserved for the logical color palette) and as the RGB values for custom colors. This is a change from Visio 2000, which displays the index values for all colors, both logical and custom.

Editing the Color Palette

The color palette appears in the Color Palette dialog box, as well as in the drop-down list of colors in the Fill, Line, Font, Text Block, and other dialog boxes. For any document that uses the default Visio palette, a color index refers to the same color: 0 is black, 1 is white, 2 is red, and so on.

However, users can choose the color they want to appear at any index by editing the color palette. If they do, any color property mapped to that index can change color. For example, if you apply a fill color to a master by clicking red in the palette, the shape's fill color is recorded as 2. If a user creates an instance of the red master in a document in which the second index in the color palette has been edited, the shape's fill color will change to whatever color appears at index 2.

Most users do not edit a document's color palette, so colors are not likely to shift. But you can ensure that a shape's color never changes, regardless of a document's color palette, by using a custom RGB or HSL color. To specify a custom color as a formula, use either the RGB or HSL function. For details about using these functions, see Using a Formula to Define a Custom Color later in this section.

Standardizing Color Palettes across Documents

When you're designing stencils that you intend to open with a template, you should use the same color palette in all documents. If the color palettes do not match, the colors defined by an index in a master's styles can change when an instance is dragged into a document that has a different color value at that index. To standardize the color palette used in documents that are intended to open together, such as stencils and templates, you can copy the color palette used in one file to another.

If you edit the color palette in a stencil file, you can copy the color palette to a template.

To copy a stencil's color palette to a template

  1. Open the template file.
  2. On the Tools menu, click Color Palette.
  3. For Copy colors from, select the stencil whose color palette you want to copy to the template file, and then click OK.
  4. Save the document.

Using a Formula to Define a Custom Color

You can define shape color using a function that specifies an RGB or HSL value. For example, to ensure that a stop-sign shape is always red, you can enter the following formula in the Fill Format section:

 FillForegnd= RGB(255,0,0) 

The RGB function's three arguments specify the red, green, and blue components of the color. Each can have a value from 0 to 255. To specify the color using an HSL value, you could instead use the formula HSL(0,240,120) in the FillForegnd cell. For details about function syntax, see the HSLfunction or RGBfunction topics in the Microsoft Visio Developer Reference (on the Help menu, click Developer Reference).

Rather than specifying color constants as the argument to these functions, you can use the RED, GREEN, and BLUE or HUE, SAT, and LUM functions to return the value of a color constant from the document's color palette or from another cell. For example, using RED(FillForegnd) with a stop-sign shape might return 255, the value of the red component in the fill color for that shape.

You can use the RGB and HSL function together with the other color functions to define a color based on another cell's color in the same or a different shape. This is particularly useful in a group containing shapes of related but not identical colors. You can define the grouped shape's colors in terms of one shape's color in the group. For example, if the topmost shape in a group is Star 7, you could enter the following in Star 7.2:

 FillForegnd= RGB(RED(Sheet.7!FillForegnd),0,0) 

If a user applies a new color to the group, the topmost shape changes color, but Star 7.2 changes only the proportion of red in its fill color.

When you specify a custom color using the RGBor HSLfunction, the color is added to the color list in the Fill, Line, Font, and other dialog boxes in which you can assign color. If you create a master from a shape to which a custom color has been assigned, and then drop an instance of it in another Visio document, the custom color is added to that document's color lists as well.

Adding Transparency for Custom Colors

Beginning with Visio 2002, you can specify transparency independent of color settings. As the following table shows, each transparency cell is located next to its corresponding color cell in the ShapeSheet spreadsheet. Transparency is specified as a positive percentage value from 0% (completely opaque) to 100% (completely transparent).

Corresponding Color and Transparency cells

Section

Color cell

Transparency cell

Fill Format

FillForegnd

FillForegndTrans

FillBkgnd

FillBkgndTrans

ShdwForegnd

ShdwForegndTrans

ShdwBkgnd

ShdwBkgndTrans

Line Format

LineColor

LineColorTrans

Character

Char.Color

Char.ColorTrans

Text Block Format

TextBkgnd

TextBkgndTrans

Image Properties

Transparency

Layers section (Page)

Layers.Color

Layers.ColorTrans



Developing Microsoft Visio Solutions 2001
Developing Microsoft Visio Solutions (Pro-Documentation)
ISBN: 0735613532
EAN: 2147483647
Year: 2004
Pages: 180

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