shape.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3. exports.__esModule = true;
  4. exports["default"] = void 0;
  5. var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
  6. var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
  7. var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
  8. var _base = _interopRequireDefault(require("./base"));
  9. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  10. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  11. var Shape = /*#__PURE__*/function (_Base) {
  12. (0, _inheritsLoose2["default"])(Shape, _Base);
  13. var _super = _createSuper(Shape);
  14. function Shape(cfg) {
  15. var _this;
  16. _this = _Base.call(this, cfg) || this;
  17. _this.names = ['shape'];
  18. _this.type = 'shape';
  19. _this.gradient = null;
  20. return _this;
  21. }
  22. /**
  23. * @override
  24. */
  25. var _proto = Shape.prototype;
  26. _proto.getLinearValue = function getLinearValue(percent) {
  27. var values = this.values;
  28. var index = Math.round((values.length - 1) * percent);
  29. return values[index];
  30. };
  31. return Shape;
  32. }(_base["default"]);
  33. var _default = Shape;
  34. exports["default"] = _default;