Rect GraphicsObjectData::dstRect(const GraphicsObject& go, const GraphicsObject* parent) { Point origin = dstOrigin(go); Rect src = srcRect(go); int center_x = go.x() + go.xAdjustmentSum() - origin.x() + (src.width() / 2.0f); int center_y = go.y() + go.yAdjustmentSum() - origin.y() + (src.height() / 2.0f); float second_factor_x = 1.0f; float second_factor_y = 1.0f; if (parent) { center_x += parent->x() + parent->xAdjustmentSum(); center_y += parent->y() + parent->yAdjustmentSum(); second_factor_x = parent->getWidthScaleFactor(); second_factor_y = parent->getHeightScaleFactor(); } int half_real_width = (src.width() * second_factor_x * go.getWidthScaleFactor()) / 2.0f; int half_real_height = (src.height() * second_factor_y * go.getHeightScaleFactor()) / 2.0f; int xPos1 = center_x - half_real_width; int yPos1 = center_y - half_real_height; int xPos2 = center_x + half_real_width; int yPos2 = center_y + half_real_height; return Rect::GRP(xPos1, yPos1, xPos2, yPos2); }
Rect GraphicsObjectData::dstRect(const GraphicsObject& go) { Point origin = dstOrigin(go); Rect src = srcRect(go); int xPos1 = go.x() + go.xAdjustmentSum() - origin.x(); int yPos1 = go.y() + go.yAdjustmentSum() - origin.y(); int xPos2 = int(xPos1 + src.width() * (go.width() / 100.0f)); int yPos2 = int(yPos1 + src.height() * (go.height() / 100.0f)); return Rect::GRP(xPos1, yPos1, xPos2, yPos2); }