-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
sites/cheerpx/src/content/docs/12-reference/13-CheerpX-Linux-setKmsCanvas.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
title: CheerpX.Linux#setKmsCanvas | ||
Description: Configure the KMS canvas for rendering graphical output in a CheerpX Linux instance. | ||
--- | ||
|
||
```ts | ||
namespace CheerpX { | ||
class Linux { | ||
setKmsCanvas( | ||
canvas: HTMLCanvasElement, | ||
width: number, | ||
height: number | ||
): void; | ||
} | ||
} | ||
``` | ||
|
||
## Parameters | ||
|
||
- **canvas: HTMLCanvasElement** - The `canvas` element in your HTML document that serves as the rendering surface. This is where graphical output is displayed. | ||
|
||
- **width: number** - The desired width of the canvas in pixels. | ||
|
||
- **height: number** - The desired height of the canvas in pixels. | ||
|
||
## Description | ||
|
||
The `setKmsCanvas` method configures a kernel-mode setting (KMS) canvas, enabling the CheerpX Linux instance to render graphical output, for example via Xorg. The dimensions of the canvas are defined by the `width` and `height` parameters, allowing the application to adapt to different display sizes dynamically. | ||
|
||
## Example | ||
|
||
```ts | ||
function setScreenSize(display) { | ||
const displayWidth = display.offsetWidth; | ||
const displayHeight = display.offsetHeight; | ||
|
||
cx.setKmsCanvas(display, displayWidth, displayHeight); | ||
} | ||
|
||
// Set up the canvas in a web application | ||
const canvasElement = document.getElementById("display"); | ||
setScreenSize(canvasElement); | ||
``` |