MCPcopy Create free account
hub / github.com/adobe/react-spectrum / toFormat

Method toFormat

packages/react-stately/src/color/Color.ts:528–542  ·  view source on GitHub ↗
(format: ColorFormat)

Source from the content-addressed store, hash-verified

526 }
527
528 toFormat(format: ColorFormat): IColor {
529 switch (format) {
530 case 'hsb':
531 case 'hsba':
532 return this;
533 case 'hsl':
534 case 'hsla':
535 return this.toHSL();
536 case 'rgb':
537 case 'rgba':
538 return this.toRGB();
539 default:
540 throw new Error('Unsupported color conversion: hsb -> ' + format);
541 }
542 }
543
544 /**
545 * Converts a HSB color to HSL.

Callers 1

toStringMethod · 0.95

Calls 2

toHSLMethod · 0.95
toRGBMethod · 0.95

Tested by

no test coverage detected