[ Leksykon ] [ JavaScript ] [ Metody ] [ Właściwości ] [ canvas ] [ HTMLCanvasElement() ]
HTMLCanvasElement.width
[_] [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 = 450;
const wys = 350;
const canvas = document.getElementById("canvas");
canvas.width = szer;
canvas.height = wys;
console.log(canvas.width);
const ctx = canvas.getContext("2d");
ctx.fillStyle = "green";
ctx.fillRect(0, 0, 80, 90);
return;
};
</script>
<canvas id="canvas" width="100" height="100"></canvas>
Opis:
Właściwość HTMLCanvasElement.width to integer odzwierciedlający width HTML atrybut elementu <canvas> interpretowany w pikselach CSS. Kiedy atrybut nie jest określony lub jeśli jest ustawiony na nieprawidłową wartość, na przykład ujemną, używana jest domyślna wartość 300.
Zobacz też:
HTMLCanvasElement() height - wysokość integer height HTML atrybut elementu <canvas>