QgsRectangle boundingBox(10.0, 20.0, 30.0, 40.0); // Create a bounding box boundingBox.scale(2.0); // Scale the bounding box by a factor of 2
QgsRectangle boundingBox(10.0, 20.0, 30.0, 40.0); // Create a bounding box QgsPoint center = boundingBox.center(); // Get the center point of the bounding box double factor = 0.5; // Scale factor boundingBox.scale(factor, center); // Scale the bounding box around its center pointThis code first creates a bounding box with the same coordinates as the previous example. Then, the center method is called to get the center point of the bounding box. Next, a scaling factor of 0.5 is defined, and the scale method is called with this factor as well as the center point. This scales the bounding box by half around its center point. Both examples use the QGIS C++ library (QgsRectangle is a class in this library).