[ Leksykon ] [ JavaScript ] [ Metody ] [ Właściwości ] [ canvas ] [ CanvasRenderingContext2D ]
CanvasRenderingContext2D.lineWidth
[_] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z]
Przykłady:
<script>
window.onload = () => {
const szer = 600;
const wys = 300;
const canvas = document.getElementById("canvas");
canvas.width = szer;
canvas.height = wys;
const ctx = canvas.getContext("2d");
ctx.lineWidth = 25;
ctx.lineJoin = "round";
ctx.beginPath();
ctx.moveTo(25, 25);
ctx.lineTo(170, 110);
ctx.lineTo(450, 30);
ctx.lineTo(470, 100);
ctx.stroke();
ctx.lineWidth = 15;
["round", "bevel", "miter"].forEach((join, i) => {
ctx.lineJoin = join;
ctx.beginPath();
ctx.moveTo(10, 150 + i * 30);
ctx.lineTo(135, 195 + i * 30);
ctx.lineTo(175, 150 + i * 30);
ctx.lineTo(215, 195 + i * 30);
ctx.lineTo(455, 150 + i * 30);
ctx.stroke();
});
}
</script>
<canvas id="canvas" width="1" height="1"></canvas>
Opis:
Właściwość CanvasRenderingContext2D.lineWidth ustawia grubość linii. Liczba określająca szerokość linii, wyrażona w jednostkach przestrzeni współrzędnych. Wartości zero, ujemne Infinity i NaN są ignorowane. Wartość jest 1.0 domyślna.
Zobacz też: