Skip to content

Commit

Permalink
Text Cursor optimized.
Browse files Browse the repository at this point in the history
  • Loading branch information
Seng-Jik committed Mar 2, 2022
1 parent f1b165e commit ca6d45e
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions cpymo/cpymo_textbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,21 @@ void cpymo_textbox_draw(
}

if (tb->msg_cursor_visible) {
float ratio =
tb->character_size
/ (float)(e->say.msg_cursor_w > e->say.msg_cursor_h ? e->say.msg_cursor_w : e->say.msg_cursor_h);

if (ratio > 1) ratio = 1;

ratio *= 0.75f;

float cursor_w = ratio * (float)e->say.msg_cursor_w;
float cursor_h = ratio * (float)e->say.msg_cursor_h;

cpymo_backend_image_draw(
tb->x + tb->width - (float)e->say.msg_cursor_w,
tb->y + (tb->max_lines) * tb->character_size - (float)e->say.msg_cursor_h,
(float)e->say.msg_cursor_w, (float)e->say.msg_cursor_h,
tb->x + tb->width - cursor_w,
tb->y + (tb->max_lines) * tb->character_size - cursor_h,
cursor_w, cursor_h,
e->say.msg_cursor, 0, 0, e->say.msg_cursor_w, e->say.msg_cursor_h,
1.0f, drawtype);
}
Expand Down

0 comments on commit ca6d45e

Please sign in to comment.