void draw_gradient_line(ucg_t *ucg) { prepare_picture(ucg); hrule(ucg, ox+50, 40, 45, 0); ucg_SetColor(ucg, 0, 0, 255, 255); ucg_SetColor(ucg, 1, 255, 255, 0); ucg_DrawGradientLine(ucg, ox+50, 40, 45, 0); pos(ucg, ox+50, 40,0); save_picture(ucg, "draw_gradient_line"); }
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"); }
void draw_gradient_box(ucg_t *ucg) { prepare_picture(ucg); hrule(ucg, ox+50, 30, 45, 0); vrule(ucg, ox+50+45-1, 30, 20, 1); 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+50, 30, 45, 20); pos(ucg, ox+50, 30,0); save_picture(ucg, "draw_gradient_box"); }
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_pixel(ucg_t *ucg) { prepare_picture(ucg); pos(ucg, ox+50, 20,0); ucg_SetColor(ucg, 0, 255, 255, 255); ucg_DrawPixel(ucg, ox+50, 20); save_picture(ucg, "draw_pixel"); }
void prepare_picture(ucg_t *ucg) { 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_SetMaxClipRange(ucg); ucg_SetColor(ucg, 0, 0, 0, 0); ucg_DrawBox(ucg, ox, 0, 128, 64); }
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 draw_vline(ucg_t *ucg) { prepare_picture(ucg); vrule(ucg, ox+50, 20, 25, 1); ucg_SetColor(ucg, 0, 255, 255, 255); ucg_DrawVLine(ucg, ox+50, 20, 25); pos(ucg, ox+50, 20,0); save_picture(ucg, "draw_vline"); }
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 draw_hline(ucg_t *ucg) { prepare_picture(ucg); hrule(ucg, ox+50, 40, 45, 0); ucg_SetColor(ucg, 0, 255, 255, 255); ucg_DrawHLine(ucg, ox+50, 40, 45); pos(ucg, ox+50, 40,0); save_picture(ucg, "draw_hline"); }
// Lua: ucg.setColor( self, [idx], r, g, b ) static int lucg_setColor( lua_State *L ) { lucg_userdata_t *lud; if ((lud = get_lud( L )) == NULL) return 0; ucg_int_t args[3]; lucg_get_int_args( L, 2, 3, args ); ucg_int_t opt = luaL_optint( L, (1+3) + 1, -1 ); if (opt < 0) ucg_SetColor( LUCG, 0, args[0], args[1], args[2] ); else ucg_SetColor( LUCG, args[0], args[1], args[2], opt ); return 0; }
void draw_circle(ucg_t *ucg) { prepare_picture(ucg); hrule(ucg, ox+50+1, 30, 20, 0); vrule(ucg, ox+50+20-1, 30+1, 20, 1); ucg_SetColor(ucg, 0, 255, 255, 255); ucg_DrawCircle(ucg, ox+50, 30, 20, UCG_DRAW_LOWER_RIGHT); pos(ucg, ox+50, 30,0); save_picture(ucg, "draw_circle"); }
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 draw_frame(ucg_t *ucg) { prepare_picture(ucg); hrule(ucg, ox+50, 30, 45, 0); vrule(ucg, ox+50+45-1, 30, 20, 1); ucg_SetColor(ucg, 0, 255, 255, 255); ucg_DrawFrame(ucg, ox+50, 30, 45, 20); pos(ucg, ox+50, 30,0); save_picture(ucg, "draw_frame"); }
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; }
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 draw_rframe(ucg_t *ucg) { prepare_picture(ucg); hrule(ucg, ox+50, 30, 45, 0); vrule(ucg, ox+50+45-1, 30, 20, 1); vrule(ucg, ox+50+1, 30+20-8, 8, 0); hrule(ucg, ox+50, 30+20-1-1, 8, 1); ucg_SetColor(ucg, 0, 255, 255, 255); ucg_DrawRFrame(ucg, ox+50, 30, 45, 20, 8); pos(ucg, ox+50, 30,0); save_picture(ucg, "draw_rframe"); }
void lower_pin(ucg_t *ucg, ucg_int_t x, ucg_int_t y) { ucg_int_t w = 7; ucg_int_t h = 5; ucg_SetColor(ucg, 0, 212, 212, 212); ucg_SetColor(ucg, 1, 200, 200, 200); ucg_SetColor(ucg, 2, 200, 200, 200); ucg_SetColor(ucg, 3, 188, 188, 188); ucg_DrawGradientBox(ucg, x, y, w, h); //ucg_DrawVLine(ucg, x+w, y+1, len); ucg_SetColor(ucg, 0, 220, 220, 220); ucg_SetColor(ucg, 1, 232, 232, 232); ucg_DrawGradientLine(ucg, x+w, y, h, 1); ucg_SetColor(ucg, 0, 220, 220, 220); ucg_SetColor(ucg, 1, 232, 232, 232); ucg_DrawGradientLine(ucg, x, y+h, w, 0); ucg_SetColor(ucg, 0, 240, 240, 240); ucg_DrawPixel(ucg, x+w, y+h); }
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_triangle(ucg_t *ucg) { prepare_picture(ucg); ucg_SetColor(ucg, 0, 255, 255, 255); ucg_DrawTriangle(ucg, 52, 9, 83,32, 47,42); ucg_DrawTriangle(ucg, 52,55, 83,32+1, 47,42+1); pos(ucg, 52, 9, 0); pos(ucg, 83,32, 1); pos(ucg, 47,42+1, 0); save_picture(ucg, "draw_triangle"); }
void ic_body(ucg_t *ucg, ucg_int_t x, ucg_int_t y) { ucg_int_t w = 4*14+4; ucg_int_t h = 31; ucg_SetColor(ucg, 0, 60, 60, 60); ucg_SetColor(ucg, 1, 40, 40, 40); ucg_SetColor(ucg, 2, 48, 48, 48); ucg_SetColor(ucg, 3, 30, 30, 30); ucg_DrawGradientBox(ucg, x, y, w, h); ucg_SetColor(ucg, 0, 255, 168, 0); //ucg_SetColor(ucg, 0, 225, 168, 30); ucg_DrawDisc(ucg, x+w-1, y+h/2-1, 7, UCG_DRAW_UPPER_LEFT|UCG_DRAW_LOWER_LEFT); ucg_SetColor(ucg, 0, 60, 30, 0); //ucg_DrawDisc(ucg, x+w-1, y+h/2+1, 7, UCG_DRAW_UPPER_LEFT|UCG_DRAW_LOWER_LEFT); ucg_SetColor(ucg, 0, 50, 50, 50); ucg_SetColor(ucg, 0, 25, 25, 25); ucg_DrawDisc(ucg, x+w-1, y+h/2+1, 7, UCG_DRAW_UPPER_LEFT|UCG_DRAW_LOWER_LEFT); }
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); }
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; }