Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 

65 строки
1.7 KiB

  1. SVG.Path = SVG.invent({
  2. // Initialize node
  3. create: 'path'
  4. // Inherit from
  5. , inherit: SVG.Shape
  6. // Add class methods
  7. , extend: {
  8. // Define morphable array
  9. morphArray: SVG.PathArray
  10. // Get array
  11. , array: function() {
  12. return this._array || (this._array = new SVG.PathArray(this.attr('d')))
  13. }
  14. // Plot new path
  15. , plot: function(d) {
  16. return (d == null) ?
  17. this.array() :
  18. this.clear().attr('d', typeof d == 'string' ? d : (this._array = new SVG.PathArray(d)))
  19. }
  20. // Clear array cache
  21. , clear: function() {
  22. delete this._array
  23. return this
  24. }
  25. // Move by left top corner
  26. , move: function(x, y) {
  27. return this.attr('d', this.array().move(x, y))
  28. }
  29. // Move by left top corner over x-axis
  30. , x: function(x) {
  31. return x == null ? this.bbox().x : this.move(x, this.bbox().y)
  32. }
  33. // Move by left top corner over y-axis
  34. , y: function(y) {
  35. return y == null ? this.bbox().y : this.move(this.bbox().x, y)
  36. }
  37. // Set element size to given width and height
  38. , size: function(width, height) {
  39. var p = proportionalSize(this, width, height)
  40. return this.attr('d', this.array().size(p.width, p.height))
  41. }
  42. // Set width of element
  43. , width: function(width) {
  44. return width == null ? this.bbox().width : this.size(width, this.bbox().height)
  45. }
  46. // Set height of element
  47. , height: function(height) {
  48. return height == null ? this.bbox().height : this.size(this.bbox().width, height)
  49. }
  50. }
  51. // Add parent method
  52. , construct: {
  53. // Create a wrapped path element
  54. path: function(d) {
  55. // make sure plot is called as a setter
  56. return this.put(new SVG.Path).plot(d || new SVG.PathArray)
  57. }
  58. }
  59. })