3 #include "math/point.h"
5 #include "./wiggly_text.h"
7 #include "system/stacktrace.h"
8 #include "system/nth_alloc.h"
9 #include "system/str.h"
10 #include "game/camera.h"
12 int wiggly_text_render(const WigglyText *wiggly_text,
15 trace_assert(wiggly_text);
18 const size_t n = strlen(wiggly_text->text);
21 for (size_t i = 0; i < n; ++i) {
22 buf[0] = wiggly_text->text[i];
24 if (camera_render_text_screen(
30 wiggly_text->position,
32 (float) (i * FONT_CHAR_WIDTH) * wiggly_text->scale.x,
33 sinf(wiggly_text->angle + (float) i / (float) n * 10.0f) * 20.0f))) < 0) {
41 int wiggly_text_update(WigglyText *wiggly_text, float delta_time)
43 trace_assert(wiggly_text);
44 wiggly_text->angle = fmodf(wiggly_text->angle + 10.0f * delta_time, 2 * PI);
48 Vec wiggly_text_size(const WigglyText *wiggly_text, const Camera *camera)
50 trace_assert(wiggly_text);
52 const Rect boundary = camera_text_boundary_box(
58 return vec(boundary.w, boundary.h);