MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / PiuRectangleScaleToFit

Function PiuRectangleScaleToFit

modules/piu/All/piuRectangle.c:174–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172}
173
174void 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
197void PiuRectangleSet(PiuRectangle r, PiuCoordinate x, PiuCoordinate y, PiuDimension width, PiuDimension height)
198{

Callers 1

PiuRectangleApplyAspectFunction · 0.85

Calls 2

PiuRectangleEmptyFunction · 0.85
PiuRectangleOffsetFunction · 0.85

Tested by

no test coverage detected