From 153c1fb5ef0e55e86e09c868422dd43187c75ccc Mon Sep 17 00:00:00 2001 From: luboslenco Date: Fri, 18 Jul 2025 16:49:51 +0200 Subject: [PATCH] Fix stencil rotation --- base/sources/ts/ui_base.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/base/sources/ts/ui_base.ts b/base/sources/ts/ui_base.ts index 362c610b..8998f992 100644 --- a/base/sources/ts/ui_base.ts +++ b/base/sources/ts/ui_base.ts @@ -1295,10 +1295,8 @@ function ui_base_render_cursor() { } if (context_raw.brush_stencil_image != null && - // @ts-ignore context_raw.tool != workspace_tool_t.BAKE && context_raw.tool != workspace_tool_t.PICKER && - // @ts-ignore context_raw.tool != workspace_tool_t.MATERIAL && context_raw.tool != workspace_tool_t.COLORID) { let r: rect_t = ui_base_get_brush_stencil_rect(); @@ -1320,10 +1318,15 @@ function ui_base_render_cursor() { draw_rect(r.x - 8, r.y - 8 + r.h, 16, 16); draw_rect(r.x - 8 + r.w, r.y - 8 + r.h, 16, 16); // Rotate - let angle: f32 = context_raw.brush_stencil_angle; - draw_set_transform(mat3_multmat(mat3_multmat(mat3_translation(0.5, 0.5), mat3_rotation(-angle)), mat3_translation(-0.5, -0.5))); - draw_filled_circle(r.x + r.w / 2, r.y - 4, 8); - draw_set_transform(mat3_nan()); + let cosa: f32 = math_cos(-context_raw.brush_stencil_angle); + let sina: f32 = math_sin(-context_raw.brush_stencil_angle); + let ox: f32 = 0; + let oy: f32 = -r.h / 2; + let x: f32 = ox * cosa - oy * sina; + let y: f32 = ox * sina + oy * cosa; + x += r.x + r.w / 2; + y += r.y + r.h / 2; + draw_filled_circle(x, y, 8); } }