diff -r 26ebb2f1e6e6 -r 764fbb013252 src/text.c --- a/src/text.c Fri Apr 12 22:03:15 2024 +0200 +++ b/src/text.c Fri Apr 12 22:22:07 2024 +0200 @@ -89,8 +89,7 @@ SDL_FreeSurface(surface); } -AscSceneNode *asc_text(int x, int y, char const *text) { - // TODO: implement fancy struct "named param" initialization +AscSceneNode *asc_text_create(struct asc_text_create_args args) { AscText *node = calloc(1, sizeof(AscText)); node->base.render_group = ASC_RENDER_GROUP_SPRITE_BLEND; @@ -98,14 +97,16 @@ node->base.update_func = (asc_scene_update_func) asc_text_update; node->base.draw_func = (asc_scene_draw_func) asc_text_draw; - node->base.position.x = (float) x; - node->base.position.y = (float) y; + node->base.flags = args.alignment; + node->base.position.x = (float) args.x; + node->base.position.y = (float) args.y; + node->max_width = args.max_width; node->font = asc_context.active_font; node->color = asc_context.ink; - if (text == NULL) { + if (args.text == NULL) { node->text = cx_mutstr(strdup(" ")); } else { - node->text = cx_mutstr(strdup(text)); + node->text = cx_mutstr(strdup(args.text)); } // initialize