I drew a polygon on an image and I want to move it with the mouse click, i have this error and i can not do them have you an idea please. for this problem i used the librairie Two.js and i can not do that
$scope.DrawPolygon = function (id, json)
{
var elem = document.getElementById('ImgCamera' + id);
if (elem != null)
{
elem.innerHTML = "";
var two = new Two({
type: Two.Types.canvas,
fullscreen: false,
width: 640,
height: 480,
}).appendTo(elem);
var canvas = two.renderer.domElement;
var img = $scope.spotCAMImageLoaded[_GetCameraNumberFromPolygonNumber(id)];
var texture = new Two.Texture(img, function () { });
var rect = two.makeRectangle(canvas.width / 2, canvas.height / 2, canvas.width, canvas.height);
rect.fill = texture;
rect.noStroke();
var jsonPoly = null;
var camera = json.Camera2;
if (_GetCameraNumberFromPolygonNumber(id) == 0)
camera = json.Camera1;
if (camera != null)
{
jsonPoly = camera[_GetPolygonNumberFromCameraNumber(id)];
var polygon = two.makePath([new Two.Anchor(jsonPoly.P1.x, jsonPoly.P1.y)
, new Two.Anchor(jsonPoly.P2.x, jsonPoly.P2.y)
, new Two.Anchor(jsonPoly.P3.x, jsonPoly.P3.y)
, new Two.Anchor(jsonPoly.P4.x, jsonPoly.P4.y)])
polygon.fill = "#008bbe";
polygon.opacity = 0.5;
polygon.stroke = "#00435c";
polygon.linewidth = 10;
polygon.renderer.elem.style.cursor = 'pointer';
two.update();
}
}