当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript tinycolor2.default函数代码示例

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


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

示例1: default

export default (element, { Style }) => {
  if (element.style.color) {
    const color = tinycolor(element.style.color).toHexString();
    // eslint-disable-next-line new-cap
    return Style(`PUB_COLOR_${color}`);
  }
  if (element.style.fontSize) {
    const { fontSize } = element.style;
    // eslint-disable-next-line new-cap
    return Style(`PUB_FONT_SIZE_${fontSize}`);
  }
  return null;
};
开发者ID:carlospaelinck,项目名称:publications-js,代码行数:13,代码来源:import-text-style.ts

示例2: blendColor

export function blendColor(fgColor: string, bgColor: string, alpha: number) {
    const fg = tinycolor(fgColor).toRgb();
    var added = [fg.r, fg.g, fg.b, alpha];

    const bg = tinycolor(bgColor).toRgb();
    var base = [bg.r, bg.g, bg.b, 1 - alpha];

    var mix = [];

    mix[3] = 1 - (1 - added[3]) * (1 - base[3]); // alpha

    mix[0] = Math.round(
        (added[0] * added[3]) / mix[3] + (base[0] * base[3] * (1 - added[3])) / mix[3]
    ); // red

    mix[1] = Math.round(
        (added[1] * added[3]) / mix[3] + (base[1] * base[3] * (1 - added[3])) / mix[3]
    ); // green

    mix[2] = Math.round(
        (added[2] * added[3]) / mix[3] + (base[2] * base[3] * (1 - added[3])) / mix[3]
    ); // blue

    return "rgba(" + mix.join(",") + ")";
}
开发者ID:eez-open,项目名称:studio,代码行数:25,代码来源:color.ts

示例3: onThresholdTypeChange

 onThresholdTypeChange(index) {
   // Because of the ng-model binding, threshold's color mode is already set here
   if (this.panel.thresholds[index].colorMode === 'custom') {
     this.panel.thresholds[index].fillColor = tinycolor(config.theme.colors.blueBase)
       .setAlpha(0.2)
       .toRgbString();
     this.panel.thresholds[index].lineColor = tinycolor(config.theme.colors.blueShade)
       .setAlpha(0.6)
       .toRgbString();
   }
   this.panelCtrl.render();
 }
开发者ID:grafana,项目名称:grafana,代码行数:12,代码来源:thresholds_form.ts

示例4: addAlphaToRGB

function addAlphaToRGB(colorString: string, alpha: number): string {
  let color = tinycolor(colorString);
  if (color.isValid()) {
    color.setAlpha(alpha);
    return color.toRgbString();
  } else {
    return colorString;
  }
}
开发者ID:PaulMest,项目名称:grafana,代码行数:9,代码来源:event_manager.ts

示例5: if

  state.round.roundRankedPlayers.forEach((player, roundPos) => {

    // TODO: this lookup sucks, combine with above memoization to map a map of {id => pos} or
    // something
    const matchPos = matchRankedPlayers.findIndex((matchPlayer) => matchPlayer.id === player.id);

    const roundRowY = y + 30 + roundPos * 12;
    const matchRowY = y + 30 + matchPos * 12;

    let rowY, pos;
    if (elapsedMs < endCountingMs) {
      pos = player.scored ? roundPos + 1 : '';
      rowY = roundRowY;
    } else if (elapsedMs > endSortingMs) {
      pos = matchPos + 1;
      rowY = matchRowY;
    } else {
      pos = matchPos + 1;

      const sortingElapsedMs = elapsedMs - endCountingMs;
      const progress = sortingElapsedMs / (endSortingMs - endCountingMs);
      rowY = roundRowY + ((matchRowY - roundRowY) * progress)
    }

    const strokes = player.scored ? `${player.strokes}` : '---';
    const elapsed = player.scored ? (player.scoreTime / 1000).toFixed(2) : '---';

    // Render place
    ctx.textAlign = 'left';
    ctx.fillText(pos, placeX, rowY);

    // Render name
    if (tinycolor(player.color).isDark()) {
      ctx.strokeText(player.name, nameX, rowY);
    }

    ctx.fillStyle = player.color;
    ctx.fillText(player.name, nameX, rowY);

    // Render strokes & time elapsed
    ctx.textAlign = 'right';
    ctx.fillStyle = 'white';

    ctx.fillText(strokes, scoreX, rowY);
    ctx.fillText(elapsed, timeX, rowY);

    // Render points
    renderLeaderboardPoints(ctx, state, player, pointsX, rowY, elapsedMs);
  });
开发者ID:Hamatek,项目名称:manygolf,代码行数:49,代码来源:leaderboard.ts

示例6:

  state.round.roundRankedPlayers.forEach((player, idx) => {
    const rowY = y + 30 + idx * 10;

    ctx.textAlign = 'left';
    ctx.fillText(`${idx + 1}`, placeX, rowY);
    ctx.fillStyle = player.color;

    if (tinycolor(player.color).isDark()) {
      ctx.strokeText(player.name, nameX, rowY);
    }

    ctx.fillText(player.name, nameX, rowY);

    ctx.textAlign = 'right';
    ctx.fillStyle = 'white';
    ctx.fillText(`${player.strokes}`, scoreX, rowY);
    const elapsed = (player.scoreTime / 1000).toFixed(2);
    ctx.fillText(elapsed, timeX, rowY);
  });
开发者ID:neuhaus,项目名称:manygolf,代码行数:19,代码来源:render.ts

示例7: renderMessages

export function renderMessages(ctx: CanvasRenderingContext2D, state: State, scaleFactor: number) {
  // Messages
  if (state.displayMessage) {
    ctx.fillStyle = textColor;
    ctx.font = 'normal 8px "Press Start 2P"';
    ctx.textAlign = 'left';

    const colorStart = state.displayMessage.indexOf('{{');
    const colorEnd = state.displayMessage.indexOf('}}');

    const x = 10;
    const y = Math.round(HEIGHT - (55 / scaleFactor));

    if (colorStart !== -1) {
      const before = state.displayMessage.slice(0, colorStart);
      const colorized = state.displayMessage.slice(colorStart + 2, colorEnd);
      const after = state.displayMessage.slice(colorEnd + 2);

      ctx.fillStyle = textColor;
      ctx.fillText(before, x, y);

      ctx.fillStyle = state.displayMessageColor;

      if (tinycolor(state.displayMessageColor).isDark()) {
        ctx.strokeText(colorized, x + ctx.measureText(before).width, y);
      }

      ctx.fillText(colorized, x + ctx.measureText(before).width, y);

      ctx.fillStyle = textColor;
      ctx.fillText(after, x + ctx.measureText(before + colorized).width, y);

    } else {
      ctx.fillText(state.displayMessage, x, y);
    }
  }
}
开发者ID:Hamatek,项目名称:manygolf,代码行数:37,代码来源:hud.ts

示例8: hslToHex

export function hslToHex(color) {
  return tinycolor(color).toHexString();
}
开发者ID:acedrew,项目名称:grafana,代码行数:3,代码来源:colors.ts

示例9: hexToHsl

export function hexToHsl(color) {
  return tinycolor(color).toHsl();
}
开发者ID:acedrew,项目名称:grafana,代码行数:3,代码来源:colors.ts

示例10: darken

export function darken(color: string, percent: number) {
    return tinyColor(color).darken(percent).toHexString();
}
开发者ID:H1net,项目名称:black-screen,代码行数:3,代码来源:functions.ts


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