ColorPresentation
A ColorPresentation
object represents a single way a Color object can be represented in the text of a document. Examples of this include the various CSS color types (#HEX
, rgb()
, rgba()
, etc.).
The ColorPresentation
class is not subclassable.
Added in Nova 5.
let string = "#000000";
let presentation = new ColorPresentation(string, "hex");
Class Methods
constructor(label, [kind])
Creates a new ColorPresentation
object with the provided label
string.
The optional kind
argument may be a string that represents the “type” of the color presentation. This value will be used by a color picker to automatically select the most consistent representation based on any existing color at the relevant location when performing color mixing. This string is arbitrary and can be decided by the extension.
Properties
additionalTextEdits
An array of TextEdit objects describing additional changes to apply to the editor when this presentation is chosen, unrelated to the change made via the textEdit
or label
properties. The ranges of these edits must not intersect each other nor the current editor selection.
This property is settable.
format
The closest Color Format for which the provided color presentation represents. This property may be provided as a hint as to which editing controls should be displayed when the presentation is chosen. If not provided, the color picker will attempt to interpret to the best of its ability.
insertText
The text used when inserting the presentation into the editor. If not specified, label
will be used.
This property is settable.
kind
The presentation kind may be a string that represents the “type” of the color presentation.
This value will be used by a color picker to automatically select the most consistent representation based on any existing color at the relevant location when performing color mixing. This string is arbitrary and can be decided by the extension.
This property is settable.
label
The user-readable label for the presentation. This will be displayed in the color picker’s presentations list.
This property is settable.
usesFloats
A boolean value indicating whether the presentation 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 presentation is chosen. If not provided, it is assumed this value is false
.