我希望将坐标从文本字段传递到 HTML5 画布。我正在使用下面的代码在画布上绘制一个矩形。坐标应该是0,0,50,50
function displayObject(currentObject){
var imageNumber = $(currentObject).find('div.objectDd input.objectImageNum').val();
var objectCoordinates = $(currentObject).find('div.objectDd input.objectCoordinates').val();
var imageId = "";
var canvasId = "";
var context = "";
var canvas = "";
if(imageNumber != "" && objectCoordinates != ""){
imageId = "#imgNum".concat(imageNumber);
canvasId = $('#objectData').find('#miImages '+imageId+' .imageContainer canvas').attr("id");
canvas = document.getElementById(canvasId);
context = canvas.getContext("2d");
context.fillStyle = "#FF0000";
context.fillRect(objectCoordinates);
}
}
我尝试将它们作为变量传递,objectCoordinates
但未绘制矩形。
如何传递用户输入的坐标?