LinearGradient.js 994 B

12345678910111213141516171819202122232425262728293031323334
  1. var zrUtil = require("../core/util");
  2. var Gradient = require("./Gradient");
  3. /**
  4. * x, y, x2, y2 are all percent from 0 to 1
  5. * @param {number} [x=0]
  6. * @param {number} [y=0]
  7. * @param {number} [x2=1]
  8. * @param {number} [y2=0]
  9. * @param {Array.<Object>} colorStops
  10. * @param {boolean} [globalCoord=false]
  11. */
  12. var LinearGradient = function (x, y, x2, y2, colorStops, globalCoord) {
  13. // Should do nothing more in this constructor. Because gradient can be
  14. // declard by `color: {type: 'linear', colorStops: ...}`, where
  15. // this constructor will not be called.
  16. this.x = x == null ? 0 : x;
  17. this.y = y == null ? 0 : y;
  18. this.x2 = x2 == null ? 1 : x2;
  19. this.y2 = y2 == null ? 0 : y2; // Can be cloned
  20. this.type = 'linear'; // If use global coord
  21. this.global = globalCoord || false;
  22. Gradient.call(this, colorStops);
  23. };
  24. LinearGradient.prototype = {
  25. constructor: LinearGradient
  26. };
  27. zrUtil.inherits(LinearGradient, Gradient);
  28. var _default = LinearGradient;
  29. module.exports = _default;