All files / src/models color.ts

100% Statements 15/15
100% Branches 2/2
100% Functions 3/3
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 161x   1x 9x 9x 2x 2x 2x 2x     1x   7x   1x
import { Utils } from "../utils";
 
export class Color {
    constructor(public red: number, public green: number, public blue: number, public color?: string) {
        if (color) {
            this.color = color.toUpperCase();
            this.red = Utils.hexToNumber(color.substr(0, 2));
            this.green = Utils.hexToNumber(color.substr(2, 2));
            this.blue = Utils.hexToNumber(color.substr(4, 2));
        }
    }
    public getValue() {
        // tslint:disable-next-line:no-bitwise
        return this.red * 65536 + this.green * 256 + this.blue;
    }
}