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

Function PiuRectangleScaleToFill

modules/piu/All/piuRectangle.c:151–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149}
150
151void PiuRectangleScaleToFill(PiuRectangle r0, PiuRectangle r1, PiuRectangle r2)
152{
153 PiuRectangleRecord r;
154
155 if ((0 == r1->height) || (0 == r1->width)) {
156 PiuRectangleEmpty(r0);
157 return;
158 }
159
160 r.width = r2->width;
161 r.height = (r1->height * r2->width) / r1->width;
162 if (r.height < r2->height) {
163 r.height = r2->height;
164 r.width = (r1->width * r2->height) / r1->height;
165 }
166
167 r.x = (r2->width - r.width) / 2;
168 r.y = (r2->height - r.height) / 2;
169 PiuRectangleOffset(&r, r2->x, r2->y);
170
171 *r0 = r;
172}
173
174void PiuRectangleScaleToFit(PiuRectangle r0, PiuRectangle r1, PiuRectangle r2)
175{

Callers 1

PiuRectangleApplyAspectFunction · 0.85

Calls 2

PiuRectangleEmptyFunction · 0.85
PiuRectangleOffsetFunction · 0.85

Tested by

no test coverage detected