forked from Blendman974/faceclaw
Refactor font handling; add image-compression estimation debug option
This commit is contained in:
1 parent
5a92637537
commit
964cd11785
15 files changed
+389
-130
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { getDefaultSmallFont } from "../../graphics/bdffont";
|
||||
import { G2_LENS_HEIGHT, G2_LENS_WIDTH, GrayImage } from "../../graphics/image";
|
||||
import { Layer, type DashboardInputEvent, type LayerContext } from "../layers";
|
||||
|
||||
@@ -18,6 +19,7 @@ const SWATCH_HEIGHT = 16;
|
||||
export class ScreenTestLayer implements Layer {
|
||||
paint(ctx: LayerContext): GrayImage {
|
||||
const image = new GrayImage(G2_LENS_WIDTH, G2_LENS_HEIGHT, 0);
|
||||
const font = getDefaultSmallFont();
|
||||
|
||||
for (let value = 0; value < COLOR_VALUE_COUNT; value += COLOR_VALUE_STEP) {
|
||||
const slot = value / COLOR_VALUE_STEP;
|
||||
@@ -26,10 +28,10 @@ export class ScreenTestLayer implements Layer {
|
||||
const cellX = GRID_X + col * CELL_WIDTH;
|
||||
const cellY = row * CELL_HEIGHT;
|
||||
const label = String(value);
|
||||
const labelX = cellX + Math.max(0, Math.floor((CELL_WIDTH - ctx.font.measureText(label)) / 2));
|
||||
const labelX = cellX + Math.max(0, Math.floor((CELL_WIDTH - font.measureText(label)) / 2));
|
||||
const swatchX = cellX + Math.floor((CELL_WIDTH - SWATCH_WIDTH) / 2);
|
||||
|
||||
image.drawText(ctx.font, labelX, cellY + LABEL_Y_OFFSET, label, 185);
|
||||
image.drawText(font, labelX, cellY + LABEL_Y_OFFSET, label, 185);
|
||||
fillSwatch(image, swatchX, cellY + SWATCH_Y_OFFSET, SWATCH_WIDTH, SWATCH_HEIGHT, value);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user