lineargradient.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. define(function(require, exports, module) {
  2. var svg = require('./svg');
  3. var Gradient = require('./gradient');
  4. return require('../core/class').createClass('LinearGradientBrush', {
  5. base: Gradient,
  6. constructor: function(paper) {
  7. this.callBase('linearGradient', paper);
  8. this.setStartPosition(0, 0);
  9. this.setEndPosition(1, 0);
  10. },
  11. setStartPosition: function(px, py) {
  12. this.node.setAttribute('x1', px);
  13. this.node.setAttribute('y1', py);
  14. return this;
  15. },
  16. setEndPosition: function(px, py) {
  17. this.node.setAttribute('x2', px);
  18. this.node.setAttribute('y2', py);
  19. return this;
  20. },
  21. getStartPosition: function() {
  22. return {
  23. x: +this.node.getAttribute('x1'),
  24. y: +this.node.getAttribute('y1')
  25. };
  26. },
  27. getEndPosition: function() {
  28. return {
  29. x: +this.node.getAttribute('x2'),
  30. y: +this.node.getAttribute('y2')
  31. };
  32. }
  33. });
  34. });