diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-13 14:14:28 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-13 14:14:28 +0300 |
| commit | 339e1ad7adb8340732ee856d0f6f0d2c7f1455d1 (patch) | |
| tree | 55d2735987f240e5eaacf6581ed3ce5db2c0e3a8 /examples | |
| parent | e185a9d719d469a0fd7edcf09a6342f7b10cbb8e (diff) | |
Inline trivial internal helpers at their call sites
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/tablet.c | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/examples/tablet.c b/examples/tablet.c index 256d8f8..8a1af7e 100644 --- a/examples/tablet.c +++ b/examples/tablet.c @@ -43,16 +43,6 @@ static const char *device_name(enum yasl_pointer_device device) } } -static bool is_pen(enum yasl_pointer_device device) -{ - return device == YASL_PTR_DEV_PEN || device == YASL_PTR_DEV_ERASER; -} - -static double scale(const struct app *app) -{ - return (double)app->geometry.scale_120 / YASL_SCALE_UNIT; -} - static void cancel_stroke(struct app *app) { app->down = app->previous = app->visible = false; @@ -94,7 +84,9 @@ static void clear_canvas(struct app *app) static double brush_radius(const struct app *app) { - return scale(app) * (is_pen(app->pointer.device) ? + return ((double)app->geometry.scale_120 / YASL_SCALE_UNIT) * + ((app->pointer.device == YASL_PTR_DEV_PEN || + app->pointer.device == YASL_PTR_DEV_ERASER) ? 2 + 24 * ((double)app->pointer.pen.pressure / 65535) : 6); } @@ -121,7 +113,8 @@ static void stroke(struct app *app) double radius = brush_radius(app); /* Leaving the canvas breaks the line so re-entry cannot bridge the UI. */ if (x < 0 || x >= app->geometry.size.x || - y < HEADER * scale(app) || y >= app->geometry.size.y) { + y < HEADER * ((double)app->geometry.scale_120 / YASL_SCALE_UNIT) || + y >= app->geometry.size.y) { app->previous = false; return; } @@ -234,7 +227,7 @@ static void draw(struct yasl_surface *surface, struct yasl_frame *frame, void *u } struct yasl_framebuffer *fb = &frame->target; memcpy(fb->pixels, app->canvas, (size_t)geometry.size.x * geometry.size.y * sizeof(uint32_t)); - double dpi = scale(app); + double dpi = (double)app->geometry.scale_120 / YASL_SCALE_UNIT; rect(fb, 0, 0, fb->size.x, (int)lround(HEADER * dpi), PANEL); char line[128]; snprintf(line, sizeof(line), "YASL TABLET / %s / %s / %s", backend_name(app->backend), |
