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"); }
void prepare_measure(ucg_t *ucg) { ucg_SetMaxClipRange(ucg); ucg_SetColor(ucg, 0, 255, 160, 63); ucg_SetFont(ucg, ucg_font_6x12_tf); ucg_SetFontMode(ucg, UCG_FONT_MODE_TRANSPARENT); }
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 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); }
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"); }
// Lua: ucg.setFont( self, font ) static int lucg_setFont( lua_State *L ) { lucg_userdata_t *lud; if ((lud = get_lud( L )) == NULL) return 0; ucg_fntpgm_uint8_t *font = (ucg_fntpgm_uint8_t *)lua_touserdata( L, 2 ); if (font != NULL) ucg_SetFont( LUCG, font ); else luaL_argerror(L, 2, "font data expected"); return 0; }
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 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"); }
int main(void) { ucg_Init(&ucg, &ucg_sdl_dev_cb, ucg_ext_none, (ucg_com_fnptr)0); //ucg_SetFontMode(&ucg, UCG_FONT_MODE_TRANSPARENT); ucg_SetFont(&ucg, ucg_font_ncenB24_tf); /* ucg_SetColor(&ucg, 0, 255, 180, 40); ucg_DrawGlyph(&ucg, 64, 32,0, 'A'); ucg_SetColor(&ucg, 0, 255, 200, 70); ucg_DrawGlyph(&ucg, 64, 32,1, 'A'); ucg_SetColor(&ucg, 0, 255, 180, 40); ucg_DrawGlyph(&ucg, 64, 32,2, 'A'); ucg_SetColor(&ucg, 0, 255, 200, 70); ucg_DrawGlyph(&ucg, 64, 32,3, 'A'); */ ucg_SetColor(&ucg, 0, 255, 180, 40); ucg_DrawString(&ucg, 64, 32,0, "AB"); ucg_SetColor(&ucg, 0, 255, 200, 70); ucg_DrawString(&ucg, 64, 32,1, "AB"); ucg_SetColor(&ucg, 0, 255, 180, 40); ucg_DrawString(&ucg, 64, 32,2, "AB"); ucg_SetColor(&ucg, 0, 255, 200, 70); ucg_DrawString(&ucg, 64, 32,3, "AB"); ucg_SetColor(&ucg, 0, 128, 128, 255); ucg_DrawPixel(&ucg, 64, 32); //ucg_DrawHLine(&ucg, 0,64,20); while( ucg_sdl_get_key() < 0 ) ; return 0; }
int main(void) { tga_init(128,64); ucg_Init(&ucg, &ucg_dev_tga, ucg_ext_none, (ucg_com_fnptr)0); ucg_SetFontMode(&ucg, UCG_FONT_MODE_TRANSPARENT); ucg_SetColor(&ucg, 0, 0, 0, 0); ucg_DrawBox(&ucg, 0, 0, 128, 64); ucg_SetFont(&ucg, ucg_font_ncenB18_tf); ucg_SetColor(&ucg, 0, 0, 0, 255); ucg_DrawPixel(&ucg, 70,20); ucg_SetColor(&ucg, 0, 255, 0, 0); //ucg_SetFontPosBottom(&ucg); /* ucg_DrawGlyph(&ucg, 70, 20, 0, 'A'); ucg_DrawGlyph(&ucg, 70, 20, 1, 'A'); ucg_DrawGlyph(&ucg, 70, 20, 2, 'A'); ucg_DrawGlyph(&ucg, 70, 20, 3, 'A'); ucg_SetColor(&ucg, 0, 255, 255, 255); vrule(&ucg, 30, 0, 20, 1); vrule(&ucg, 30, 0, 20, 0); */ //pos(&ucg, 70, 20, 0); //hrule(&ucg, 0, 20, 70, 1); //hrule(&ucg, 0, 20, 70, 0); 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_DrawGradientLine(&ucg, 10, 40, 100, 0); ucg_DrawGradientBox(&ucg, 10, 43, 100, 20); tga_save("test.tga"); draw_pixel(&ucg); draw_hline(&ucg); draw_vline(&ucg); set_clip_range(&ucg); draw_text_baseline(&ucg); draw_text_bottom(&ucg); draw_text_top(&ucg); draw_text_center(&ucg); draw_text_ascent_descent(&ucg); draw_text_dir1(&ucg); draw_box(&ucg); draw_frame(&ucg); draw_rbox(&ucg); draw_rframe(&ucg); draw_gradient_box(&ucg); draw_gradient_line(&ucg); draw_disc(&ucg); draw_circle(&ucg); draw_triangle(&ucg); set_scale2x2(&ucg); set_font_mode_1(&ucg); set_font_mode_2(&ucg); solid_font_variants(&ucg); string_overwrite(&ucg, 1); string_overwrite(&ucg, 5); string_overwrite(&ucg, 10); return 0; }
int main(void) { ucg_int_t a,b; ucg_Init(&ucg, ucg_sdl_dev_cb, ucg_ext_none, (ucg_com_fnptr)0); ucg_SetFontMode(&ucg, UCG_FONT_MODE_TRANSPARENT); ucg_SetFont(&ucg, ucg_font_ncenB24); //ucg_SetRotate90(&ucg); //ucg_SetRotate270(&ucg); //ucg_SetClipRange(&ucg, 10,5,40,20); a = 2; b = 3; ucg_SetColor(&ucg, 0, 135*a/b,206*a/b,250*a/b); ucg_SetColor(&ucg, 1, 176*a/b,226*a/b,255*a/b); ucg_SetColor(&ucg, 2, 25*a/b,25*a/b,112*a/b); ucg_SetColor(&ucg, 3, 85*a/b,26*a/b,139*a/b); ucg_DrawGradientBox(&ucg, 0, 0, ucg_GetWidth(&ucg)/4, ucg_GetHeight(&ucg)); ucg_SetColor(&ucg, 1, 135*a/b,206*a/b,250*a/b); ucg_SetColor(&ucg, 0, 176*a/b,226*a/b,255*a/b); ucg_SetColor(&ucg, 3, 25*a/b,25*a/b,112*a/b); ucg_SetColor(&ucg, 2, 85*a/b,26*a/b,139*a/b); ucg_DrawGradientBox(&ucg, ucg_GetWidth(&ucg)/4, 0, ucg_GetWidth(&ucg)/4, ucg_GetHeight(&ucg)); ucg_SetColor(&ucg, 0, 135*a/b,206*a/b,250*a/b); ucg_SetColor(&ucg, 1, 176*a/b,226*a/b,255*a/b); ucg_SetColor(&ucg, 2, 25*a/b,25*a/b,112*a/b); ucg_SetColor(&ucg, 3, 85*a/b,26*a/b,139*a/b); ucg_DrawGradientBox(&ucg, ucg_GetWidth(&ucg)*2/4, 0, ucg_GetWidth(&ucg)/4, ucg_GetHeight(&ucg)); ucg_SetColor(&ucg, 1, 135*a/b,206*a/b,250*a/b); ucg_SetColor(&ucg, 0, 176*a/b,226*a/b,255*a/b); ucg_SetColor(&ucg, 3, 25*a/b,25*a/b,112*a/b); ucg_SetColor(&ucg, 2, 85*a/b,26*a/b,139*a/b); ucg_DrawGradientBox(&ucg, ucg_GetWidth(&ucg)*3/4, 0, ucg_GetWidth(&ucg)/4, ucg_GetHeight(&ucg)); upper_pin(&ucg, 7+0*14, 4); upper_pin(&ucg, 7+1*14, 4); upper_pin(&ucg, 7+2*14, 4); upper_pin(&ucg, 7+3*14, 4); ic_body(&ucg, 2, 10); lower_pin(&ucg, 7+0*14, 41); lower_pin(&ucg, 7+1*14, 41); lower_pin(&ucg, 7+2*14, 41); lower_pin(&ucg, 7+3*14, 41); ucg_SetColor(&ucg, 0, 135*a/b, 206*a/b, 250*a/b); ucg_DrawString(&ucg, 63+1, 33+1, 0, "glib"); ucg_SetColor(&ucg, 0, 255, 168, 0); ucg_DrawGlyph(&ucg, 26, 38, 0, 'U'); ucg_DrawString(&ucg, 63, 33, 0, "glib"); ucg_SetColor(&ucg, 0, 135*a/b, 206*a/b, 250*a/b); ucg_SetColor(&ucg, 1, 135*a/b, 206*a/b, 250*a/b); ucg_SetColor(&ucg, 2, 135*a/b, 206*a/b, 250*a/b); ucg_SetColor(&ucg, 3, 135*a/b, 206*a/b, 250*a/b); ucg_DrawGradientBox(&ucg, 84+1, 42+1-6, 42, 4); ucg_SetColor(&ucg, 0, 255, 180, 40); ucg_SetColor(&ucg, 1, 235, 148, 0); //ucg_DrawGradientLine(&ucg, 79, 42, 20, 0); ucg_SetColor(&ucg, 2, 245, 158, 0); ucg_SetColor(&ucg, 3, 220, 138, 0); ucg_DrawGradientBox(&ucg, 84, 42-6, 42, 4); ucg_SetColor(&ucg, 0, 255, 168, 0); ucg_SetFont(&ucg, ucg_font_5x8); //ucg_SetFont(&ucg, ucg_font_courB08); ucg_DrawString(&ucg, 2, 54, 0, "http://"); ucg_DrawString(&ucg, 1, 61, 0, "code.google.com/p/ucglib/"); while( ucg_sdl_get_key() < 0 ) ; return 0; }