Provides

ART.SVG.js

Some extensions (filters, dash, shadow blur)

License:
Public domain (http://unlicense.org).
Authors:
Yaroslaff Fedin
  1. 20
  2. 21
  3. 22
  4. 23
  5. 24
  6. 25
  7. 26
  8. 27
  9. 28
  10. 29
  11. 30
  12. 31
  13. 32
  14. 33
  15. 34
  16. 35
  17. 36
  18. 37
  19. 38
  20. 39
  21. 40
  22. 41
  23. 42
  24. 43
  25. 44
  26. 45
  27. 46
  28. 47
  29. 48
  30. 49
  31. 50
  32. 51
  33. 52
  34. 53
  35. 54
  36. 55
  37. 56
  38. 57
  39. 58
  40. 59
  41. 60
  42. 61
  43. 62
  44. 63
  45. 64
  46. 65
  47. 66
  48. 67
  49. 68
  50. 69
  51. 70
  52. 71
  53. 72
  54. 73
  55. 74
  56. 75
  57. 76
  58. 77
  59. 78
  60. 79
  61. 80
  62. 81
  63. 82
  64. 83
!function() { var NS = 'http://www.w3.org/2000/svg', XLINK = 'http://www.w3.org/1999/xlink', UID = 0, createElement = function(tag){ return document.createElementNS(NS, tag); }; ART.SVG.Base.implement({ dash: function(dash) { if (dash) { this.dashed = true; this.element.setAttribute('stroke-dasharray', dash); } else if (this.dashed) { this.dashed = false; this.element.removeAttribute('stroke-dasharray') } }, inject: function(container){ this.eject(); if (container instanceof ART.SVG.Group) container.children.push(this); this.parent.apply(this, arguments); this.container = container.defs ? container : container.container; this._injectBrush('fill'); this._injectBrush('stroke'); this._injectFilter('blur'); return this; }, strokeLinear: function(stops, angle){ var gradient = this._createGradient('stroke', 'linear', stops); angle = ((angle == null) ? 270 : angle) * Math.PI / 180; var x = Math.cos(angle), y = -Math.sin(angle), l = (Math.abs(x) + Math.abs(y)) / 2; x *= l; y *= l; gradient.setAttribute('x1', 0.5 - x); gradient.setAttribute('x2', 0.5 + x); gradient.setAttribute('y1', 0.5 - y); gradient.setAttribute('y2', 0.5 + y); return this; }, _writeTransform: function(){ if (Object.equals(this.transformed, this.transform)) return; this.transformed = $unlink(this.transform); var transforms = []; for (var transform in this.transform) transforms.push(transform + '(' + this.transform[transform].join(',') + ')'); this.element.setAttribute('transform', transforms.join(' ')); }, blur: function(radius){ if (radius == null) radius = 4; if (radius == this.blurred) return; this.blurred = radius; var filter = this._createFilter(); var blur = createElement('feGaussianBlur'); blur.setAttribute('stdDeviation', radius * 0.25); blur.setAttribute('result', 'blur'); filter.appendChild(blur);

in=SourceGraphic stdDeviation=“4” result=“blur”

  1. 86
  2. 87
  3. 88
  4. 89
  5. 90
  6. 91
  7. 92
  8. 93
  9. 94
  10. 95
  11. 96
  12. 97
  13. 98
  14. 99
  15. 100
  16. 101
  17. 102
  18. 103
  19. 104
  20. 105
  21. 106
  22. 107
  23. 108
  24. 109
  25. 110
  26. 111
  27. 112
  28. 113
  29. 114
  30. 115
  31. 116
  32. 117
  33. 118
  34. 119
  35. 120
  36. 121
  37. 122
  38. 123
return this; }, unblur: function() { delete this.blurred; this._ejectFilter(); }, _injectFilter: function(type){ if (!this.container) return; var filter = this.filter; if (filter) this.container.defs.appendChild(filter); }, _ejectFilter: function(type){ if (!this.container) return; var filter = this.filter; delete this.filter; if (filter) this.container.defs.removeChild(filter); }, _createFilter: function(){ this._ejectFilter(); var filter = this.filter = createElement('filter'); var id = 'filter-e' + this.uid; filter.setAttribute('id', id); this._injectFilter(); this.element.setAttribute('filter', 'url(#' + id + ')'); return filter; }, }); }();