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


TypeScript style-value-types.color类代码示例

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


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

示例1: return

export const blendColor = (from: Color | string, to: Color | string) => {
  const fromColor = typeof from === 'string' ? color.parse(from) : from;
  const toColor = typeof to === 'string' ? color.parse(to) : to;
  let blended = { ...fromColor };

  // Only use the sqrt blending function for rgba and hex
  const blendFunc =
    (from as HSLA).hue !== undefined ||
    (typeof from === 'string' && hsla.test(from as string))
      ? getValueFromProgress
      : blend;

  return (v: number) => {
    blended = { ...blended };
    for (const key in blended) {
      if (key !== 'alpha' && blended.hasOwnProperty(key)) {
        blended[key] = blendFunc(fromColor[key], toColor[key], v);
      }
    }

    blended.alpha = getValueFromProgress(fromColor.alpha, toColor.alpha, v);

    return blended;
  };
};
开发者ID:jamesgeorge007,项目名称:popmotion,代码行数:25,代码来源:transformers.ts

示例2: getMixer

function getMixer(origin: any, target: any) {
  if (isNum(origin)) {
    return (v: number) => mix(origin, target as number, v);
  } else if (color.test(origin)) {
    return mixColor(origin, target as HSLA | RGBA | string);
  } else {
    return mixComplex(origin as string, target as string);
  }
}
开发者ID:Popmotion,项目名称:popmotion,代码行数:9,代码来源:mix-complex.ts

示例3: if

function detectMixerFactory<T>(v: T): MixerFactory<any> {
  if (typeof v === 'number') {
    return mixNumber;
  } else if (typeof v === 'string') {
    if (color.test(v)) {
      return mixColor;
    } else {
      return mixComplex;
    }
  } else if (Array.isArray(v)) {
    return mixArray;
  } else if (typeof v === 'object') {
    return mixObject;
  }
}
开发者ID:Popmotion,项目名称:popmotion,代码行数:15,代码来源:interpolate.ts

示例4: if

const getActionCreator = (prop: any) => {
  // Pattern matching would be quite lovely here
  if (typeof prop === 'number') {
    return createAction;
  } else if (Array.isArray(prop)) {
    return createArrayAction;
  } else if (isUnitProp(prop)) {
    return createUnitAction;
  } else if (color.test(prop)) {
    return createColorAction;
  } else if (complex.test(prop)) {
    return createComplexAction;
  } else if (typeof prop === 'object') {
    return createObjectAction;
  } else {
    return createAction;
  }
};
开发者ID:Popmotion,项目名称:popmotion,代码行数:18,代码来源:vector.ts


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