HTML canvas lineTo() Yöntemi

❮ HTML Kanvas Referansı

Örnek

Bir yola başlayın, 0,0 konumuna gidin. 300.150 konumu için bir çizgi oluşturun:

TarayıcınızHTML5tuval etiketini desteklemiyor.

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() Yes 9.0 Yes Yes Yes

Tanım ve Kullanım

lineTo() yöntemi yeni bir nokta ekler ve tuvalde belirtilen son noktadan bu 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:

TarayıcınızHTMLtuval etiketini desteklemiyor.

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();


❮ HTML Kanvas Referansı