0

I was able to draw a polygon correctly using Two.js inside my AngularJS app, and now I am trying to manipulate the polygon with my mouse. I created this function but it isn't working, can anyone help me figure out why?

$scope.DragAndDrop = function (shape) {
       $scope._Drag = function (event) {
            var x = event.ClientX - offset.x;
            var y = event.ClientY - offset.y;
            shape.translation.set(x, y);
       };

       $scope._DragEnd = function (event) {
           $window.unbind('mousemove', drag)
                .unbind('mouseup', dragEnd);
       }
        shape.bind('mousedown', function (event) {
            $window.bind('mousemouve', $scope._Drag)
            .bind('mouseup', $scope._DragEnd);
        });
    }   


 var polygon = two.makePath([new Two.Anchor(jsonPoly.P1.x/3, jsonPoly.P1.y/3)
                                         , new Two.Anchor(jsonPoly.P2.x/3, jsonPoly.P2.y/3)
                                         , new Two.Anchor(jsonPoly.P3.x/3, jsonPoly.P3.y/3)
                                         , new Two.Anchor(jsonPoly.P4.x/3, jsonPoly.P4.y/3)])


            polygon.fill = "#008bbe";
            polygon.opacity = 1;
            polygon.stroke = "#00435c";
            polygon.linewidth = 10;
caitlin
  • 2,769
  • 4
  • 29
  • 65
sani
  • 23
  • 7
  • You need to provide an explanation of what *kind* of polygon it was. How was it drawn? – caitlin Mar 28 '18 at 16:19
  • the polygon is drawing like this i added the code – sani Mar 29 '18 at 07:42
  • OK, so I looked up what "Two" is and it looks like you are using Two.js. People are not going to know what you're talking about- you need to say so explicitly (and tag your question) so that the Two.js experts will be able to find this question and help you. – caitlin Apr 04 '18 at 14:52

0 Answers0