#include "editServerData.h"

int const startX = 400;
int const startY = 400;
float velikost = 10;


bool drawRobot(float X, float Y, float rot, int R, int G, int B, TCanvas * Canvas, float polomer)
{
        Canvas->Brush->Color = RGB(R,G,B);
        Canvas->Pen->Color = RGB(0,0,0);
        Canvas->Ellipse(
                startX+(X-polomer)*velikost,
                startY+(Y-polomer)*velikost,
                startX+(X+polomer)*velikost,
                startY+(Y+polomer)*velikost
        );
        Canvas->MoveTo(
                startX+X*velikost,
                startY+Y*velikost
        );
        Canvas->LineTo(
                startX+(X+cos(rot))*velikost,
                startY+(Y+sin(rot))*velikost
        );
        return true;
}

bool drawSingleRobot(robotProperties robot, TCanvas * Canvas)
{
        float X = robot.positionX;
        float Y = robot.positionY;
        float polomer = robot.drawingPolomer;
        float rot = robot.rotation;
        int Rcolor = robot.Rcolor;
        int Gcolor = robot.Gcolor;
        int Bcolor = robot.Bcolor;
        return drawRobot(X,Y,rot,Rcolor,Gcolor,Bcolor,Canvas,polomer);
}

bool drawAllRobots(std::map<int,robotProperties> robots, TCanvas * Canvas, bool kreslitStopu)
{
        if(!kreslitStopu)
                Canvas->Rectangle(0,0,1000,1000);
        for(std::map<int,robotProperties>::iterator it = robots.begin(); it != robots.end(); it++)
        {
                drawSingleRobot(it->second, Canvas);
        }
}
