forked from Blendman974/faceclaw
Adapt layouts for Rayneo screen resolution
This commit is contained in:
1 parent
4d101eefe1
commit
dee60bbcd2
34 files changed
+721
-202
No files matched your search
@@ -1,23 +1,26 @@
|
||||
import { GrayImage, G2_LENS_WIDTH, G2_LENS_HEIGHT } from "../graphics/image";
|
||||
import { GrayImage } from "../graphics/image";
|
||||
import { screenHeight, screenWidth } from "../graphics/screen-size";
|
||||
import { getDefaultMediumFont } from "../graphics/ui-fonts";
|
||||
import { wrapText } from "../graphics/textwrap";
|
||||
|
||||
export const LOCK_SCREEN_SURFACE_ID = "lock-screen";
|
||||
const LOCK_SCREEN_MESSAGE = "Glasses locked; unlock the phone to unlock the glasses.";
|
||||
|
||||
/** The paired glasses' whole screen, black, with the message in a box at its centre. */
|
||||
export function createLockScreenImage(): GrayImage {
|
||||
const image = new GrayImage(G2_LENS_WIDTH, G2_LENS_HEIGHT, 0);
|
||||
const width = screenWidth(), height = screenHeight();
|
||||
const image = new GrayImage(width, height, 0);
|
||||
const font = getDefaultMediumFont();
|
||||
const boxWidth = 480;
|
||||
const boxHeight = 150;
|
||||
const boxX = Math.round((G2_LENS_WIDTH - boxWidth) / 2);
|
||||
const boxY = Math.round((G2_LENS_HEIGHT - boxHeight) / 2);
|
||||
const boxX = Math.round((width - boxWidth) / 2);
|
||||
const boxY = Math.round((height - boxHeight) / 2);
|
||||
image.drawRoundedRect(boxX, boxY, boxWidth, boxHeight, 150, 12);
|
||||
const lines = wrapText(font, LOCK_SCREEN_MESSAGE, boxWidth - 64);
|
||||
const textHeight = lines.length * font.lineHeight;
|
||||
const firstY = boxY + Math.round((boxHeight - textHeight) / 2);
|
||||
lines.forEach((line, index) => {
|
||||
const x = Math.round((G2_LENS_WIDTH - font.measureText(line)) / 2);
|
||||
const x = Math.round((width - font.measureText(line)) / 2);
|
||||
image.drawText(font, x, firstY + index * font.lineHeight, line, 230);
|
||||
});
|
||||
return image;
|
||||
|
||||
Reference in new issue
Block a user