react-native#processColor TypeScript Examples

The following examples show how to use react-native#processColor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LinearGradient.tsx    From nlw2-proffy with MIT License 6 votes vote down vote up
render() {
    let { colors, locations, start, end, ...props } = this.props;

    if (locations && colors.length !== locations.length) {
      console.warn('LinearGradient colors and locations props should be arrays of the same length');
      locations = locations.slice(0, colors.length);
    }

    return (
      <NativeLinearGradient
        {...props}
        colors={Platform.select({
          web: colors as any,
          default: colors.map(processColor),
        })}
        locations={locations}
        startPoint={_normalizePoint(start)}
        endPoint={_normalizePoint(end)}
      />
    );
  }
Example #2
Source File: redash.ts    From react-native-sticky-item with MIT License 6 votes vote down vote up
interpolateColor = (
  value: Animated.Adaptable<number>,
  config: ColorInterpolationConfig,
  colorSpace: 'hsv' | 'rgb' = 'rgb'
): Animated.Node<number> => {
  const { inputRange } = config;
  const outputRange = config.outputRange.map(c =>
    //@ts-ignore
    typeof c === 'number' ? c : processColor(c)
  );
  if (colorSpace === 'hsv') {
    //@ts-ignore
    return interpolateColorsHSV(value, inputRange, outputRange);
  }
  //@ts-ignore
  return interpolateColorsRGB(value, inputRange, outputRange);
}
Example #3
Source File: utils.tsx    From iotc-cpm-sample with MIT License 6 votes vote down vote up
export function getRandomColor() {
  return processColor(
    `rgb(${Math.floor(Math.random() * 256)},${Math.floor(
      Math.random() * 256,
    )},${Math.floor(Math.random() * 256)})`,
  );
}