本文整理汇总了TypeScript中external/gs_tools/src/color.Colors类的典型用法代码示例。如果您正苦于以下问题:TypeScript Colors类的具体用法?TypeScript Colors怎么用?TypeScript Colors使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Colors类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: isHighContrastForegroundAlpha_
/**
* @param foreground
* @param background
* @param alpha
* @param contrast Ideal contrast ratio.
* @return True iff the foreground with the alpha applied provides enough contrast ratio on the
* given background.
*/
private static isHighContrastForegroundAlpha_(
foreground: Color,
background: Color,
alpha: number,
contrast: number): boolean {
return Colors.getContrast(Colors.mix(foreground, background, alpha), background) >= contrast;
}
开发者ID:garysoed,项目名称:gs-ui,代码行数:15,代码来源:theme.ts
示例2: isHighContrastBase_
/**
* @param value Shade distance.
* @param contrast Ideal contrast ratio.
* @param baseColor
* @return True iff the value and colors provide high enough contrast for action colors.
*/
private static isHighContrastBase_(
value: number,
contrast: number,
baseColor: Color): boolean {
const baseNormalDark = Theme.createShade_(baseColor, 0.5 - value, false);
const baseNormalDarkest = Theme.createShade_(baseColor, 0.5 - value * 2, false);
const baseNormalLightest = Theme.createShade_(baseColor, 0.5 + value * 2, false);
const baseReversedDarkest = Theme.createShade_(baseColor, 0.5 - value * 2, true);
const baseReversedLight = Theme.createShade_(baseColor, 0.5 + value, true);
const baseReversedLightest = Theme.createShade_(baseColor, 0.5 + value * 2, true);
return true
// Normal colors
&& Colors.getContrast(baseNormalDark, WHITE) >= contrast
&& Colors.getContrast(BLACK, baseNormalLightest) >= contrast
// Normal Highlights
&& Colors.getContrast(baseReversedLightest, baseNormalDark) >= contrast
&& Colors.getContrast(WHITE, baseNormalDark) >= contrast
&& Colors.getContrast(baseReversedLightest, baseReversedDarkest) >= contrast
// Inverted colors
&& Colors.getContrast(baseReversedLightest, BLACK) >= contrast
&& Colors.getContrast(WHITE, baseReversedDarkest) >= contrast
// Normal Highlights
&& Colors.getContrast(baseNormalDarkest, baseReversedLight) >= contrast
&& Colors.getContrast(BLACK, baseReversedLight) >= contrast
&& Colors.getContrast(baseNormalDarkest, baseReversedLightest) >= contrast;
}
开发者ID:garysoed,项目名称:gs-ui,代码行数:36,代码来源:theme.ts
示例3: getForegroundFade_
/**
* @param foreground
* @param background
* @param contrast Ideal contrast ratio.
* @return Foreground with the alpha applied such that its contrast ratio is just ideal.
*/
private static getForegroundFade_(
foreground: Color, background: Color, contrast: number): Color {
const alpha = Solve.findThreshold(
Spec.newInstance(0, 0.1, 1),
(alpha: number) => {
return Theme.isHighContrastForegroundAlpha_(foreground, background, alpha, contrast);
},
false);
if (alpha === null) {
throw new Error('No alpha value can be computed');
}
return Colors.mix(foreground, background, alpha);
}
开发者ID:garysoed,项目名称:gs-ui,代码行数:20,代码来源:theme.ts
示例4:
.reduce((previousResult: DistanceData, value: [string, Color], index: number) => {
const distance = Colors.getDistance(value[1], color);
return distance < previousResult.distance ? {distance, index} : previousResult;
},
开发者ID:garysoed,项目名称:gs-ui,代码行数:4,代码来源:default-palettes.ts
示例5: getBlackOnAccent
@cache()
getBlackOnAccent(): Color {
const accent = this.getAccent();
return Colors.getContrast(BLACK, accent) > Colors.getContrast(WHITE, accent) ? BLACK : WHITE;
}
开发者ID:garysoed,项目名称:gs-ui,代码行数:5,代码来源:theme.ts
注:本文中的external/gs_tools/src/color.Colors类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论