Main Content

mlreportgen.dom.Color class

Package: mlreportgen.dom

Color of document element


Specifies the color of a document element.


colorObj = mlreportgen.dom.Color() creates a black color object.

colorObj = mlreportgen.dom.Color(colorName) creates a color object based on the specified CSS color name.

colorObj = mlreportgen.dom.Color(rgbValue) creates a color object using the hexadecimal RGB color value.

Input Arguments

expand all

Name of a color. The name must be a CSS color name. See

A character vector using the following RGB format: #RRGGBB. Use # as the first character and two-digit hexadecimal numbers each for the red, green, and blue values. For example, '#0000ff' specifies blue.

Output Arguments

expand all

Color for document element, represented by an mlreportgen.dom.Color object.


expand all

Hexadecimal number representing an RGB color value. For example, '#8b008b' specifies dark magenta. You can use either uppercase or lowercase letters as part of a hexadecimal value.

ID for this document element, specified as a character vector or string scalar. The DOM generates a session-unique ID when it creates the document element. You can specify your own ID.

Tag for this document element, specified as a character vector or string scalar.

The DOM generates a session-unique tag as part of the creation of this object. The generated tag has the form CLASS:ID, where CLASS is the object class and ID is the value of the Id property of the object. Specifying your own tag value can help you to identify where an issue occurred during document generation.

Either a CSS color name or a hexadecimal RGB value.


Public Methods

mlreportgen.dom.Color.isValidUse this method to check if a string is a valid color.
tf = mlreportgen.dom.Color.isValid('red');
tf =


mlreportgen.dom.Color.getUnitVectorUse this method to get the unit vector values for a valid color.
redVector = mlreportgen.dom.Color.getUnitVector('red');
redVector =

     1     0     0


collapse all

Create a blue color object and apply it to a paragraph. Instead of specifying the CSS color name 'blue', you could use the hexadecimal value '#0000ff'.

import mlreportgen.dom.*;
doctype = 'html';
d = Document('test',doctype);

colorfulStyle = {Bold,Color('blue')};
p = Paragraph('deep sky blue paragraph');
p.Style = colorfulStyle;