OffscreenCanvasRenderingContext2D: phương thức commit()
Note: This feature is available in Web Workers.
Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
Non-standard: This feature is not standardized. We do not recommend using non-standard features in production, as they have limited browser support, and may change or be removed. However, they can be a suitable alternative in specific cases where no standard option exists.
Phương thức OffscreenCanvasRenderingContext2D.commit() của Canvas 2D API được thiết kế để sao chép bitmap của ngữ cảnh kết xuất sang bitmap của phần tử <canvas> placeholder của đối tượng OffscreenCanvas liên kết. Thao tác sao chép là đồng bộ. Không cần gọi phương thức này để chuyển đổi, vì nó diễn ra tự động trong quá trình thực thi vòng lặp sự kiện.
Cú pháp
commit()
Tham số
Không có.
Giá trị trả về
Không có (undefined).
Ví dụ
const placeholder = document.createElement("canvas");
const offscreen = placeholder.transferControlToOffscreen();
const ctx = offscreenCanvas.getContext("2d");
// Perform some drawing using the 2d context
ctx.fillStyle = "blue";
ctx.fillRect(0, 0, 10, 10);
// Push placeholder to the canvas element
ctx.commit();
Thông số kỹ thuật
Không thuộc bất kỳ thông số kỹ thuật nào.
Tương thích trình duyệt
Xem thêm
- Giao diện định nghĩa phương thức này:
OffscreenCanvasRenderingContext2D