|
14 | 14 | #include "shared-bindings/vectorio/Rectangle.h" |
15 | 15 |
|
16 | 16 | // Lifecycle actions. |
17 | | -#define VECTORIO_SHAPE_DEBUG(...) (void)0 |
18 | | -// #define VECTORIO_SHAPE_DEBUG(...) mp_printf(&mp_plat_print, __VA_ARGS__) |
| 17 | +//#define VECTORIO_SHAPE_DEBUG(...) (void)0 |
| 18 | +#define VECTORIO_SHAPE_DEBUG(...) mp_printf(&mp_plat_print, __VA_ARGS__) |
19 | 19 |
|
20 | 20 |
|
21 | 21 | // Used in both logging and ifdefs, for extra variables |
22 | 22 | // #define VECTORIO_PERF(...) mp_printf(&mp_plat_print, __VA_ARGS__) |
23 | 23 |
|
24 | 24 |
|
25 | 25 | // Really verbose. |
26 | | -#define VECTORIO_SHAPE_PIXEL_DEBUG(...) (void)0 |
27 | | -// #define VECTORIO_SHAPE_PIXEL_DEBUG(...) mp_printf(&mp_plat_print, __VA_ARGS__) |
| 26 | +//#define VECTORIO_SHAPE_PIXEL_DEBUG(...) (void)0 |
| 27 | +#define VECTORIO_SHAPE_PIXEL_DEBUG(...) mp_printf(&mp_plat_print, __VA_ARGS__) |
28 | 28 |
|
29 | 29 | #define U32_TO_BINARY_FMT "%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c" |
30 | 30 | #define U32_TO_BINARY(u32) \ |
@@ -192,6 +192,37 @@ void common_hal_vectorio_vector_shape_set_y(vectorio_vector_shape_t *self, mp_in |
192 | 192 | common_hal_vectorio_vector_shape_set_dirty(self); |
193 | 193 | } |
194 | 194 |
|
| 195 | +mp_obj_tuple_t *common_hal_vectorio_vector_shape_get_location(vectorio_vector_shape_t *self) { |
| 196 | + VECTORIO_SHAPE_DEBUG("%p get_location\n", self); |
| 197 | + mp_obj_tuple_t *pair = MP_OBJ_TO_PTR(mp_obj_new_tuple(2, NULL)); |
| 198 | + pair->items[0] = mp_obj_new_int((mp_int_t)self->x); |
| 199 | + pair->items[1] = mp_obj_new_int((mp_int_t)self->y); |
| 200 | + return pair; |
| 201 | +} |
| 202 | + |
| 203 | + |
| 204 | +void common_hal_vectorio_vector_shape_set_location(vectorio_vector_shape_t *self, mp_obj_t xy) { |
| 205 | + VECTORIO_SHAPE_DEBUG("%p set_location\n", self); |
| 206 | + size_t tuple_len = 0; |
| 207 | + mp_obj_t *tuple_items; |
| 208 | + mp_obj_tuple_get(xy, &tuple_len, &tuple_items); |
| 209 | + if (tuple_len != 2) { |
| 210 | + mp_raise_TypeError_varg(translate("(x,y) integers required")); |
| 211 | + } |
| 212 | + |
| 213 | + mp_int_t x; |
| 214 | + mp_int_t y; |
| 215 | + if (!mp_obj_get_int_maybe(tuple_items[ 0 ], &x) |
| 216 | + || !mp_obj_get_int_maybe(tuple_items[ 1 ], &y) |
| 217 | + || x < SHRT_MIN || x > SHRT_MAX || y < SHRT_MIN || y > SHRT_MAX |
| 218 | + ) { |
| 219 | + mp_raise_ValueError_varg(translate("unsupported %q type"), MP_QSTR_point); |
| 220 | + } |
| 221 | + self->x = (int16_t)x; |
| 222 | + self->y = (int16_t)y; |
| 223 | + common_hal_vectorio_vector_shape_set_dirty(self); |
| 224 | +} |
| 225 | + |
195 | 226 |
|
196 | 227 | mp_obj_t common_hal_vectorio_vector_shape_get_pixel_shader(vectorio_vector_shape_t *self) { |
197 | 228 | VECTORIO_SHAPE_DEBUG("%p get_pixel_shader\n", self); |
@@ -271,10 +302,10 @@ bool vectorio_vector_shape_fill_area(vectorio_vector_shape_t *self, const _displ |
271 | 302 | VECTORIO_SHAPE_PIXEL_DEBUG(" a(%3d, %3d)", pixel_to_get_x, pixel_to_get_y); |
272 | 303 |
|
273 | 304 | if (self->absolute_transform->mirror_x) { |
274 | | - pixel_to_get_y = shape_area.y2 - 1 - (pixel_to_get_y - shape_area.y1); |
| 305 | + pixel_to_get_y = shape_area.y2 - 1 - pixel_to_get_y; |
275 | 306 | } |
276 | 307 | if (self->absolute_transform->mirror_y) { |
277 | | - pixel_to_get_x = shape_area.x2 - 1 - (pixel_to_get_x - shape_area.x1); |
| 308 | + pixel_to_get_x = shape_area.x2 - 1 - pixel_to_get_x; |
278 | 309 | } |
279 | 310 | } else { |
280 | 311 | pixel_to_get_x = input_pixel.x - self->absolute_transform->x - self->absolute_transform->dx * self->x; |
|
0 commit comments