From bf001d626530819822fecfe1f9b6c2f76e50a089 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Sat, 12 Jul 2025 20:20:34 +0200 Subject: [PATCH] Draw fixes --- armorpaint/shaders/layer_invert.kong | 1 - armorpaint/shaders/layer_view.kong | 1 - base/shaders/draw/draw_image.kong | 2 - base/shaders/draw/draw_image_transform.kong | 53 ++++++++++ base/shaders/draw/draw_rect.kong | 2 - base/shaders/draw/draw_text.kong | 2 - base/shaders/draw/draw_tris.kong | 2 - base/shaders/layer_copy.kong | 1 - base/shaders/layer_copy_bgra.kong | 1 - base/sources/iron_draw.c | 108 +++++++++----------- base/sources/iron_draw.h | 2 +- base/sources/ts/iron/iron.ts | 2 +- base/sources/ts/iron/sys.ts | 2 + base/sources/ts/ui_base.ts | 12 +-- 14 files changed, 110 insertions(+), 81 deletions(-) create mode 100644 base/shaders/draw/draw_image_transform.kong diff --git a/armorpaint/shaders/layer_invert.kong b/armorpaint/shaders/layer_invert.kong index 7db6b5de..66a1b8a0 100644 --- a/armorpaint/shaders/layer_invert.kong +++ b/armorpaint/shaders/layer_invert.kong @@ -1,7 +1,6 @@ #[set(everything)] const constants: { - W: float3x3; pos: float4; // xywh tex: float4; // xywh col: float4; diff --git a/armorpaint/shaders/layer_view.kong b/armorpaint/shaders/layer_view.kong index b34cc2ec..0d791ce8 100644 --- a/armorpaint/shaders/layer_view.kong +++ b/armorpaint/shaders/layer_view.kong @@ -1,7 +1,6 @@ #[set(everything)] const constants: { - W: float3x3; pos: float4; // xywh tex: float4; // xywh col: float4; diff --git a/base/shaders/draw/draw_image.kong b/base/shaders/draw/draw_image.kong index 045c2a6a..b58c5bdb 100644 --- a/base/shaders/draw/draw_image.kong +++ b/base/shaders/draw/draw_image.kong @@ -1,7 +1,6 @@ #[set(everything)] const constants: { - W: float3x3; pos: float4; // xywh tex: float4; // xywh col: float4; @@ -30,7 +29,6 @@ fun draw_image_vert(input: vert_in): vert_out { var ctex: float4 = constants.tex; output.pos = float4(input.pos, 0.0, 1.0); - output.pos.xyz = constants.W * output.pos.xyz; output.pos.xy = output.pos.xy * cpos.zw + cpos.xy; output.pos.xy = output.pos.xy * 2.0 - 1.0; output.pos.y = -output.pos.y; diff --git a/base/shaders/draw/draw_image_transform.kong b/base/shaders/draw/draw_image_transform.kong new file mode 100644 index 00000000..9eff93ff --- /dev/null +++ b/base/shaders/draw/draw_image_transform.kong @@ -0,0 +1,53 @@ + +#[set(everything)] +const constants: { + pos: float4; // xywh + tex: float4; // xywh + col: float4; + W: float3x3; +}; + +#[set(everything)] +const sampler_linear: sampler; + +#[set(everything)] +const tex: tex2d; + +struct vert_in { + pos: float2; +} + +struct vert_out { + pos: float4; + tex: float2; + col: float4; +} + +fun draw_image_vert(input: vert_in): vert_out { + var output: vert_out; + + var cpos: float4 = constants.pos; + var ctex: float4 = constants.tex; + + output.pos = float4(input.pos, 1.0, 1.0); + output.pos.xyz = constants.W * output.pos.xyz; + output.pos.z = 0.0; + output.pos.xy = output.pos.xy * cpos.zw + cpos.xy; + output.pos.xy = output.pos.xy * 2.0 - 1.0; + output.pos.y = -output.pos.y; + output.tex = input.pos * ctex.zw + ctex.xy; + output.col = constants.col; + return output; +} + +fun draw_image_frag(input: vert_out): float4 { + var texcolor: float4 = sample(tex, sampler_linear, input.tex) * input.col; + texcolor.rgb = texcolor.rgb * texcolor.a * input.col.a; + return texcolor; +} + +#[pipe] +struct pipe { + vertex = draw_image_vert; + fragment = draw_image_frag; +} diff --git a/base/shaders/draw/draw_rect.kong b/base/shaders/draw/draw_rect.kong index d0175d57..2251371e 100644 --- a/base/shaders/draw/draw_rect.kong +++ b/base/shaders/draw/draw_rect.kong @@ -1,7 +1,6 @@ #[set(everything)] const constants: { - W: float3x3; pos: float4; // xywh col: float4; }; @@ -21,7 +20,6 @@ fun draw_rect_vert(input: vert_in): vert_out { var cpos: float4 = constants.pos; output.pos = float4(input.pos, 0.0, 1.0); - // output.pos.xyz = constants.W * output.pos.xyz; output.pos.xy = output.pos.xy * cpos.zw + cpos.xy; output.pos.xy = output.pos.xy * 2.0 - 1.0; output.pos.y = -output.pos.y; diff --git a/base/shaders/draw/draw_text.kong b/base/shaders/draw/draw_text.kong index 14d4b5d5..df2b88e4 100644 --- a/base/shaders/draw/draw_text.kong +++ b/base/shaders/draw/draw_text.kong @@ -1,7 +1,6 @@ #[set(everything)] const constants: { - W: float3x3; pos: float4; // xywh tex: float4; // xywh col: float4; @@ -30,7 +29,6 @@ fun draw_text_vert(input: vert_in): vert_out { var ctex: float4 = constants.tex; output.pos = float4(input.pos, 0.0, 1.0); - // output.pos.xyz = constants.W * output.pos.xyz; output.pos.xy = output.pos.xy * cpos.zw + cpos.xy; output.pos.xy = output.pos.xy * 2.0 - 1.0; output.pos.y = -output.pos.y; diff --git a/base/shaders/draw/draw_tris.kong b/base/shaders/draw/draw_tris.kong index 82024d73..eb12b23e 100644 --- a/base/shaders/draw/draw_tris.kong +++ b/base/shaders/draw/draw_tris.kong @@ -1,7 +1,6 @@ #[set(everything)] const constants: { - W: float3x3; pos0: float2; pos1: float2; pos2: float2; @@ -28,7 +27,6 @@ fun draw_tris_vert(input: vert_in): vert_out { else if (vertex_id() == 2) { output.pos = float4(constants.pos2, 0.0, 1.0); } - // output.pos.xyz = constants.W * output.pos.xyz; output.pos.xy = output.pos.xy * 2.0 - 1.0; output.pos.y = -output.pos.y; output.col = constants.col; diff --git a/base/shaders/layer_copy.kong b/base/shaders/layer_copy.kong index 70a88a73..513c83ba 100644 --- a/base/shaders/layer_copy.kong +++ b/base/shaders/layer_copy.kong @@ -1,7 +1,6 @@ #[set(everything)] const constants: { - W: float3x3; pos: float4; // xywh tex: float4; // xywh col: float4; diff --git a/base/shaders/layer_copy_bgra.kong b/base/shaders/layer_copy_bgra.kong index c2ede951..cb108962 100644 --- a/base/shaders/layer_copy_bgra.kong +++ b/base/shaders/layer_copy_bgra.kong @@ -1,7 +1,6 @@ #[set(everything)] const constants: { - W: float3x3; pos: float4; // xywh tex: float4; // xywh col: float4; diff --git a/base/sources/iron_draw.c b/base/sources/iron_draw.c index 08d6787d..583d6e63 100644 --- a/base/sources/iron_draw.c +++ b/base/sources/iron_draw.c @@ -27,37 +27,27 @@ static gpu_buffer_t tris_vertex_buffer; static gpu_buffer_t tris_index_buffer; static gpu_vertex_structure_t draw_structure; -static gpu_shader_t image_vert_shader; -static gpu_shader_t image_frag_shader; static gpu_pipeline_t image_pipeline; +static gpu_pipeline_t image_transform_pipeline; static int image_tex_unit; -static int image_w_loc; static int image_pos_loc; static int image_tex_loc; static int image_col_loc; +static int image_transform_w_loc; -static gpu_shader_t rect_vert_shader; -static gpu_shader_t rect_frag_shader; static gpu_pipeline_t rect_pipeline; -static int rect_w_loc; static int rect_pos_loc; static int rect_col_loc; -static gpu_shader_t tris_vert_shader; -static gpu_shader_t tris_frag_shader; static gpu_pipeline_t tris_pipeline; -static int tris_w_loc; static int tris_pos0_loc; static int tris_pos1_loc; static int tris_pos2_loc; static int tris_col_loc; -static gpu_shader_t text_vert_shader; -static gpu_shader_t text_frag_shader; static gpu_pipeline_t text_pipeline; -static gpu_pipeline_t text_pipeline_rt; +static gpu_pipeline_t text_rt_pipeline; static int text_tex_unit; -static int text_w_loc; static int text_pos_loc; static int text_tex_loc; static int text_col_loc; @@ -105,8 +95,8 @@ static void draw_pipeline_init(gpu_pipeline_t *pipe, gpu_shader_t *vert, gpu_sha pipe->fragment_shader = frag; } -void draw_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *rect_vert, buffer_t *rect_frag, buffer_t *tris_vert, buffer_t *tris_frag, buffer_t *text_vert, buffer_t *text_frag) { - draw_transform = iron_matrix3x3_identity(); +void draw_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *image_transform_vert, buffer_t *image_transform_frag, buffer_t *rect_vert, buffer_t *rect_frag, buffer_t *tris_vert, buffer_t *tris_frag, buffer_t *text_vert, buffer_t *text_frag) { + draw_transform = mat3_nan(); draw_structure.size = 0; gpu_vertex_structure_add(&draw_structure, "pos", GPU_VERTEX_DATA_F32_2X); @@ -153,61 +143,66 @@ void draw_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *rect_vert, gpu_index_buffer_unlock(&tris_index_buffer); } + gpu_shader_t vert_shader; + gpu_shader_t frag_shader; + // Image painter { - gpu_shader_init(&image_vert_shader, image_vert->buffer, image_vert->length, GPU_SHADER_TYPE_VERTEX); - gpu_shader_init(&image_frag_shader, image_frag->buffer, image_frag->length, GPU_SHADER_TYPE_FRAGMENT); - draw_pipeline_init(&image_pipeline, &image_vert_shader, &image_frag_shader); + gpu_shader_init(&vert_shader, image_vert->buffer, image_vert->length, GPU_SHADER_TYPE_VERTEX); + gpu_shader_init(&frag_shader, image_frag->buffer, image_frag->length, GPU_SHADER_TYPE_FRAGMENT); + draw_pipeline_init(&image_pipeline, &vert_shader, &frag_shader); gpu_pipeline_compile(&image_pipeline); image_tex_unit = 0; - image_w_loc = 0; - image_pos_loc = 48; - image_tex_loc = 64; - image_col_loc = 80; + image_pos_loc = 0; + image_tex_loc = 16; + image_col_loc = 32; + + gpu_shader_init(&vert_shader, image_transform_vert->buffer, image_transform_vert->length, GPU_SHADER_TYPE_VERTEX); + gpu_shader_init(&frag_shader, image_transform_frag->buffer, image_transform_frag->length, GPU_SHADER_TYPE_FRAGMENT); + draw_pipeline_init(&image_transform_pipeline, &vert_shader, &frag_shader); + gpu_pipeline_compile(&image_transform_pipeline); + image_transform_w_loc = 48; } // Rect painter { - gpu_shader_init(&rect_vert_shader, rect_vert->buffer, rect_vert->length, GPU_SHADER_TYPE_VERTEX); - gpu_shader_init(&rect_frag_shader, rect_frag->buffer, rect_frag->length, GPU_SHADER_TYPE_FRAGMENT); - draw_pipeline_init(&rect_pipeline, &rect_vert_shader, &rect_frag_shader); + gpu_shader_init(&vert_shader, rect_vert->buffer, rect_vert->length, GPU_SHADER_TYPE_VERTEX); + gpu_shader_init(&frag_shader, rect_frag->buffer, rect_frag->length, GPU_SHADER_TYPE_FRAGMENT); + draw_pipeline_init(&rect_pipeline, &vert_shader, &frag_shader); rect_pipeline.blend_source = GPU_BLEND_SOURCE_ALPHA; gpu_pipeline_compile(&rect_pipeline); - rect_w_loc = 0; - rect_pos_loc = 48; - rect_col_loc = 64; + rect_pos_loc = 0; + rect_col_loc = 16; } // Tris painter { - gpu_shader_init(&tris_vert_shader, tris_vert->buffer, tris_vert->length, GPU_SHADER_TYPE_VERTEX); - gpu_shader_init(&tris_frag_shader, tris_frag->buffer, tris_frag->length, GPU_SHADER_TYPE_FRAGMENT); - draw_pipeline_init(&tris_pipeline, &tris_vert_shader, &tris_frag_shader); + gpu_shader_init(&vert_shader, tris_vert->buffer, tris_vert->length, GPU_SHADER_TYPE_VERTEX); + gpu_shader_init(&frag_shader, tris_frag->buffer, tris_frag->length, GPU_SHADER_TYPE_FRAGMENT); + draw_pipeline_init(&tris_pipeline, &vert_shader, &frag_shader); tris_pipeline.blend_source = GPU_BLEND_SOURCE_ALPHA; gpu_pipeline_compile(&tris_pipeline); - tris_w_loc = 0; - tris_pos0_loc = 48; - tris_pos1_loc = 56; - tris_pos2_loc = 64; - tris_col_loc = 80; // 16 align + tris_pos0_loc = 0; + tris_pos1_loc = 8; + tris_pos2_loc = 16; + tris_col_loc = 32; // 16 align } // Text painter { - gpu_shader_init(&text_vert_shader, text_vert->buffer, text_vert->length, GPU_SHADER_TYPE_VERTEX); - gpu_shader_init(&text_frag_shader, text_frag->buffer, text_frag->length, GPU_SHADER_TYPE_FRAGMENT); - draw_pipeline_init(&text_pipeline, &text_vert_shader, &text_frag_shader); + gpu_shader_init(&vert_shader, text_vert->buffer, text_vert->length, GPU_SHADER_TYPE_VERTEX); + gpu_shader_init(&frag_shader, text_frag->buffer, text_frag->length, GPU_SHADER_TYPE_FRAGMENT); + draw_pipeline_init(&text_pipeline, &vert_shader, &frag_shader); text_pipeline.blend_source = GPU_BLEND_SOURCE_ALPHA; gpu_pipeline_compile(&text_pipeline); text_tex_unit = 0; - text_w_loc = 0; - text_pos_loc = 48; - text_tex_loc = 64; - text_col_loc = 80; + text_pos_loc = 0; + text_tex_loc = 16; + text_col_loc = 32; - draw_pipeline_init(&text_pipeline_rt, &text_vert_shader, &text_frag_shader); - text_pipeline_rt.blend_source = GPU_BLEND_SOURCE_ALPHA; - gpu_pipeline_compile(&text_pipeline_rt); + draw_pipeline_init(&text_rt_pipeline, &vert_shader, &frag_shader); + text_rt_pipeline.blend_source = GPU_BLEND_SOURCE_ALPHA; + gpu_pipeline_compile(&text_rt_pipeline); } } @@ -228,10 +223,15 @@ void draw_end(void) { } void draw_scaled_sub_image(gpu_texture_t *tex, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh) { - gpu_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : &image_pipeline); + if (mat3_isnan(draw_transform)) { + gpu_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : &image_pipeline); + } + else { + gpu_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : &image_transform_pipeline); + gpu_set_matrix3(image_transform_w_loc, draw_transform); + } gpu_set_vertex_buffer(&rect_vertex_buffer); gpu_set_index_buffer(&rect_index_buffer); - gpu_set_matrix3(image_w_loc, draw_transform); gpu_set_float4(image_pos_loc, dx / vw(), dy / vh(), dw / vw(), dh / vh()); gpu_set_float4(image_tex_loc, sx / tex->width, sy / tex->height, sw / tex->width, sh / tex->height); gpu_set_float4(image_col_loc, _draw_color_r(draw_color) / 255.0, _draw_color_g(draw_color) / 255.0, _draw_color_b(draw_color) / 255.0, _draw_color_a(draw_color) / 255.0); @@ -255,7 +255,6 @@ void draw_filled_triangle(float x0, float y0, float x1, float y1, float x2, floa gpu_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : &tris_pipeline); gpu_set_vertex_buffer(&tris_vertex_buffer); gpu_set_index_buffer(&tris_index_buffer); - gpu_set_matrix3(tris_w_loc, draw_transform); gpu_set_float2(tris_pos0_loc, x0 / vw(), y0 / vh()); gpu_set_float2(tris_pos1_loc, x1 / vw(), y1 / vh()); gpu_set_float2(tris_pos2_loc, x2 / vw(), y2 / vh()); @@ -267,7 +266,6 @@ void draw_filled_rect(float x, float y, float width, float height) { gpu_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : &rect_pipeline); gpu_set_vertex_buffer(&rect_vertex_buffer); gpu_set_index_buffer(&rect_index_buffer); - gpu_set_matrix3(rect_w_loc, draw_transform); gpu_set_float4(rect_pos_loc, x / vw(), y / vh(), width / vw(), height / vh()); gpu_set_float4(rect_col_loc, _draw_color_r(draw_color) / 255.0, _draw_color_g(draw_color) / 255.0, _draw_color_b(draw_color) / 255.0, _draw_color_a(draw_color) / 255.0); gpu_draw(); @@ -515,7 +513,7 @@ void draw_string(const char *text, float x, float y) { float ypos = y + img->baseline; draw_font_aligned_quad_t q; - gpu_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : _draw_current != NULL ? &text_pipeline_rt : &text_pipeline); + gpu_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : _draw_current != NULL ? &text_rt_pipeline : &text_pipeline); gpu_set_vertex_buffer(&rect_vertex_buffer); gpu_set_index_buffer(&rect_index_buffer); gpu_set_texture(text_tex_unit, img->tex); @@ -529,7 +527,6 @@ void draw_string(const char *text, float x, float y) { xpos += q.xadvance; gpu_set_float4(text_pos_loc, q.x0 / vw(), q.y0 / vh(), (q.x1 - q.x0) / vw(), (q.y1 - q.y0) / vh()); gpu_set_float4(text_tex_loc, q.s0, q.t0, q.s1 - q.s0, q.t1 - q.t0); - gpu_set_matrix3(text_w_loc, draw_transform); gpu_set_float4(text_col_loc, _draw_color_r(draw_color) / 255.0, _draw_color_g(draw_color) / 255.0, _draw_color_b(draw_color) / 255.0, _draw_color_a(draw_color) / 255.0); gpu_draw(); } @@ -702,12 +699,7 @@ void draw_set_pipeline(gpu_pipeline_t *pipeline) { } void draw_set_transform(mat3_t matrix) { - if (mat3_isnan(matrix)) { - draw_transform = iron_matrix3x3_identity(); - } - else { - draw_transform = matrix; - } + draw_transform = matrix; } bool draw_set_font(draw_font_t *font, int size) { diff --git a/base/sources/iron_draw.h b/base/sources/iron_draw.h index fe2983e4..568babc0 100644 --- a/base/sources/iron_draw.h +++ b/base/sources/iron_draw.h @@ -26,7 +26,7 @@ typedef struct draw_font { int index; } draw_font_t; -void draw_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *rect_vert, buffer_t *rect_frag, buffer_t *tris_vert, buffer_t *tris_frag, buffer_t *text_vert, buffer_t *text_frag); +void draw_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *image_transform_vert, buffer_t *image_transform_frag, buffer_t *rect_vert, buffer_t *rect_frag, buffer_t *tris_vert, buffer_t *tris_frag, buffer_t *text_vert, buffer_t *text_frag); void draw_begin(gpu_texture_t *target, bool clear, unsigned color); void draw_scaled_sub_image(gpu_texture_t *img, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh); void draw_scaled_image(gpu_texture_t *tex, float dx, float dy, float dw, float dh); diff --git a/base/sources/ts/iron/iron.ts b/base/sources/ts/iron/iron.ts index 7981e327..fe6b6a25 100644 --- a/base/sources/ts/iron/iron.ts +++ b/base/sources/ts/iron/iron.ts @@ -288,7 +288,7 @@ declare function iron_get_arg(index: i32): string; declare function iron_get_files_location(): string; declare function _iron_http_request(url: string, size: i32, callback: (url: string, _: buffer_t)=>void): void; -declare function draw_init(image_vert: buffer_t, image_frag: buffer_t, rect_vert: buffer_t, rect_frag: buffer_t, tris_vert: buffer_t, tris_frag: buffer_t, text_vert: buffer_t, text_frag: buffer_t): void; +declare function draw_init(image_vert: buffer_t, image_frag: buffer_t, image_transform_vert: buffer_t, image_transform_frag: buffer_t, rect_vert: buffer_t, rect_frag: buffer_t, tris_vert: buffer_t, tris_frag: buffer_t, text_vert: buffer_t, text_frag: buffer_t): void; declare function draw_begin(render_target: gpu_texture_t = null, clear: bool = false, color: u32 = 0): void; declare function draw_end(): void; declare function draw_scaled_sub_image(image: gpu_texture_t, sx: f32, sy: f32, sw: f32, sh: f32, dx: f32, dy: f32, dw: f32, dh: f32): void; diff --git a/base/sources/ts/iron/sys.ts b/base/sources/ts/iron/sys.ts index 3f08bfd3..4ef7a9a2 100644 --- a/base/sources/ts/iron/sys.ts +++ b/base/sources/ts/iron/sys.ts @@ -47,6 +47,8 @@ function sys_start(ops: iron_window_options_t) { draw_init( iron_load_blob(data_path() + "draw_image.vert" + sys_shader_ext()), iron_load_blob(data_path() + "draw_image.frag" + sys_shader_ext()), + iron_load_blob(data_path() + "draw_image_transform.vert" + sys_shader_ext()), + iron_load_blob(data_path() + "draw_image_transform.frag" + sys_shader_ext()), iron_load_blob(data_path() + "draw_rect.vert" + sys_shader_ext()), iron_load_blob(data_path() + "draw_rect.frag" + sys_shader_ext()), iron_load_blob(data_path() + "draw_tris.vert" + sys_shader_ext()), diff --git a/base/sources/ts/ui_base.ts b/base/sources/ts/ui_base.ts index 753772a6..362c610b 100644 --- a/base/sources/ts/ui_base.ts +++ b/base/sources/ts/ui_base.ts @@ -1305,9 +1305,7 @@ function ui_base_render_cursor() { if (!operator_shortcut(map_get(config_keymap, "stencil_hide"), shortcut_type_t.DOWN)) { draw_set_color(0x88ffffff); let angle: f32 = context_raw.brush_stencil_angle; - let cx: f32 = r.x + r.w / 2; - let cy: f32 = r.y + r.h / 2; - draw_set_transform(mat3_multmat(mat3_multmat(mat3_translation(cx, cy), mat3_rotation(-angle)), mat3_translation(-cx, -cy))); + draw_set_transform(mat3_multmat(mat3_multmat(mat3_translation(0.5, 0.5), mat3_rotation(-angle)), mat3_translation(-0.5, -0.5))); draw_scaled_image(context_raw.brush_stencil_image, r.x, r.y, r.w, r.h); draw_set_transform(mat3_nan()); draw_set_color(0xffffffff); @@ -1323,9 +1321,7 @@ function ui_base_render_cursor() { draw_rect(r.x - 8 + r.w, r.y - 8 + r.h, 16, 16); // Rotate let angle: f32 = context_raw.brush_stencil_angle; - let cx: f32 = r.x + r.w / 2; - let cy: f32 = r.y + r.h / 2; - draw_set_transform(mat3_multmat(mat3_multmat(mat3_translation(cx, cy), mat3_rotation(-angle)), mat3_translation(-cx, -cy))); + 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()); } @@ -1381,9 +1377,7 @@ function ui_base_render_cursor() { draw_set_color(color_from_floats(1, 1, 1, decal_alpha)); let angle: f32 = (context_raw.brush_angle + context_raw.brush_nodes_angle) * (math_pi() / 180); - let cx: f32 = decalx + psizex / 2; - let cy: f32 = decaly + psizey / 2; - draw_set_transform(mat3_multmat(mat3_multmat(mat3_translation(cx, cy), mat3_rotation(angle)), mat3_translation(-cx, -cy))); + draw_set_transform(mat3_multmat(mat3_multmat(mat3_translation(0.5, 0.5), mat3_rotation(angle)), mat3_translation(-0.5, -0.5))); draw_scaled_image(context_raw.decal_image, decalx, decaly, psizex, psizey); draw_set_transform(mat3_nan()); draw_set_color(0xffffffff);