-
Notifications
You must be signed in to change notification settings - Fork 11
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
2 changed files
with
61 additions
and
59 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
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,61 @@ | ||
--- | ||
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 width of the canvas in pixels. | ||
|
||
- **height: number** - The 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. 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) { | ||
// Determine scaling factor | ||
let scaleFactor = 1.0; | ||
const displayWidth = display.offsetWidth; | ||
const displayHeight = display.offsetHeight; | ||
|
||
// Minimum width and height for the canvas | ||
const minWidth = 1024; | ||
const minHeight = 768; | ||
|
||
// Adjust scale factor if the display is smaller than the minimum | ||
if (displayWidth < minWidth) { | ||
scaleFactor = minWidth / displayWidth; | ||
} | ||
if (displayHeight < minHeight) { | ||
scaleFactor = Math.max(scaleFactor, minHeight / displayHeight); | ||
} | ||
|
||
cx.setKmsCanvas( | ||
display, | ||
displayWidth * scaleFactor, | ||
displayHeight * scaleFactor | ||
); | ||
} | ||
|
||
// Set up the canvas in a web application | ||
const canvasElement = document.getElementById("display"); | ||
setScreenSize(canvasElement); | ||
``` |
59 changes: 0 additions & 59 deletions
59
sites/cheerpx/src/content/docs/12-reference/21-CheerpX-Linux-setKmsCanvas.md
This file was deleted.
Oops, something went wrong.