[英]how to draw svg or canvas on image on specific cordinates
我有在圖像上選擇的坐標 (x1,y1)(x2,y2)(x3,y3)(x4,y4)。我想使用坐標繪制畫布(矩形)。如何做到這一點? 我曾嘗試使用此功能,但它不是在圖像上的特定坐標上繪制。
for(var i=0;i<_self.coordinatesxy.length;i++){
fnc( _self.coordinatesxy[i][0],_self.coordinatesxy[i][1],ci)
}
function fnc(x,y, ci){
console.log(x,y)
ci.lineTo(x,y);
}
ci.strokeStyle = 'red';
ci.lineWidth = 2; ci.stroke();
我不知道你所說的“不繪制特定坐標”是什么意思,它在哪里繪制? 一般來說,您的代碼看起來不錯。
ci.strokeStyle = 'red';
ci.lineWidth = 2;
ci.moveTo(_self.coordinatesxy[0][0],_self.coordinatesxy[0][1]);
for (var i = 1; i < _self.coordinatesxy.length; i++) {
ci.lineTo(_self.coordinatesxy[i][0],_self.coordinatesxy[i][1]);
}
ci.stroke();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.