summaryrefslogtreecommitdiffstats
path: root/src/image.js
blob: b01897df704f6ab5574be9a8bf64e3a09ac9ecc8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
SVG.Image = function() {
  this.constructor.call(this, SVG.create('image'))
}

// Inherit from SVG.Element
SVG.Image.prototype = new SVG.Shape

//
SVG.extend(SVG.Image, {
  
  // (re)load image
  load: function(url) {
    return (url ? this.attr('xlink:href', (this.src = url), SVG.xlink) : this)
  }
  
})

//
SVG.extend(SVG.Container, {
  // Create image element, load image and set its size
  image: function(source, width, height) {
    width = width != null ? width : 100
    return this.put(new SVG.Image().load(source).size(width, height != null ? height : width))
  }

})