// Lua: ucg.setFontPosCenter( self ) static int lucg_setFontPosCenter( lua_State *L ) { lucg_userdata_t *lud; if ((lud = get_lud( L )) == NULL) return 0; ucg_SetFontPosCenter( LUCG ); return 0; }
void draw_text_center(ucg_t *ucg) { prepare_picture(ucg); ucg_SetFont(ucg, ucg_font_ncenB18_tf); ucg_SetFontPosCenter(ucg); ucg_SetColor(ucg, 0, 0, 0, 255); /* draw blue "baseline" */ ucg_DrawHLine(ucg, 45+ox, 30, ucg_GetStrWidth(ucg, "Ucg")); ucg_SetColor(ucg, 0, 255, 255, 255); /* draw white "Ucg" */ ucg_DrawString(ucg, 45+ox, 30, 0, "Ucg"); pos(ucg, 45+ox, 30, 0); save_picture(ucg, "draw_text_center"); }
void pos(ucg_t *ucg, ucg_int_t x, ucg_int_t y, int is_right) { char s[20]; ucg_int_t w; prepare_measure(ucg); sprintf(s, "(%d,%d)", x-ox, y); w = ucg_GetStrWidth(ucg, s); ucg_DrawPixel(ucg, x, y); ucg_SetFontPosCenter(ucg); if ( is_right ) { ucg_DrawString(ucg, x+1, y, 0, s); //ucg_DrawHLine(ucg, x+1, y, w); } else { ucg_DrawString(ucg, x+1-w, y, 0, s); //ucg_DrawHLine(ucg, x+1-w, y, w); } }