Exemple #1
0
void Terrain::swapImg(sf::Image &img)
{
	for(unsigned int i=0;i<img.GetWidth();i++)
	{
		for(unsigned int j=0;j<img.GetHeight()/2;j++)
		{
			sf::Color tmp = img.GetPixel(i,img.GetHeight()-1-j);
			img.SetPixel(i,img.GetHeight()-1-j,img.GetPixel(i,j));
			img.SetPixel(i,j,tmp);
		}
	}
}
void ColorScale::draw(sf::Image& img,const sf::Vector2f& start,const sf::Vector2f& end,GradientStyle::GradientStyle style, int size) const
{

	sf::Color (*pFunction)(sf::Color*,int,const sf::Vector2f&,const sf::Vector2f&,int,int);

	sf::Color* tab =new sf::Color[size];
	fillTab(tab,size);

	switch (style)
	{
		case GradientStyle::Linear : pFunction = GradientLinear; break;
		case GradientStyle::Circle : pFunction = GradientCircle; break;
		case GradientStyle::Radial : pFunction = GradientRadial; break;
		case GradientStyle::Reflex : pFunction = GradientReflex; break;

		default: pFunction = GradientLinear;  break;
	}

	for(int i=0;i<img.GetWidth();i++)
	{
		for(int j=0;j<img.GetHeight();j++)
		{
			img.SetPixel(i,j,pFunction(tab,size,start,end,i,j));
		}
	}
	delete[] tab;
}
Exemple #3
0
void DrawCharacter(sf::Image &screen, unsigned short *font_buff, char c, sf::Color fg_col, sf::Color bg_col, bool blink, int x, int y)
{
    /*
    set the area on the screen to the proper character c, defined in the font_buf
    use the colors fg_col and bg_col
    fonts defined in 2 words
    upperword aaaa bbbb cccc dddd
    lowerword eeee ffff gggg hhhh
    character defined as
    
        a a a a
        b b b b
        c c c c
        d d d d
        e e e e
        f f f f
        g g g g
        h h h h
    
    1 means set to fg_col, 0 means set to bg col
    */
    int font_off_x = x * 4;
    int font_off_y = y * 8;
    //font_buff += (c * 2);   // 1 char per word

    unsigned short fontupperword = font_buff[(c * 2)];
    unsigned short fontlowerword = font_buff[(c * 2) + 1];

    unsigned int font_char = fontupperword << 16 | fontlowerword;

    //for(int off = 0; off < 32; off++) // for reverse
    for(int off = 31; off >= 0; off--)
    {
        unsigned int mask = font_char & (1 << (31-off));
        int x_img = font_off_x + (off % 4);
        int y_img = font_off_y + (off / 4);

        if(mask > 0 && !blink)
            screen.SetPixel(x_img, y_img, fg_col);
        else
            screen.SetPixel(x_img, y_img, bg_col);
        
    }
}
Exemple #4
0
void SetPixelWithVariance(int r, int g, int b, int x, int y, int variance, sf::Image &Image)
{


        int br, bg, bb;
        br=r*variance;
        bg=g*variance;
        bb=b*variance;


        if(br>255) {
                br=255;
        }
        if(br<0) {
                br=0;
        }
        if(bg>255) {
                bg=255;
        }
        if(br<0) {
                bg=0;
        }
        if(bb>255) {
                bb=255;
        }
        if(br<0) {
                bb=0;
        }

        sf::Color Temp;
        Temp.r=br;
        Temp.g=bg;
        Temp.b=bb;
        Image.SetPixel(x, y, Temp);



}
Exemple #5
0
void Metl::Render(sf::Image& pixbuff)
{
    pixbuff.SetPixel(XPos,YPos,sf::Color::Red);

}