How to use the tinycolor2.default function in tinycolor2

To help you get started, we’ve selected a few tinycolor2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github romannurik / AndroidAssetStudio / app / scripts / studio / fields.js View on Github external
getValue() {
    return this.value_ || tinycolor(this.params_.defaultValue || '#000');
  }
github WordPress / gutenberg / packages / blocks / src / api / utils.js View on Github external
export function normalizeIconObject( icon ) {
	if ( isValidIcon( icon ) ) {
		return { src: icon };
	}

	if ( has( icon, [ 'background' ] ) ) {
		const tinyBgColor = tinycolor( icon.background );

		return {
			...icon,
			foreground: icon.foreground ? icon.foreground : mostReadable(
				tinyBgColor,
				ICON_COLORS,
				{ includeFallbackColors: true, level: 'AA', size: 'large' }
			).toHexString(),
			shadowColor: tinyBgColor.setAlpha( 0.3 ).toRgbString(),
		};
	}

	return icon;
}
github romannurik / AndroidAssetStudio / app / scripts / studio / fields.js View on Github external
setValue(val, pauseUi) {
    let oldValue = this.value_;
    this.value_ = (val.hasOwnProperty('_r'))
        ? val
        : tinycolor(val || this.params_.defaultValue || '#000');
    if (!pauseUi) {
      this.el_.spectrum('set', this.value_.toRgbString());
    }
    this.notifyChanged_(val, oldValue);
  }
github romannurik / AndroidIconAnimator / app / scripts / ColorUtil.js View on Github external
svgToAndroidColor(color) {
    if (color == 'none') {
      return null;
    }
    color = tinycolor(color);
    let colorHex = color.toHex();
    let alphaHex = color.toHex8().substr(6);
    return '#' + (alphaHex != 'ff' ? alphaHex : '') + colorHex;
  },
github romannurik / AndroidIconAnimator / app / scripts / colorutil.js View on Github external
svgToAndroidColor(color, opacity) {
    if (color == 'none') {
      return null;
    }

    color = tinycolor(color);
    if (opacity) {
      color.setAlpha(opacity);
    }

    return color.toHex8String();
  },