Skip to content

Commit 3b506f0

Browse files
committed
displayio: area: add displayio_area_canon
This routine will be used to simplify code that deals with ranges of bitmap coordinates.
1 parent f40c0c1 commit 3b506f0

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

shared-module/displayio/__init__.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,19 @@ bool displayio_area_empty(const displayio_area_t *a) {
320320
return (a->x1 == a->x2) || (a->y1 == a->y2);
321321
}
322322

323+
void displayio_area_canon(displayio_area_t *a) {
324+
if (a->x1 < a->x2) {
325+
int16_t t = a->x1;
326+
a->x1 = a->x2;
327+
a->x2 = t;
328+
}
329+
if (a->y1 < a->y2) {
330+
int16_t t = a->y1;
331+
a->y1 = a->y2;
332+
a->y2 = t;
333+
}
334+
}
335+
323336
void displayio_area_union(const displayio_area_t *a,
324337
const displayio_area_t *b,
325338
displayio_area_t *u) {

shared-module/displayio/area.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ extern displayio_buffer_transform_t null_transform;
5555

5656
bool displayio_area_empty(const displayio_area_t *a);
5757
void displayio_area_copy_coords(const displayio_area_t *src, displayio_area_t *dest);
58+
void displayio_area_canon(displayio_area_t *a);
5859
void displayio_area_union(const displayio_area_t *a,
5960
const displayio_area_t *b,
6061
displayio_area_t *u);

0 commit comments

Comments
 (0)