Stylesheet Development with PTC ALD > Adding PTC ALD Code to Stylesheet Source > Samples > Colors > Set Text, Line, and Background Color > Text Color — Direct Setting with Standard Color
  
Text Color — Direct Setting with Standard Color
The samples listed here describe how to set text color based on standard methods of describing the color - CMYK and RGB.
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 IF attribute “role” = “CMYK text colour 1” of the emphasis everywhere context references the CMYK text colour 1 property set. This property set sets a text color in CMYK format, where each of the four values is specified by a number in the range 0-255. The relevant code in that property set is given below.
style.color = "cmyk(120,140,10,50)";
Here you have added a color property to the styling assigned to the inline text.
You may set colors in this way in both CMYK and RGB formats, using numbered, percentage, and hex values. The conditions for the emphasis everywhere context and their associated property sets in the stylesheet provide examples of each of these:
CMYK (numbered values)
Sample code:
style.color = "cmyk(120,140,10,50)";
See condition IF attribute “role” = “CMYK text colour 1” and property set CMYK text colour 1
CMYK (percentage values)
Sample code:
style.color = "cmyk(10%,60%,80%,20%)";
See condition ELSE IF attribute “role” = “CMYK text colour 2” and property set CMYK text colour 2
RGB (numbered values)
Sample code:
style.color = "rgb(120,140,10)";
See condition ELSE IF attribute “role” = “RGB text colour 1” and property set CMYK text colour 1
RGB (percentage values)
Sample code:
style.color = "rgb(10%,60%,80%)";
See condition ELSE IF attribute “role” = “RGB text colour 2” and property set RGB text colour 2
RGB (hex values)
Sample code:
style.color = "#cd102f";
See condition ELSE IF attribute “role” = “RGB text colour 3” and property set RGB text colour 3