MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / parseCssColor

Function parseCssColor

packages/core/css/parser.ts:83–95  ·  view source on GitHub ↗
(text: string, start = 0)

Source from the content-addressed store, hash-verified

81
82const cssColorRegEx = /\s*((?:rgb|rgba|hsl|hsla|hsv|hsva)\([^\(\)]*\))/gy;
83export function parseCssColor(text: string, start = 0): Parsed<Color> {
84 cssColorRegEx.lastIndex = start;
85 const result = cssColorRegEx.exec(text);
86 if (!result) {
87 return null;
88 }
89 const end = cssColorRegEx.lastIndex;
90 try {
91 return { start, end, value: new Color(result[1]) };
92 } catch {
93 return null;
94 }
95}
96
97export function convertHSLToRGBColor(hue: number, saturation: number, lightness: number): { r: number; g: number; b: number } {
98 // Per formula it will be easier if hue is divided to 60° and saturation to 100 beforehand

Callers 1

parseColorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected