• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript color类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中color的典型用法代码示例。如果您正苦于以下问题:TypeScript color类的具体用法?TypeScript color怎么用?TypeScript color使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了color类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: 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 -->>
    }
开发者ID:siggame,项目名称:Viseur,代码行数:34,代码来源:tile.ts


示例2: 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);
    }
开发者ID:siggame,项目名称:Viseur,代码行数:17,代码来源:color-picker.ts


示例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';
};
开发者ID:EmmaRamirez,项目名称:nuzlocke-generator,代码行数:11,代码来源:getContrastColor.ts


示例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();
    }
}
开发者ID:siggame,项目名称:Viseur,代码行数:11,代码来源:pixi.ts


示例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,
  };
}
开发者ID:uhyo,项目名称:jinrou,代码行数:40,代码来源:global-style.ts


示例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 -->>
    }
开发者ID:siggame,项目名称:Viseur,代码行数:21,代码来源:port.ts


示例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()
开发者ID:ArtemZag,项目名称:DefinitelyTyped,代码行数:31,代码来源:color-tests.ts


示例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 -->>
开发者ID:siggame,项目名称:Viseur,代码行数:30,代码来源:unit.ts


示例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()
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:31,代码来源:color-tests.ts


示例10: colorToGhostColor

function colorToGhostColor(hex: string) {
  const c = Color(hex).mix(Color('white'));
  return c.toString(16);
}
开发者ID:DallanQ,项目名称:rxjs,代码行数:4,代码来源:painter.ts



注:本文中的color类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript command-line-args类代码示例发布时间:2022-05-28
下一篇:
TypeScript codemirror类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap