#ifndef _CGRAF_H_
#define _CGRAF_H_

#include "../App/EngineH.h"

class CGraf
{
private :
	TPoint	*_bod;
	TRect _rect;
	uint _texBackground;
	int _numBods;
	int _odOkraje;
	float _r, _g, _b;
	bool _bBackground;
	int _Nejvetsi(int p, int pole[] )
	{
		int ret;
		for( register i=0; i<p; i++)
		{
			if(i==0) ret=pole[i];
			else
			if( pole[i] > ret ) ret = pole[i];
		}
		return ret;
	}

public :
	CGraf();
public :
	void SetBackground( uint tex, TRect rect) 
	{	
		_texBackground = tex;
		_rect = rect;
	}
	void SetAtribut( int num, int poleX[], int poleY[] )
	{
		_numBods = num;
		_bod = new TPoint[num];
		float prevX = float( (_rect.width-_odOkraje*2)/poleX[num-1] );
		float nej = _Nejvetsi( num, poleY );
		float prevY = 1.0f;
		if( nej > _rect.height-_odOkraje*2 ) prevY = float( (_rect.height-_odOkraje*2)/nej );
		for( register i=0; i<num; i++)
		{
			TPoint point = { (float)poleX[i]*prevX, (float)poleY[i]*prevY };
			_bod[i] = point;
		}
	}
	void SetColor( float r, float g, float b ) {_r=r; _g=g; _b=b;}
	void SetBackBool( bool b ) {_bBackground = b;}
	void Render();
	
};

#endif // _CGRAF_H_