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

Function PiuRectangleApplyAspect

modules/piu/All/piuRectangle.c:23–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21#include "piuAll.h"
22
23void PiuRectangleApplyAspect(PiuRectangle r0, PiuRectangle r1, PiuRectangle r2, PiuAspect aspect)
24{
25 if (!PiuRectangleIsEqual(r1, r2)) {
26 if (aspect & piuAspectFill) {
27 if (aspect & piuAspectFit)
28 *r0 = *r2;
29 else
30 PiuRectangleScaleToFill(r0, r1, r2);
31 }
32 else {
33 if (aspect & piuAspectFit)
34 PiuRectangleScaleToFit(r0, r1, r2);
35 else {
36#ifdef piuPC
37 r0->x = r2->x + ((r2->width - r1->width) / 2);
38 r0->y = r2->y + ((r2->height - r1->height) / 2);
39#else
40 r0->x = r2->x + ((r2->width - r1->width) >> 1);
41 r0->y = r2->y + ((r2->height - r1->height) >> 1);
42#endif
43 r0->width = r1->width;
44 r0->height = r1->height;
45 }
46 }
47 }
48}
49
50void PiuRectangleApplyMargins(PiuRectangle r0, PiuRectangle r1, PiuMargins margins)
51{

Callers

nothing calls this directly

Calls 3

PiuRectangleIsEqualFunction · 0.85
PiuRectangleScaleToFillFunction · 0.85
PiuRectangleScaleToFitFunction · 0.85

Tested by

no test coverage detected