Skip to content

Instantly share code, notes, and snippets.

@spaceribs
Last active March 17, 2016 20:31
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spaceribs/7694120 to your computer and use it in GitHub Desktop.
Save spaceribs/7694120 to your computer and use it in GitHub Desktop.
paper.js angular directive using $http.get You can use this via: <paper src="scripts/papers/test.js" width="600" height="600"></paper>
'use strict';
angular.module('myApp')
.directive('paper', ['$http', function ($http) {
return {
replace: true,
template: '<canvas></canvas>',
restrict: 'E',
link: function postLink(scope, element, attrs) {
var scope = new paper.PaperScope();
scope.setup(element[0]);
$http.get(attrs.src).success(function (data) {
paper.PaperScript.evaluate(data, scope);
});
}
};
}]);
@spaceribs
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment