Stylesheet Development with PTC ALD > Adding PTC ALD Code to Stylesheet Source > Samples > Colors > Set Text, Line, and Background Color > Background Color
  
Background Color
The samples listed here describe how to set text background color based on a standard method of describing the color - CMYK.
Refer to the emphasis everywhere context in the Arbortext-path/samples/ALD/Colour/SettingColours.xml sample file. The context includes a set of conditions based on the value of the role attribute in the associated stylesheet. Each condition references a different property set.
For example, the condition ELSE IF attribute “role” = “CMYK background colour” of the emphasis everywhere context references the CMYK background colour property set. This property set sets a text background color in CMYK format, where each of the four values is specified as a number in the range 0-255. The relevant code in that property set is given below.
style.backgroundRule.color = 'cmyk(220,10,10,50)';
Here you have added a backgroundRule property to the styling assigned to the inline text. That property is based on the fTextRule object, which takes a color property. The value of color is described in CMYK format.
You also have to display the background color setting you have defined:
style.backgroundRule.show = 1;
Here you have added a second backgroundRule property to the styling assigned to the inline text. That property is based on the fTextRule object, which takes a show property. The value of show is 1, which draws the rule. If the value was 0 the rule would not appear.