HTML canvas lineTo() Yöntemi
Örnek
Bir yola başlayın, 0, 0 konumuna gidin. 300, 150 konumuna bir çizgi oluşturun:
JavaScript:
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.beginPath();
ctx.moveTo(0, 0);
ctx.lineTo(300, 150);
ctx.stroke();
Tarayıcı Desteği
Tablodaki sayılar, yöntemi tam olarak destekleyen ilk tarayıcı sürümünü belirtir.
Method | |||||
---|---|---|---|---|---|
lineTo() | 4.0 | 9.0 | 3.6 | 4.0 | 10.1 |
Tanım ve Kullanım
lineTo() yöntemi yeni bir nokta ekler ve bu noktadan tuvalde belirtilen son noktaya bir çizgi oluşturur (bu yöntem çizgi çizmez).
İpucu: Yolu tuvale gerçekten çizmek için vuruş() yöntemini kullanın .
JavaScript sözdizimi: | bağlam .lineTo( x,y ); |
---|
Parametre Değerleri
Parameter | Description | Play it |
---|---|---|
x | The x-coordinate of where to create the line to | |
y | The y-coordinate of where to create the line to |
Daha fazla örnek
Örnek
L harfi şeklinde bir yol çizin:
JavaScript:
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.beginPath();
ctx.moveTo(20, 20);
ctx.lineTo(20, 100);
ctx.lineTo(70, 100);
ctx.stroke();
❮ Tuval Nesnesi