ich habe eine Klasse für Farben
Die Klasse hat eine statisches Attribut für HTML Farben
die über die statische Funktion initHTMLColors initialisiert wird.
Jetzt müsste ich die Anzahl der Einträge ermitteln und über einen Index zugreifen, wie kann ich das am besten machen?
Code:
export class Color { private name: string; private color_value: number = 0; private transparency: number = null; public static htmlColor: Array<Color> = new Array<Color>(); // this is the factor to calculate in brighter() or lighter() public static SMOOTHFACTOR: number = 0.7; // Internal mask for red private static RED_MASK = 255 << 16; // Internal mask for green private static GREEN_MASK = 255 << 8; // Internal mask for blue private static BLUE_MASK = 255; // Internal mask for alpha. private static ALPHA_MASK = 255 << 24; .... public static initHTMLColors(): void { if ( Color.htmlColor.length === 0 ) { Color.htmlColor['aliceblue'] = new Color(0xF0F8FF, null, 'AliceBlue'); Color.htmlColor['antiquewhite'] = new Color(0xFAEBD7, null, 'AntiqueWhite' ); Color.htmlColor['aqua'] = new Color(0x00FFFF, null, 'Aqua' ); Color.htmlColor['aquamarine'] = new Color(0x7FFFD4, null, 'Aquamarine' ); Color.htmlColor['azure'] = new Color(0xF0FFFF, null, 'Azure' ); Color.htmlColor['beige'] = new Color(0xF5F5DC, null, 'Beige' ); Color.htmlColor['bisque'] = new Color(0xFFE4C4, null, 'Bisque' ); Color.htmlColor['black'] = new Color(0x000000, null, 'Black' ); ... } } }
Code:
public static htmlColor: Array<Color> = new Array<Color>();
Jetzt müsste ich die Anzahl der Einträge ermitteln und über einen Index zugreifen, wie kann ich das am besten machen?
Kommentar