簡體   English   中英

如何在特定坐標上的圖像上繪制 svg 或畫布

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM