void TCOD_sys_console_to_bitmap(void *vbitmap, int console_width, int console_height, char_t *console_buffer, char_t *prev_console_buffer) { int x,y; sfImage *bitmap=(sfImage *)vbitmap; TCOD_color_t fading_color = TCOD_console_get_fading_color(); static int oldFade=-1; uint8 fade = TCOD_console_get_fade(); static sfShape *rectShape=NULL; if ( ! rectShape ) { rectShape=sfShape_CreateRectangle(0.5f, 0.5f, 0.5f + fontWidth, 0.5f + fontHeight, sfBlack, 0.0f, sfBlack); sfShape_EnableOutline(rectShape, sfFalse); } for (y=0;y<console_height;y++) { for (x=0; x<console_width; x++) { char_t *c=&console_buffer[x+y*console_width]; bool changed=true; if ( changed ) { sfColor b={c->back.r,c->back.g,c->back.b,255}; // background b.r = ((int)b.r) * fade / 255 + ((int)fading_color.r) * (255-fade)/255; b.g = ((int)b.g) * fade / 255 + ((int)fading_color.g) * (255-fade)/255; b.b = ((int)b.b) * fade / 255 + ((int)fading_color.b) * (255-fade)/255; int destx=x*fontWidth; int desty=y*fontHeight; if ( (void *)bitmap == (void *)renderWindow && fullscreen_on ) { destx+=fullscreen_offsetx; desty+=fullscreen_offsety; } sfShape_SetPosition(rectShape,destx+0.5f,desty+0.5f); sfShape_SetColor(rectShape,sfWhite); sfRenderWindow_DrawShape (renderWindow, rectShape); nbBlit++; int srcx,srcy; if ( c->c != ' ') { // foreground int ascii=(int)c->c; sfColor f={c->fore.r,c->fore.g,c->fore.b,255}; f.r = ((int)f.r) * fade / 255 + ((int)fading_color.r) * (255-fade)/255; f.g = ((int)f.g) * fade / 255 + ((int)fading_color.g) * (255-fade)/255; f.b = ((int)f.b) * fade / 255 + ((int)fading_color.b) * (255-fade)/255; if (fontInRow) { srcx = (ascii%fontNbCharHoriz)*fontWidth; srcy = (ascii/fontNbCharHoriz)*fontHeight; } else { srcx = (ascii/fontNbCharVertic)*fontWidth; srcy = (ascii%fontNbCharVertic)*fontHeight; } sfIntRect rect={srcx,srcy,srcx+fontWidth-1,srcy+fontHeight-1}; sfSprite_SetSubRect(charmapSprite,&rect); sfSprite_SetX(charmapSprite,destx); sfSprite_SetY(charmapSprite,desty); sfSprite_SetColor(charmapSprite,f); sfRenderWindow_DrawSprite(renderWindow,charmapSprite); } } } } }
void Shape_SetColor(avm *vm) { sfColor Color = {getint(vm, 1), getint(vm, 2), getint(vm, 3), getint(vm, 4)}; sfShape_SetColor(getint(vm, 0), Color); }