Color alpha isn't optional

This commit is contained in:
Joao Moreno
2017-08-11 11:19:34 +02:00
parent f4db436c9d
commit 43160efc08

View File

@@ -7,7 +7,7 @@
import * as crypto from 'crypto';
import URI from 'vs/base/common/uri';
import { Color as CommonColor, HSLA } from 'vs/base/common/color';
import { Color as BaseColor, HSLA } from 'vs/base/common/color';
import { illegalArgument } from 'vs/base/common/errors';
import * as vscode from 'vscode';
@@ -1020,23 +1020,20 @@ export class Color {
readonly blue: number;
readonly alpha: number;
constructor(red: number, green: number, blue: number, alpha?: number) {
constructor(red: number, green: number, blue: number, alpha: number) {
this.red = red;
this.green = green;
this.blue = blue;
this.alpha = alpha;
}
static fromHSLA(hue: number, saturation: number, luminosity: number, alpha?: number): Color {
if (!alpha) {
alpha = 1;
}
const color = new CommonColor(new HSLA(hue, saturation, luminosity, alpha)).rgba;
static fromHSLA(hue: number, saturation: number, luminance: number, alpha: number): Color {
const color = new BaseColor(new HSLA(hue, saturation, luminance, alpha)).rgba;
return new Color(color.r, color.g, color.b, color.a / 255);
}
static fromHex(hex: string): Color {
const color = CommonColor.fromHex(hex).rgba;
const color = BaseColor.fromHex(hex).rgba;
return new Color(color.r, color.g, color.b, color.a / 255);
}
}