本文整理汇总了TypeScript中color.default方法的典型用法代码示例。如果您正苦于以下问题:TypeScript color.default方法的具体用法?TypeScript color.default怎么用?TypeScript color.default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类color
的用法示例。
在下文中一共展示了color.default方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: value
/**
* Sets the value to a new color (if valid), otherwise defaults to white.
*/
public set value(newValue: string) {
let parsedColor: Color;
try {
parsedColor = Color(newValue);
}
catch (err) {
// that color is invalid, reset to white
parsedColor = Color("white");
}
const value = parsedColor.hex();
super.value = value;
this.element.attr("title", value);
}
示例2: constructor
// <<-- /Creer-Merge: variables -->>
/**
* Constructor for the Tile with basic logic as provided by the Creer
* code generator. This is a good place to initialize sprites and constants.
*
* @param state - The initial state of this Tile.
* @param viseur - The Viseur instance that controls everything and contains the game.
*/
constructor(state: ITileState, viseur: Viseur) {
super(state, viseur);
// <<-- Creer-Merge: constructor -->>
// render the board
// Set the parent of the tile container as the background layer
this.container.setParent(this.game.layers.background);
// Set the container's sprite as the ground tile Sprite
const grassSpriteName = `grass${Math.abs(this.game.random.int32() % 3) + 1}` as "grass1" | "grass2" | "grass3";
this.grass = this.addSprite[grassSpriteName]();
// Change the resource here
if (state.harvestRate > 0) {
this.bush = this.addSprite.bush();
this.berry = this.addSprite.berry();
const colors = [Color("purple"), Color("yellow"), Color("red"), Color("blue")]; // by ptm
const i = Math.abs(this.game.random.int32() % colors.length);
this.berry.tint = colors[i].rgbNumber();
// this.berry.tint = Color("blue").rgbNumber();
} /** */
// Set the position of the container to the current position
this.container.position.set(state.x, state.y);
// <<-- /Creer-Merge: constructor -->>
}
示例3: Color
export const getContrastColor = color => {
let c;
try {
c = Color(color);
} catch (e) {
return '#000000';
}
if (c && c.isLight()) return '#000000';
if (c && c.isDark()) return '#FFFFFF';
return '#000000';
};
示例4: getTintFromColor
export function getTintFromColor(color: ColorTint): number {
if (typeof(color) === "number") {
return color;
}
else if (typeof(color) === "string") {
return Color(color).rgbNumber();
}
else {
return color.rgbNumber();
}
}
示例5: computeGlobalStyle
export function computeGlobalStyle(
userTheme: UserTheme,
mode: GlobalStyleMode,
): GlobalStyleTheme {
// Compute global style from user theme and mode.
const background =
mode === 'day'
? userTheme.day.bg
: mode === 'night'
? userTheme.night.bg
: mode === 'heaven'
? userTheme.heaven.bg
: '#ffffff';
const color =
mode === 'day'
? userTheme.day.color
: mode === 'night'
? userTheme.night.color
: mode === 'heaven'
? userTheme.heaven.color
: '#000000';
// Determine link color according to lightness of bg..
const linkColor1 = Color('#000a68');
const linkColor2 = Color('#ffffff');
const bgObj = Color(background);
const linkObj =
bgObj.contrast(linkColor1) > bgObj.contrast(linkColor2)
? linkColor1
: linkColor2;
const link = linkObj.rgb().string();
return {
background,
color,
link,
};
}
示例6: recolor
/**
* Invoked after a player changes their color,
* so we have a chance to recolor this Port's sprites.
*/
public recolor(): void {
super.recolor();
// <<-- Creer-Merge: recolor -->>
if (this.ownerID === undefined) {
const white = Color("white");
this.portColor.tint = white.rgbNumber();
this.rotatedPortColor.tint = white.rgbNumber();
return;
}
const ownerColor = this.game.getPlayersColor(this.ownerID);
this.portColor.tint = ownerColor.rgbNumber();
this.rotatedPortColor.tint = ownerColor.rgbNumber();
// replace with code to recolor sprites based on player color
// <<-- /Creer-Merge: recolor -->>
}
示例7: Color
import * as Color from "color"
var color: Color.Color = Color("white")
var colorOther: Color.Color = Color("black")
var colorRGB: Color.Color = Color({ r : 0, g : 0, b : 0 }, "rgb")
var hex: string = color.hex()
var percent: string = color.percentString()
var keyword: string | void = color.keyword()
var alpha: number = color.alpha()
var red: number = color.red()
var green: number = color.green()
var blue: number = color.blue()
var hue: number = color.hue()
var saturationl: number = color.saturationl()
var lightness: number = color.lightness()
var saturationv: number = color.saturationv()
var value: number = color.value()
var cyan: number = color.cyan()
var magenta: number = color.magenta()
var yellow: number = color.yellow()
var black: number = color.black()
var luminosity: number = color.luminosity()
var contrast: number = color.contrast(colorOther)
var dark: boolean = color.dark()
var light: boolean = color.light()
var level: string = color.level(colorOther)
var x: number = color.x()
var y: number = color.y()
var z: number = color.z()
示例8: Color
import { Delta } from "@cadre/ts-utils/cadre";
import { Immutable } from "src/utils";
import { Viseur } from "src/viseur";
import { makeRenderable } from "src/viseur/game";
import { GameObject } from "./game-object";
import { ITileState, IUnitState } from "./state-interfaces";
// <<-- Creer-Merge: imports -->>
// any additional imports you want can be added here safely between Creer runs
import * as Color from "color";
import { ease, updown } from "src/utils"; // updown
import { GameBar } from "src/viseur/game";
import { IJobState } from "./state-interfaces";
import { Tile } from "./tile";
const WHITE_COLOR = Color("white").rgbNumber();
// <<-- /Creer-Merge: imports -->>
// <<-- Creer-Merge: should-render -->>
// Set this variable to `true`, if this class should render.
const SHOULD_RENDER = true;
// <<-- /Creer-Merge: should-render -->>
/**
* An object in the game. The most basic class that all game classes should inherit from automatically.
*/
export class Unit extends makeRenderable(GameObject, SHOULD_RENDER) {
// <<-- Creer-Merge: static-functions -->>
// you can add static functions here
// <<-- /Creer-Merge: static-functions -->>
示例9: Color
import * as Color from "color"
var color: Color.Color = Color("white")
var colorOther: Color.Color = Color("black")
var colorRGB: Color.Color = color.rgb(0, 0, 0)
var colorRGB: Color.Color = color.rgb([0, 0, 0])
var rgb: Color.RGBColor = color.rgb()
var colorHSL: Color.Color = color.hsl([0, 0, 0])
var hsl: Color.HSLColor = color.hsl()
var colorHSV: Color.Color = color.hsv([0, 0, 0])
var hsv: Color.HSVColor = color.hsv()
var colorHBW: Color.Color = color.hbw([0, 0, 0])
var hbw: Color.HBWColor = color.hbw()
var colorCMYK: Color.Color = color.cmyk([0, 0, 0, 0])
var cmyk: Color.CMYKColor = color.cmyk()
var hex: string = color.hexString()
var percent: string = color.percentString()
var keyword: string | void = color.keyword()
var alpha: number = color.alpha()
var red: number = color.red()
var green: number = color.green()
var blue: number = color.blue()
var hue: number = color.hue()
var saturation: number = color.saturation()
var lightness: number = color.lightness()
示例10: colorToGhostColor
function colorToGhostColor(hex: string) {
const c = Color(hex).mix(Color('white'));
return c.toString(16);
}