[ Leksykon ] [ JavaScript ] [ Metody ] [ Właściwości ] [ canvas ] [ CanvasRenderingContext2D ]
CanvasRenderingContext2D.getLineDash()
[_] [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]
getLineDash()
Przykłady:
<script>
window.onload = () => {
const szer = 600;
const wys = 600;
const canvas = document.getElementById("canvas");
canvas.width = szer;
canvas.height = wys;
const ctx = canvas.getContext("2d");
ctx.setLineDash([5, 10, 15, 20, 25, 30]);
//console.log(ctx.getLineDash());
ctx.beginPath();
ctx.moveTo(0, 25);
ctx.lineTo(400, 25);
ctx.stroke();
ctx.setLineDash([5, 3, 3, 3, 3, 3]);
ctx.beginPath();
ctx.moveTo(0, 50);
ctx.lineTo(400, 50);
ctx.stroke();
ctx.setLineDash([5, 10]);
ctx.beginPath();
ctx.moveTo(0, 75);
ctx.lineTo(400, 75);
ctx.stroke();
return;
};
</script>
<canvas id="canvas" width="100" height="100"></canvas>
Opis:
Metoda CanvasRenderingContext2D.getLineDash() pobiera bieżący wzór linii przerywanej. Wartość zwracana to liczba Array określająca odległości do naprzemiennego rysowania linii i odstępu, w jednostkach współrzędnych przestrzeni. Jeśli liczba przy ustawianiu elementów jest nieparzysta, elementy tablicy zostaną skopiowane i połączone.
Zobacz też: