// 数字文字列のCGを作成 int scg_create_textnum(int wNumCG, int wSize, int wR, int wG, int wB, int wFigs, int wZeroPadding, int wValue) { cginfo_t *i; agsurface_t *glyph; FONT *font; char s[256], ss[256]; spcg_assert_no(wNumCG); if (wZeroPadding) { char *sss = "%%0%dd"; sprintf(ss, sss, wFigs); } else { char *sss = "%%%dd"; sprintf(ss, sss, wFigs); } sprintf(s, ss, wValue); font = nact->ags.font; font->sel_font(FONT_GOTHIC, wSize); glyph = font->get_glyph(s); i = g_new(cginfo_t, 1); i->type = CG_SET; i->no = wNumCG; i->refcnt = 0; i->sf = sf_create_surface(glyph->width, wSize, nact->ags.dib->depth); gr_fill(i->sf, 0, 0, glyph->width, wSize, wR, wG, wB); gr_draw_amap(i->sf, 0, 0, glyph->pixel, glyph->width, wSize, glyph->bytes_per_line); // もし前に作成したものがあり、未開放の場合は開放 scg_free(wNumCG); sact.cg[wNumCG] = i; return OK; }
// 指定の文字列のCGを作成 int scg_create_text(int wNumCG, int wSize, int wR, int wG, int wB, int wText) { cginfo_t *i; agsurface_t *glyph; FONT *font; if (0) { char *b = sjis2lang(v_str(wText-1)); WARNING("str = '%s'\n", b); free(b); } spcg_assert_no(wNumCG); // 勝手に出ていいのかな? if (v_strlen(wText -1) == 0) return OK; font = nact->ags.font; font->sel_font(FONT_GOTHIC, wSize); glyph = font->get_glyph(v_str(wText -1)); i = g_new(cginfo_t, 1); i->type = CG_SET; i->no = wNumCG; i->refcnt = 0; i->sf = sf_create_surface(glyph->width, wSize, nact->ags.dib->depth); gr_fill(i->sf, 0, 0, glyph->width, wSize, wR, wG, wB); gr_draw_amap(i->sf, 0, 0, glyph->pixel, glyph->width, wSize, glyph->bytes_per_line); // もし前に作成したものがあり、未開放の場合は開放 scg_free(wNumCG); sact.cg[wNumCG] = i; return OK; }