ColorInformation

A ColorInformation object represents an instance of a Color within a document, and defines the text range at which the color is located.

The ColorInformation class is not subclassable.

Added in Nova 5.

let color = new Color(ColorFormat.rgb, [1, 0, 0.5, 1]);
let range = new Range(100, 107);
let colorInfo = new ColorInformation(range, color, "hex");

Class Methods

constructor(range, color, [kind])

Creates a new ColorInformation object with the provided Range and Color values.

The optional kind argument should be a string that represents the “type” of color presentation the created color information object represents. (See the kind property below.)

Properties

color

The color represented by the object as a Color object.

This property is settable.

kind

The presentation kind that by which the color information is represented.

This value will be used by the editor color picker to automatically select the first ColorPresentation object returned from the relevant color assistant that matches this kind. This way, as a user alters the value of a color, the text presentation of the new color can be consistent. If this value is not provided, then no attempt to match presentation kinds will be attempted.

range

The range of the document where the color exists, as a Range object.

This property is settable.

usesFloats

A boolean value indicating whether the color information uses floating-point values for its components (not including alpha), such as an RGB presentation that uses floating point values between 0.0 and 1.0. This property may be provided as a hint as to which editing controls should be displayed when the color information is chosen. If not provided, it is assumed this value is false.