void vrule(ucg_t *ucg, ucg_int_t x, ucg_int_t y, ucg_int_t len, int is_right) { char s[10]; ucg_int_t o = rule_offset; ucg_int_t w; prepare_measure(ucg); sprintf(s, "%d", len); ucg_SetFontPosBaseline(ucg); w = ucg_GetStrWidth(ucg, s); if ( is_right ) { ucg_DrawVLine(ucg, x+o, y, len); ucg_DrawHLine(ucg, x-1+o, y, 3); ucg_DrawHLine(ucg, x-1+o, y+len-1, 3); ucg_SetFontPosBottom(ucg); ucg_DrawString(ucg, x+o-1, y + len/2 - w/2 + 1, 1, s); } else { ucg_DrawVLine(ucg, x-o, y, len); ucg_DrawHLine(ucg, x-1-o, y, 3); ucg_DrawHLine(ucg, x-1-o, y+len-1, 3); ucg_SetFontPosBottom(ucg); ucg_DrawString(ucg, x-o+1, y + len - ( len/2 - w/2 + 1), 3, s); } }
void solid_font_variants(ucg_t *ucg) { prepare_picture(ucg); ucg_SetColor(ucg, 0, 250, 0, 0); ucg_SetColor(ucg, 1, 255, 255, 30); ucg_SetColor(ucg, 2, 220, 235, 10); ucg_SetColor(ucg, 3, 205, 0, 30); ucg_DrawGradientBox(ucg, ox+0, 0, 128, 64); ucg_SetColor(ucg, 0, 0, 0, 0); /* draw black "Ucg" */ ucg_SetColor(ucg, 1, 150, 220, 255); /* light blue background */ ucg_SetFontMode(ucg, UCG_FONT_MODE_SOLID); ucg_SetFontPosBaseline(ucg); ucg_SetFont(ucg, ucg_font_fur11_tf); ucg_DrawString(ucg, 3+ox, 20, 0, "fur11_tf"); ucg_SetFont(ucg, ucg_font_fur11_hf); ucg_DrawString(ucg, 3+ox, 50, 0, "fur11_hf"); ucg_SetFont(ucg, ucg_font_fur11_hr); ucg_DrawString(ucg, 68+ox, 50, 0, "fur11_hr"); //pos(ucg, 42+ox, 40, 0); save_picture(ucg, "solid_font_variants"); }
// Lua: ucg.setFontPosBaseline( self ) static int lucg_setFontPosBaseline( lua_State *L ) { lucg_userdata_t *lud; if ((lud = get_lud( L )) == NULL) return 0; ucg_SetFontPosBaseline( LUCG ); return 0; }
void draw_text_dir1(ucg_t *ucg) { prepare_picture(ucg); ucg_SetFont(ucg, ucg_font_ncenB18_tf); ucg_SetFontPosBaseline(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, 10, 1, "Ucg"); pos(ucg, 45+ox, 10, 0); save_picture(ucg, "draw_text_dir1"); }
ucg_int_t ucg_Init(ucg_t *ucg, ucg_dev_fnptr device_cb, ucg_dev_fnptr ext_cb, ucg_com_fnptr com_cb) { ucg_int_t r; ucg_init_struct(ucg); if ( ext_cb == (ucg_dev_fnptr)0 ) ucg->ext_cb = ucg_ext_none; else ucg->ext_cb = ext_cb; ucg->device_cb = device_cb; ucg->com_cb = com_cb; ucg_SetFontPosBaseline(ucg); r = ucg_PowerUp(ucg); ucg_GetDimension(ucg); return r; }
void set_scale2x2(ucg_t *ucg) { prepare_picture(ucg); ucg_SetFont(ucg, ucg_font_ncenB18_tf); ucg_SetFontPosBaseline(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_SetScale2x2(ucg); ucg_DrawString(ucg, 20+ox, 20, 0, "Ucg"); ucg_UndoScale(ucg); pos(ucg, 40+ox, 40, 0); save_picture(ucg, "set_scale2x2"); }
void draw_text_ascent_descent(ucg_t *ucg) { prepare_picture(ucg); ucg_SetFont(ucg, ucg_font_ncenB24_tf); ucg_SetFontPosBaseline(ucg); ucg_SetColor(ucg, 0, 0, 0, 255); /* draw blue "baseline" */ ucg_DrawHLine(ucg, 42+ox, 30, ucg_GetStrWidth(ucg, "Ucg")); ucg_SetColor(ucg, 0, 255, 255, 255); /* draw white "Ucg" */ ucg_DrawString(ucg, 42+ox, 30, 0, "Ucg"); pos(ucg, 42+ox, 30, 0); ucg_SetFont(ucg, ucg_font_ncenB24_tf); vrule(ucg, 42+ox+ucg_GetStrWidth(ucg, "Ucg"), 30-ucg_GetFontAscent(ucg), ucg_GetFontAscent(ucg), 1); ucg_SetFont(ucg, ucg_font_ncenB24_tf); vrule(ucg, 42+ox+ucg_GetStrWidth(ucg, "Ucg"), 30, -ucg_GetFontDescent(ucg), 1); save_picture(ucg, "draw_text_ascent_descent"); }
void set_clip_range(ucg_t *ucg) { prepare_picture(ucg); ucg_SetFontPosBaseline(ucg); ucg_SetFont(ucg, ucg_font_ncenB18_tf); ucg_SetColor(ucg, 0, 255, 255, 255); /* draw white A */ ucg_DrawGlyph(ucg, 50, 40, 0, 'A'); ucg_SetClipRange(ucg, 57, 20, 30, 15); /* restrict area */ ucg_SetColor(ucg, 0, 0, 0, 127); ucg_DrawBox(ucg, 0, 0, 128, 64); /* fill the restricted area with dark blue */ ucg_SetColor(ucg, 0, 0, 0, 255); ucg_DrawGlyph(ucg, 50, 40, 0, 'A'); /* draw light blue A */ hrule(ucg, ox+57, 20, 30, 0); vrule(ucg, ox+57+30, 20, 15, 1); pos(ucg, ox+50, 40, 0); save_picture(ucg, "set_clip_range"); }
void set_font_mode_1(ucg_t *ucg) { prepare_picture(ucg); ucg_SetColor(ucg, 0, 255, 0, 0); ucg_SetColor(ucg, 1, 0, 255, 0); ucg_SetColor(ucg, 2, 255, 0, 255); ucg_SetColor(ucg, 3, 0, 255, 255); ucg_DrawGradientBox(ucg, ox+0, 0, 128, 64); ucg_SetFontMode(ucg, UCG_FONT_MODE_TRANSPARENT); ucg_SetFont(ucg, ucg_font_ncenB18_tf); ucg_SetFontPosBaseline(ucg); ucg_SetColor(ucg, 0, 0, 0, 0); /* draw black "Ucg" */ ucg_DrawString(ucg, 40+ox, 40, 0, "Ucg"); pos(ucg, 42+ox, 40, 0); save_picture(ucg, "set_font_mode_1"); }
void set_font_mode_2(ucg_t *ucg) { prepare_picture(ucg); ucg_SetColor(ucg, 0, 255, 0, 0); ucg_SetColor(ucg, 1, 0, 255, 0); ucg_SetColor(ucg, 2, 255, 0, 255); ucg_SetColor(ucg, 3, 0, 255, 255); ucg_DrawGradientBox(ucg, ox+0, 0, 128, 64); ucg_SetFontMode(ucg, UCG_FONT_MODE_SOLID); ucg_SetFont(ucg, ucg_font_ncenB18_hr); ucg_SetFontPosBaseline(ucg); ucg_SetColor(ucg, 0, 0, 0, 0); /* draw black "Ucg" */ ucg_SetColor(ucg, 1, 150, 220, 255); /* light blue background */ ucg_DrawString(ucg, 40+ox, 40, 0, "Ucg"); pos(ucg, 42+ox, 40, 0); save_picture(ucg, "set_font_mode_2"); }
void string_overwrite(ucg_t *ucg, int cnt) { char s[40]; int i; prepare_picture(ucg); ucg_SetColor(ucg, 0, 250, 0, 0); ucg_SetColor(ucg, 1, 255, 255, 30); ucg_SetColor(ucg, 2, 220, 235, 10); ucg_SetColor(ucg, 3, 205, 0, 30); ucg_DrawGradientBox(ucg, ox+0, 0, 128, 64); ucg_SetColor(ucg, 0, 0, 0, 0); /* draw black "Ucg" */ ucg_SetColor(ucg, 1, 150, 220, 255); /* light blue background */ ucg_SetFontMode(ucg, UCG_FONT_MODE_SOLID); ucg_SetFontPosBaseline(ucg); for( i = 11; i < 11+cnt; i++ ) { sprintf(s, "cu12_tf %d", i); ucg_SetFont(ucg, ucg_font_cu12_tf); ucg_DrawString(ucg, 1+ox, 15, 0, s); sprintf(s, "cu12_hf %d", i); ucg_SetFont(ucg, ucg_font_cu12_hf); ucg_DrawString(ucg, 1+ox, 35, 0, s); sprintf(s, "7x14_mf %d", i); ucg_SetFont(ucg, ucg_font_7x14_mf); ucg_DrawString(ucg, 1+ox, 55, 0, s); } //pos(ucg, 42+ox, 40, 0); sprintf(s, "string_overwrite_%d", cnt); save_picture(ucg, s); }