[ Leksykon ] [ JavaScript ] [ Metody ] [ Właściwości ] [ canvas ] [ CanvasRenderingContext2D ]
CanvasRenderingContext2D.save()
[_] [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]
save()
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.fillStyle = "blue";
ctx.fillRect(50, 50, 150, 150);
ctx.save();
ctx.fillStyle = "yellow";
ctx.fillRect(300, 50, 150, 150);
ctx.fillRect(50, 300, 150, 150);
ctx.restore();
ctx.fillRect(300, 300, 150, 150);
return;
};
</script>
<canvas id="canvas" width="100" height="100"></canvas>
Opis:
Metoda CanvasRenderingContext2D.save() zapisuje cały stan canvas poprzez wypychanie bieżącego stan na stos. Stan rysunku zapisywany na stosie składa się z: bieżąca macierz transformacji, bieżący region przycinania, aktualna lista myślników, bieżące wartości następujących atrybutów: strokeStyle, fillStyle, globalAlpha, lineWidth, lineCap, lineJoin, miterLimit, lineDashOffset, shadowOffsetX, shadowOffsetY, shadowBlur, shadowColor, globalCompositeOperation, font, textAlign, textBaseline, direction, imageSmoothingEnabled.
Zobacz też:
strokeStyle -
fillStyle -
globalAlpha -
lineWidth, lineCap -
lineJoin -
miterLimit -
lineDashOffset -
shadowOffsetX -
shadowOffsetY -
shadowBlur -
shadowColor -
globalCompositeOperation -
font -
textAlign -
textBaseline -
direction -
imageSmoothingEnabled -