diff options
| author | DavePutz <dwputz@gmail.com> | 2020-05-19 10:32:32 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-19 10:32:32 -0500 |
| commit | 7fa5009674c7741436fd45a3d2009019280aa6f6 (patch) | |
| tree | 9b9197adc9dfc2a7f7a7466abcfc2259f842c16a /shared-module/vectorio/Rectangle.c | |
| parent | 114f06d8250b4250a7c035f3bb1a2820ca2720d2 (diff) | |
| parent | 2c2b53303d17e07daa8f7a61740835d30f671a18 (diff) | |
Merge pull request #4 from adafruit/master
merge from adafruit
Diffstat (limited to 'shared-module/vectorio/Rectangle.c')
| -rw-r--r-- | shared-module/vectorio/Rectangle.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/shared-module/vectorio/Rectangle.c b/shared-module/vectorio/Rectangle.c new file mode 100644 index 000000000..7fabe6ff9 --- /dev/null +++ b/shared-module/vectorio/Rectangle.c @@ -0,0 +1,35 @@ +#include "shared-bindings/vectorio/Rectangle.h" +#include "shared-module/displayio/area.h" + +#include "py/runtime.h" + + +void common_hal_vectorio_rectangle_construct(vectorio_rectangle_t *self, uint32_t width, uint32_t height) { + self->width = width; + self->height = height; +} + + +uint32_t common_hal_vectorio_rectangle_get_pixel(void *obj, int16_t x, int16_t y) { + vectorio_rectangle_t *self = obj; + if (x < 0 || x > self->width || y > self->height || y < 0) { + return 0; + } + return 1; +} + + +void common_hal_vectorio_rectangle_get_area(void *rectangle, displayio_area_t *out_area) { + vectorio_rectangle_t *self = rectangle; + out_area->x1 = -1; + out_area->y1 = -1; + out_area->x2 = self->width; + out_area->y2 = self->height; +} + + +uint32_t common_hal_vectorio_rectangle_get_height(void *rectangle) { + vectorio_rectangle_t *self = rectangle; + return self->height; +} + |
