Example #1
0
/**
 * Print formatted output with a ByteMap font.
 * This function could be slow, it should be used with GRRLIB_CompoStart and GRRLIB_CompoEnd.
 * @param xpos Specifies the x-coordinate of the upper-left corner of the text.
 * @param ypos Specifies the y-coordinate of the upper-left corner of the text.
 * @param bmf The ByteMap font to use.
 * @param text Text to draw.
 * @param ... Optional arguments.
 */
void  GRRLIB_PrintBMF (const f32 xpos, const f32 ypos,
                       const GRRLIB_bytemapFont *bmf,
                       const char *text, ...) {
    uint  i, size;
    u8    *pdata;
    u8    x, y;
    char  tmp[1024];
    f32   xoff = xpos;
    const GRRLIB_bytemapChar *pchar;

    va_list argp;
    va_start(argp, text);
    size = vsprintf(tmp, text, argp);
    va_end(argp);

    for (i=0; i<size; i++) {
        pchar = &bmf->charDef[(u8)tmp[i]];
        pdata = pchar->data;
        for (y=0; y<pchar->height; y++) {
            for (x=0; x<pchar->width; x++) {
                if (*pdata) {
                    GRRLIB_Plot(xoff + x + pchar->relx,
                                ypos + y + pchar->rely,
                                bmf->palette[*pdata]);
                }
                pdata++;
            }
        }
        xoff += pchar->kerning + bmf->tracking;
    }
}
Example #2
0
void
Draw::DrawTerrain(Terrain* t, int start_x, int start_y)
{

#define GRRLIB_BLUE    0x0000FF00
#define GRRLIB_GREEN   0x00FF0000
#ifdef OSX
	int w = t->width;
	int h = t->height;
#else
	int w = rmode->fbWidth;
	int h = rmode->efbHeight;
#endif


	for(int y=0; y<h; y++)
	{
		for(int x = 0; x<w; x++)
		{
		
			int x_=x+start_x;
			while(x_ >= t->width)
				x_-=t->width;
			while(x_ < 0)
				x_+=t->width;
				
				
			int y_=y+start_y;
			while(y_ >= t->height)
				y_-=t->height;
			while(y_ < 0)
				y_+=t->height;
#ifndef OSX
			utils::Color c = image.GetValue(x_,y_);
			GRRLIB_Plot(x, y, c.red<<24 | c.green<<16 | c.blue<<8 | c.alpha);
			/*float num = this->map[y_][x_];
			if(num == NAN)
			{
				GRRLIB_Plot(x,y,0xff0000FF);
			}
			else
			{
				int val = (num)*255.0;
				GRRLIB_Plot(x,y,val<<24|val<<16|val<<8|0xff);
			}*/
#endif
		}
	}
}
Example #3
0
void blurDot(u16 x, u16 y, u16 factor, u16 lightf, u32 col)
{
int div, i, j, ui;
u8 colors[3];

colors[0] = R(col);
colors[1] = G(col);
colors[2] = B(col);

div = 1 + (2 * lightf);

	for(i = -factor; i <= factor; i++)
	{
		if (i < 0) ui = factor+i;
		else ui = factor-i;

		//Plot a "square" with a 45 deg rotation
		for(j = -ui; j <= ui; j++)
		{
			GRRLIB_Plot(x+i, y+j, RGBA(colors[0]/div, colors[1]/div, colors[2]/div, 0xFF));
		}
	}
}
Example #4
0
void grlib_Text (f32 xpos, f32 ypos, u8 align, u32 color, char *text)
	{
    uint  i;
    u8    *pdata;
    u8    x, y;
	u8 	  r,g,b,a;
	u8 	  ghostChar = 0;

    f32   xoff = xpos;
    const GRRLIB_bytemapChar *pchar;
	
	ypos --;

	if (align == GRLIB_ALIGNCENTER)
	    xoff -= grlib_GetFontMetrics (text, NULL, NULL) / 2;

	if (align == GRLIB_ALIGNRIGHT)
	    xoff -= grlib_GetFontMetrics (text, NULL, NULL);
		
	for (i=0; i < strlen (text); i++) 
		{
		if (text[i] < 32) continue;

		if (text[i] != '\255')
			{
			pchar = &grlibSettings.fontBMF->charDef[(u8)text[i]];
			ghostChar = 0;
			}
		else
			{
			i++;
			pchar = &grlibSettings.fontBMF->charDef[(u8)text[i]];
			ghostChar = 1;
			}

        pdata = pchar->data;
        for (y = 0; y < pchar->height; y++) 
			{
            for (x = 0; x < pchar->width; x++) 
				{
                if (*pdata && !ghostChar) 
					{
					if (color == 0)
						{
						u32 c = grlibSettings.fontBMF->palette[*pdata];
						
						if (!grlibSettings.fontBMF_reverse)
							{
							r = R(c);	
							g = G(c);
							b = B(c);
							}
						else
							{
							r = 255-R(c);
							g = 255-G(c);
							b = 255-B(c);
							}
							
						a = A(c);
						c = RGBA (r,g,b,a);
						//if (R(grlibSettings.fontBMF->palette[*pdata]) > 32 && G(grlibSettings.fontBMF->palette[*pdata]) > 32 && B(grlibSettings.fontBMF->palette[*pdata]) > 32)
							GRRLIB_Plot(xoff + x + pchar->relx, ypos + y + pchar->rely, c);
						}
					else
						{
						u32 c;

						r = R(color);
						g = G(color);
						b = B(color);
						a = A(grlibSettings.fontBMF->palette[*pdata]);
						c = RGBA (r,g,b,a);
						GRRLIB_Plot(xoff + x + pchar->relx, ypos + y + pchar->rely, c);
						}
					}
                pdata++;
				}
			}
        
		xoff += pchar->kerning + grlibSettings.fontBMF->tracking;
		}
	}