Skip to content

Commit

Permalink
edit text, simplified code
Browse files Browse the repository at this point in the history
  • Loading branch information
AtibQur committed Nov 21, 2024
1 parent 3827562 commit 9715310
Showing 1 changed file with 4 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,22 @@ namespace CheerpX {

- **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.
- **width: number** - The desired width of the canvas in pixels.

- **height: number** - The height 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. The dimensions of the canvas are defined by the `width` and `height` parameters, allowing the application to adapt to different display sizes dynamically.
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) {
// 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
);
cx.setKmsCanvas(display, displayWidth, displayHeight);
}

// Set up the canvas in a web application
Expand Down

0 comments on commit 9715310

Please sign in to comment.