Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
  <head>
    <title>Home Page</title>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.min.js"></script>
  </head>
<body>
<div  ng-app="myapp"> 
<canvas id="canvas" width="2100" height="900" 
    style="border: 1px solid #d3d3d3;">
  <draw-circle x="500" y="500"></draw-circle>
  <draw-circle x="200" y="500"></draw-circle>
</canvas>
</div>
<script>
  var $scope;
  var app = angular.module('myapp', []);
  app.directive('drawCircle', function() {
    return {
      scope: {
        x: '@x',
        y: '@y'
      },
      link: function(scope, element, attrs) {
        var x = parseInt(scope.x);
        var y = parseInt(scope.y);
        var canvas = element.parent();
        var ctx = canvas[0].getContext("2d");
        ctx.beginPath();
        ctx.arc(x, y, 50, 0, 2 * Math.PI, false);
        ctx.lineWidth = 0.2;
        ctx.stroke();
        ctx.fill();
      }
    }
  });
</script>
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers