提交 43160efc 编写于 作者: J Joao Moreno

Color alpha isn't optional

上级 f4db436c
......@@ -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);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册