diff --git a/shared-module/displayio/__init__.c b/shared-module/displayio/__init__.c index 07fd603861..18d08c530e 100644 --- a/shared-module/displayio/__init__.c +++ b/shared-module/displayio/__init__.c @@ -320,6 +320,19 @@ bool displayio_area_empty(const displayio_area_t *a) { return (a->x1 == a->x2) || (a->y1 == a->y2); } +void displayio_area_canon(displayio_area_t *a) { + if (a->x1 < a->x2) { + int16_t t = a->x1; + a->x1 = a->x2; + a->x2 = t; + } + if (a->y1 < a->y2) { + int16_t t = a->y1; + a->y1 = a->y2; + a->y2 = t; + } +} + void displayio_area_union(const displayio_area_t *a, const displayio_area_t *b, displayio_area_t *u) { diff --git a/shared-module/displayio/area.h b/shared-module/displayio/area.h index 1b30ce96fe..b6ff1dcd29 100644 --- a/shared-module/displayio/area.h +++ b/shared-module/displayio/area.h @@ -55,6 +55,7 @@ extern displayio_buffer_transform_t null_transform; bool displayio_area_empty(const displayio_area_t *a); void displayio_area_copy_coords(const displayio_area_t *src, displayio_area_t *dest); +void displayio_area_canon(displayio_area_t *a); void displayio_area_union(const displayio_area_t *a, const displayio_area_t *b, displayio_area_t *u);