void RectangleActions(CRectangle &rect, ifstream &fin) { string action; fin >> action; if (action == "Rectangle") { int width, height, left, top; fin >> left >> top >> width >> height; rect.SetLeft(left); rect.SetTop(top); rect.SetWidth(width); rect.SetHeight(height); }
void CProcessRectangles::ProcessRectangleCommand(const listArguments & arguments, CRectangle & rectangle) { if (arguments.size() != AMOUNT_ARGUMENTS_FOR_COMMAND[static_cast<int>(IdCommand::Rectangle)]) { throw invalid_argument(MESSAGE_INCORRECT_AMOUNT_ARGUMENTS + to_string(AMOUNT_ARGUMENTS_FOR_COMMAND[static_cast<int>(IdCommand::Rectangle)])); } rectangle.SetLeft(stoi(arguments[1])); rectangle.SetTop(stoi(arguments[2])); rectangle.SetWidth(stoi(arguments[3])); rectangle.SetHeight(stoi(arguments[4])); }
void CBorder::CalculateUVCoords(SUVCornersFull* apsUVs) { SFloat2 sTopLeft; SFloat2 sBottomRight; CRectangle sSubImage; int iTextureWidth; int iTextureHeight; if (mpcBorderParameters->GetGraphicsMaterial()->GetNumTextures() > 0) { //You're not actually done yet, until you handle the tiled version. iTextureWidth = GetTexture(0)->GetWidth(); iTextureHeight = GetTexture(0)->GetHeight(); //Top sSubImage.miTop = 0; sSubImage.miLeft = 0; sSubImage.SetWidth(iTextureWidth); sSubImage.SetHeight(mpcBorderParameters->maiEdgeWidths[0]); sTopLeft = sSubImage.GetUVCoordinatesTopLeft(iTextureWidth, iTextureHeight); sBottomRight = sSubImage.GetUVCoordinatesBottomRight(iTextureWidth, iTextureHeight); apsUVs[1].Set(sTopLeft.x, sTopLeft.y, sBottomRight.x, sBottomRight.y); //Right sSubImage.miTop += sSubImage.GetHeight() - 1; //Don't even ask... sSubImage.SetHeight(mpcBorderParameters->maiEdgeWidths[1]); sTopLeft = sSubImage.GetUVCoordinatesTopLeft(iTextureWidth, iTextureHeight); sBottomRight = sSubImage.GetUVCoordinatesBottomRight(iTextureWidth, iTextureHeight); apsUVs[3].Set(sTopLeft.x, sTopLeft.y, sBottomRight.x, sBottomRight.y); apsUVs[3].Rotate(1); //Bottom sSubImage.miTop += sSubImage.GetHeight(); sSubImage.SetHeight(mpcBorderParameters->maiEdgeWidths[2]); sTopLeft = sSubImage.GetUVCoordinatesTopLeft(iTextureWidth, iTextureHeight); sBottomRight = sSubImage.GetUVCoordinatesBottomRight(iTextureWidth, iTextureHeight); apsUVs[5].Set(sTopLeft.x, sTopLeft.y, sBottomRight.x, sBottomRight.y); apsUVs[5].Rotate(2); //Left sSubImage.miTop += sSubImage.GetHeight() + 1; sSubImage.SetHeight(mpcBorderParameters->maiEdgeWidths[3]); sTopLeft = sSubImage.GetUVCoordinatesTopLeft(iTextureWidth, iTextureHeight); sBottomRight = sSubImage.GetUVCoordinatesBottomRight(iTextureWidth, iTextureHeight); apsUVs[7].Set(sTopLeft.x, sTopLeft.y, sBottomRight.x, sBottomRight.y); apsUVs[7].Rotate(3); //Top Left sSubImage.miTop += sSubImage.GetHeight(); sSubImage.SetHeight(mpcBorderParameters->masCornerSizes[0].y); sSubImage.SetWidth(mpcBorderParameters->masCornerSizes[0].x); sTopLeft = sSubImage.GetUVCoordinatesTopLeft(iTextureWidth, iTextureHeight); sBottomRight = sSubImage.GetUVCoordinatesBottomRight(iTextureWidth, iTextureHeight); apsUVs[0].Set(sTopLeft.x, sTopLeft.y, sBottomRight.x, sBottomRight.y); //Top Right sSubImage.miTop += sSubImage.GetHeight(); sSubImage.SetHeight(mpcBorderParameters->masCornerSizes[1].y); sSubImage.SetWidth(mpcBorderParameters->masCornerSizes[1].x); sTopLeft = sSubImage.GetUVCoordinatesTopLeft(iTextureWidth, iTextureHeight); sBottomRight = sSubImage.GetUVCoordinatesBottomRight(iTextureWidth, iTextureHeight); apsUVs[2].Set(sTopLeft.x, sTopLeft.y, sBottomRight.x, sBottomRight.y); //Bottom Right sSubImage.miTop += sSubImage.GetHeight(); sSubImage.SetHeight(mpcBorderParameters->masCornerSizes[2].y); sSubImage.SetWidth(mpcBorderParameters->masCornerSizes[2].x); sTopLeft = sSubImage.GetUVCoordinatesTopLeft(iTextureWidth, iTextureHeight); sBottomRight = sSubImage.GetUVCoordinatesBottomRight(iTextureWidth, iTextureHeight); apsUVs[4].Set(sTopLeft.x, sTopLeft.y, sBottomRight.x, sBottomRight.y); //Bottom Left sSubImage.miTop += sSubImage.GetHeight(); sSubImage.SetHeight(mpcBorderParameters->masCornerSizes[3].y); sSubImage.SetWidth(mpcBorderParameters->masCornerSizes[3].x); sTopLeft = sSubImage.GetUVCoordinatesTopLeft(iTextureWidth, iTextureHeight); sBottomRight = sSubImage.GetUVCoordinatesBottomRight(iTextureWidth, iTextureHeight); apsUVs[6].Set(sTopLeft.x, sTopLeft.y, sBottomRight.x, sBottomRight.y); } }