2020-05-02 05:21:35 -04:00
|
|
|
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_VECTORIO_SHAPE_H
|
|
|
|
#define MICROPY_INCLUDED_SHARED_BINDINGS_VECTORIO_SHAPE_H
|
|
|
|
|
2021-08-01 16:01:57 -04:00
|
|
|
#include "py/objproperty.h"
|
2021-08-08 03:14:53 -04:00
|
|
|
#include "py/objtuple.h"
|
2021-08-01 16:01:57 -04:00
|
|
|
|
|
|
|
#include "shared-bindings/vectorio/__init__.h"
|
2020-05-02 05:21:35 -04:00
|
|
|
#include "shared-module/vectorio/VectorShape.h"
|
2020-05-09 02:03:15 -04:00
|
|
|
#include "shared-module/displayio/area.h"
|
2020-05-02 05:21:35 -04:00
|
|
|
|
|
|
|
extern const mp_obj_type_t vectorio_vector_shape_type;
|
|
|
|
|
2021-08-01 16:01:57 -04:00
|
|
|
// Python shared bindings constructor
|
2021-09-10 04:24:33 -04:00
|
|
|
mp_obj_t vectorio_vector_shape_make_new(const mp_obj_t shape, const mp_obj_t pixel_shader, int32_t x, int32_t y);
|
2021-08-01 16:01:57 -04:00
|
|
|
|
|
|
|
// C data constructor
|
2020-05-02 05:21:35 -04:00
|
|
|
void common_hal_vectorio_vector_shape_construct(vectorio_vector_shape_t *self,
|
2021-03-15 09:57:36 -04:00
|
|
|
vectorio_ishape_t ishape,
|
2021-09-10 04:24:33 -04:00
|
|
|
mp_obj_t pixel_shader, int32_t x, int32_t y);
|
2020-05-02 05:21:35 -04:00
|
|
|
|
vectorio contains(x, y)
new utility function for all vectorio shape specializations for testing
whether a screen-space x,y point falls within a shape's x,y.
This respects the current orientation of the screen in the manner of
displayio and vectorio - so your x,y requests are in the same coordinate
domain as your x,y locations and your width/height etc. properties that
ou set on other shapes. I.e., if you're using this for touch points then
you will need to make sure the touch events are in the same x,y domain as
your display.
```
contains(2, 4) -> true
------------------
| |
| |
| -- |
| | \ |
| |. \ |
| | \ |
| |____\ |
| |
------------------
contains(5, 4) -> false
------------------
| |
| |
| -- |
| | \ |
| | \. |
| | \ |
| |____\ |
| |
------------------
```
This helps provide low overhead introspection of shape coverage on screen.
It's envisioned that this will be used for things like touch-and-drag
widget controls, touch "areas" and may help with random ornament placement
on toy Christmas trees.
2021-12-27 16:31:18 -05:00
|
|
|
bool common_hal_vectorio_vector_shape_contains(vectorio_vector_shape_t *self, mp_int_t x, mp_int_t y);
|
|
|
|
|
2020-05-02 05:21:35 -04:00
|
|
|
void common_hal_vectorio_vector_shape_set_dirty(void *self);
|
|
|
|
|
|
|
|
mp_int_t common_hal_vectorio_vector_shape_get_x(vectorio_vector_shape_t *self);
|
2021-09-10 16:48:01 -04:00
|
|
|
void common_hal_vectorio_vector_shape_set_x(vectorio_vector_shape_t *self, mp_int_t x);
|
2020-05-02 05:21:35 -04:00
|
|
|
|
2021-08-08 03:14:53 -04:00
|
|
|
mp_obj_tuple_t *common_hal_vectorio_vector_shape_get_location(vectorio_vector_shape_t *self);
|
|
|
|
void common_hal_vectorio_vector_shape_set_location(vectorio_vector_shape_t *self, mp_obj_t xy);
|
|
|
|
|
2020-05-02 05:21:35 -04:00
|
|
|
mp_int_t common_hal_vectorio_vector_shape_get_y(vectorio_vector_shape_t *self);
|
2021-09-10 16:48:01 -04:00
|
|
|
void common_hal_vectorio_vector_shape_set_y(vectorio_vector_shape_t *self, mp_int_t y);
|
2020-05-02 05:21:35 -04:00
|
|
|
|
2022-11-11 18:50:07 -05:00
|
|
|
mp_int_t common_hal_vectorio_vector_shape_get_hidden(vectorio_vector_shape_t *self);
|
|
|
|
void common_hal_vectorio_vector_shape_set_hidden(vectorio_vector_shape_t *self, bool hidden);
|
|
|
|
|
2020-05-02 05:21:35 -04:00
|
|
|
mp_obj_t common_hal_vectorio_vector_shape_get_pixel_shader(vectorio_vector_shape_t *self);
|
|
|
|
void common_hal_vectorio_vector_shape_set_pixel_shader(vectorio_vector_shape_t *self, mp_obj_t pixel_shader);
|
|
|
|
|
2020-05-09 02:03:15 -04:00
|
|
|
void vectorio_vector_shape_update_transform(vectorio_vector_shape_t *self, displayio_buffer_transform_t *group_transform);
|
|
|
|
|
2021-08-01 16:01:57 -04:00
|
|
|
// Composable property definition for shapes that use VectorShape
|
|
|
|
extern vectorio_draw_protocol_impl_t vectorio_vector_shape_draw_protocol_impl;
|
2022-05-01 12:24:05 -04:00
|
|
|
extern const mp_obj_property_getset_t vectorio_vector_shape_x_obj;
|
|
|
|
extern const mp_obj_property_getset_t vectorio_vector_shape_y_obj;
|
2022-11-11 18:50:07 -05:00
|
|
|
extern const mp_obj_property_getset_t vectorio_vector_shape_hidden_obj;
|
2022-05-01 12:24:05 -04:00
|
|
|
extern const mp_obj_property_getset_t vectorio_vector_shape_location_obj;
|
|
|
|
extern const mp_obj_property_getset_t vectorio_vector_shape_pixel_shader_obj;
|
vectorio contains(x, y)
new utility function for all vectorio shape specializations for testing
whether a screen-space x,y point falls within a shape's x,y.
This respects the current orientation of the screen in the manner of
displayio and vectorio - so your x,y requests are in the same coordinate
domain as your x,y locations and your width/height etc. properties that
ou set on other shapes. I.e., if you're using this for touch points then
you will need to make sure the touch events are in the same x,y domain as
your display.
```
contains(2, 4) -> true
------------------
| |
| |
| -- |
| | \ |
| |. \ |
| | \ |
| |____\ |
| |
------------------
contains(5, 4) -> false
------------------
| |
| |
| -- |
| | \ |
| | \. |
| | \ |
| |____\ |
| |
------------------
```
This helps provide low overhead introspection of shape coverage on screen.
It's envisioned that this will be used for things like touch-and-drag
widget controls, touch "areas" and may help with random ornament placement
on toy Christmas trees.
2021-12-27 16:31:18 -05:00
|
|
|
extern const mp_obj_fun_builtin_fixed_t vectorio_vector_shape_contains_obj;
|
2021-08-01 16:01:57 -04:00
|
|
|
|
2020-05-02 05:21:35 -04:00
|
|
|
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_VECTORIO_SHAPE_H
|