Beispiel #1
0
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);
    }
}
Beispiel #2
0
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");
}
Beispiel #3
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");
}
Beispiel #4
0
// Lua: ucg.drawHLine( self, x, y, len )
static int lucg_drawHLine( 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_DrawHLine( LUCG, args[0], args[1], args[2] );

    return 0;
}
Beispiel #5
0
static void pg_hline(pg_struct *pg, ucg_t *ucg)
{
  pg_word_t x1, x2, y;
  x1 = pg->pge[PG_LEFT].current_x;
  x2 = pg->pge[PG_RIGHT].current_x;
  y = pg->pge[PG_RIGHT].current_y;
  
  if ( y < 0 )
    return;
  if ( y >= ucg_GetHeight(ucg) )
    return;
  if ( x1 < x2 )
  {
    if ( x2 < 0 )
      return;
    if ( x1 >= ucg_GetWidth(ucg) )
      return;
    if ( x1 < 0 )
      x1 = 0;
    if ( x2 >= ucg_GetWidth(ucg) )
      x2 = ucg_GetWidth(ucg);
    ucg_DrawHLine(ucg, x1, y, x2 - x1);
  }
  else
  {
    if ( x1 < 0 )
      return;
    if ( x2 >= ucg_GetWidth(ucg) )
      return;
    if ( x2 < 0 )
      x1 = 0;
    if ( x1 >= ucg_GetWidth(ucg) )
      x1 = ucg_GetWidth(ucg);
    ucg_DrawHLine(ucg, x2, y, x1 - x2);
  }
}
Beispiel #6
0
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");
}
Beispiel #7
0
/*
  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);
}