示例#1
0
文件: main.c 项目: gnkarn/ucglib
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);
    }
}
示例#2
0
static void ICACHE_FLASH_ATTR ucg_draw_disc_section(ucg_t *ucg, ucg_int_t x, ucg_int_t y, ucg_int_t x0, ucg_int_t y0, uint8_t option)
{
    /* upper right */
    if ( option & UCG_DRAW_UPPER_RIGHT )
    {
      ucg_DrawVLine(ucg, x0+x, y0-y, y+1);
      ucg_DrawVLine(ucg, x0+y, y0-x, x+1);
    }
    
    /* upper left */
    if ( option & UCG_DRAW_UPPER_LEFT )
    {
      ucg_DrawVLine(ucg, x0-x, y0-y, y+1);
      ucg_DrawVLine(ucg, x0-y, y0-x, x+1);
    }
    
    /* lower right */
    if ( option & UCG_DRAW_LOWER_RIGHT )
    {
      ucg_DrawVLine(ucg, x0+x, y0, y+1);
      ucg_DrawVLine(ucg, x0+y, y0, x+1);
    }
    
    /* lower left */
    if ( option & UCG_DRAW_LOWER_LEFT )
    {
      ucg_DrawVLine(ucg, x0-x, y0, y+1);
      ucg_DrawVLine(ucg, x0-y, y0, x+1);
    }
}
示例#3
0
文件: main.c 项目: gnkarn/ucglib
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");
}
示例#4
0
// Lua: ucg.drawVLine( self, x, y, len )
static int lucg_drawVLine( 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_DrawVLine( LUCG, args[0], args[1], args[2] );

    return 0;
}
示例#5
0
文件: main.c 项目: gnkarn/ucglib
/*
  pos = 1 above
  pos = 0
  pos = -1 below
*/
void hrule(ucg_t *ucg, ucg_int_t x, ucg_int_t y, ucg_int_t len, int is_below)
{
    char s[10];
    ucg_int_t o = rule_offset;
    ucg_int_t w;

    if ( is_below )
    {
        ucg_SetFontPosTop(ucg);
        o  = -o;
    }
    else
    {
        ucg_SetFontPosBottom(ucg);
    }

    prepare_measure(ucg);
    ucg_DrawHLine(ucg, x, y-o, len);
    ucg_DrawVLine(ucg, x, y-1-o, 3);
    ucg_DrawVLine(ucg, x+len-1, y-1-o, 3);
    sprintf(s, "%d", len);
    w = ucg_GetStrWidth(ucg, s);
    ucg_DrawString(ucg, x + len/2 - w/2, y-o+1, 0, s);
}