თვისება lineWidth
თვისება lineWidth ადგენს სისქეს
ხაზისა ხატვისას canvas-ზე.
სინტაქსი
კონტექსტი.lineWidth = მთელი რიცხვი;
მაგალითი
დავხატოთ ხაზი და დავაყენოთ მას სისქე
5 პიქსელი:
<canvas id="canvas" width="200" height="200" style="background: #f4f4f4;"></canvas>
let canvas = document.querySelector('#canvas');
let ctx = canvas.getContext('2d');
ctx.beginPath();
ctx.lineWidth = 5; // სისქე 5px
ctx.moveTo(50, 50);
ctx.lineTo(150, 50);
ctx.stroke();
:
მაგალითი
სისქის შეცვლა ასევე შესაძლებელია კონტურებისთვის,
მაგალითად, rect-ით დახატულებისთვის:
<canvas id="canvas" width="200" height="200" style="background: #f4f4f4;"></canvas>
let canvas = document.querySelector('#canvas');
let ctx = canvas.getContext('2d');
ctx.rect(50, 50, 100, 100);
ctx.lineWidth = 5;
ctx.stroke();
: