| 172 | } |
| 173 | |
| 174 | void PiuRectangleScaleToFit(PiuRectangle r0, PiuRectangle r1, PiuRectangle r2) |
| 175 | { |
| 176 | PiuRectangleRecord r; |
| 177 | |
| 178 | if ((0 == r1->height) || (0 == r1->width)) { |
| 179 | PiuRectangleEmpty(r0); |
| 180 | return; |
| 181 | } |
| 182 | |
| 183 | r.width = r2->width; |
| 184 | r.height = (r1->height * r2->width) / r1->width; |
| 185 | if (r.height > r2->height) { |
| 186 | r.height = r2->height; |
| 187 | r.width = (r1->width * r2->height) / r1->height; |
| 188 | } |
| 189 | |
| 190 | r.x = (r2->width - r.width) / 2; |
| 191 | r.y = (r2->height - r.height) / 2; |
| 192 | PiuRectangleOffset(&r, r2->x, r2->y); |
| 193 | |
| 194 | *r0 = r; |
| 195 | } |
| 196 | |
| 197 | void PiuRectangleSet(PiuRectangle r, PiuCoordinate x, PiuCoordinate y, PiuDimension width, PiuDimension height) |
| 198 | { |
no test coverage detected