5ecd728aa7014332dc41918613aa32e52f232dfea2c76baa571debf37303e5fb20a980c7ef88e40582608c280ecd4a4e835412094f16b5e351245b4c296ce2 961 B

123456789101112131415161718192021222324252627282930
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.legacyRandom = exports.fromRatio = void 0;
  4. var index_js_1 = require("./index.js");
  5. var util_js_1 = require("./util.js");
  6. /**
  7. * If input is an object, force 1 into "1.0" to handle ratios properly
  8. * String input requires "1.0" as input, so 1 will be treated as 1
  9. */
  10. function fromRatio(ratio, opts) {
  11. var newColor = {
  12. r: (0, util_js_1.convertToPercentage)(ratio.r),
  13. g: (0, util_js_1.convertToPercentage)(ratio.g),
  14. b: (0, util_js_1.convertToPercentage)(ratio.b),
  15. };
  16. if (ratio.a !== undefined) {
  17. newColor.a = Number(ratio.a);
  18. }
  19. return new index_js_1.TinyColor(newColor, opts);
  20. }
  21. exports.fromRatio = fromRatio;
  22. /** old random function */
  23. function legacyRandom() {
  24. return new index_js_1.TinyColor({
  25. r: Math.random(),
  26. g: Math.random(),
  27. b: Math.random(),
  28. });
  29. }
  30. exports.legacyRandom = legacyRandom;