Created
April 18, 2014 12:20
-
-
Save nraynaud/11041186 to your computer and use it in GitHub Desktop.
markers for svg.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
define(['libs/svg'], (function () { | |
SVG.Marker = SVG.invent({ | |
create: 'marker', | |
inherit: SVG.Container, | |
extend: { | |
getRef: function () { | |
return 'url(#' + this.attr('id') + ')' | |
}, | |
update: function (block) { | |
this.clear(); | |
if (typeof block == 'function') | |
block.call(this, this) | |
return this | |
}, | |
toString: function () { | |
return this.getRef() | |
} | |
}, | |
construct: { | |
marker: function (refX, refY, width, height, block) { | |
return this.defs().marker(refX, refY, width, height, block) | |
} | |
} | |
}); | |
SVG.extend(SVG.Defs, { | |
// Define gradient | |
marker: function (refX, refY, width, height, block) { | |
return this.put(new SVG.Marker).update(block).attr({ | |
refX: refX, refY: refY, markerWidth: width, markerHeight: height, orient: 'auto' | |
}) | |
} | |
}); | |
SVG.extend(SVG.Container, { | |
// Define filter on defs | |
filter: function (block) { | |
return this.defs().filter(block) | |
} | |
}); | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment