pxt-core
Version:
Microsoft MakeCode provides Blocks / JavaScript / Python tools and editors
40 lines (39 loc) • 1.55 kB
TypeScript
/// <reference path="../../pxtlib.d.ts" />
import * as Blockly from "blockly";
import { FieldCustom, FieldCustomOptions } from "./field_utils";
import { FieldColour } from "@blockly/field-colour";
/**
* The value modes:
* hex - Outputs an HTML color string: "#ffffff" (with quotes)
* rgb - Outputs an RGB number in hex: 0xffffff
* index - Outputs the index of the color in the list of colors: 0
*/
export declare type FieldColourValueMode = "hex" | "rgb" | "index";
export interface FieldColourNumberOptions extends FieldCustomOptions {
colours?: string;
columns?: string;
className?: string;
valueMode?: FieldColourValueMode;
}
export declare class FieldColorNumber extends FieldColour implements FieldCustom {
isFieldCustom_: boolean;
protected colour_: string;
private valueMode_;
protected colours_: string[];
constructor(text: string, params: FieldColourNumberOptions, opt_validator?: Blockly.FieldValidator);
setColours(colours: string[], titles?: string[]): FieldColour;
doClassValidation_(colour: string): string;
/**
* Return the current colour.
* @param {boolean} opt_asHex optional field if the returned value should be a hex
* @return {string} Current colour in '#rrggbb' format.
*/
getValue(opt_asHex?: boolean): string;
/**
* Set the colour.
* @param {string} colour The new colour in '#rrggbb' format.
*/
doValueUpdate_(colour: string): void;
getColours_(): string[];
applyColour(): void;
}