@@ -60,6 +60,51 @@ STATIC const vectorio_draw_protocol_t rectangle_draw_protocol = {
60
60
.draw_protocol_impl = & vectorio_vector_shape_draw_protocol_impl
61
61
};
62
62
63
+ //| width : int
64
+ //| """The width of the rectangle in pixels."""
65
+ //|
66
+ STATIC mp_obj_t vectorio_rectangle_obj_get_width (mp_obj_t self_in ) {
67
+ vectorio_rectangle_t * self = MP_OBJ_TO_PTR (self_in );
68
+ return mp_obj_new_int (common_hal_vectorio_rectangle_get_width (self ));
69
+ }
70
+ MP_DEFINE_CONST_FUN_OBJ_1 (vectorio_rectangle_get_width_obj , vectorio_rectangle_obj_get_width );
71
+
72
+ STATIC mp_obj_t vectorio_rectangle_obj_set_width (mp_obj_t self_in , mp_obj_t width ) {
73
+ vectorio_rectangle_t * self = MP_OBJ_TO_PTR (self_in );
74
+ common_hal_vectorio_rectangle_set_width (self , mp_obj_get_int (width ));
75
+ return mp_const_none ;
76
+ }
77
+ MP_DEFINE_CONST_FUN_OBJ_2 (vectorio_rectangle_set_width_obj , vectorio_rectangle_obj_set_width );
78
+
79
+ const mp_obj_property_t vectorio_rectangle_width_obj = {
80
+ .base .type = & mp_type_property ,
81
+ .proxy = {(mp_obj_t )& vectorio_rectangle_get_width_obj ,
82
+ (mp_obj_t )& vectorio_rectangle_set_width_obj ,
83
+ MP_ROM_NONE },
84
+ };
85
+
86
+ //| height : int
87
+ //| """The height of the rectangle in pixels."""
88
+ //|
89
+ STATIC mp_obj_t vectorio_rectangle_obj_get_height (mp_obj_t self_in ) {
90
+ vectorio_rectangle_t * self = MP_OBJ_TO_PTR (self_in );
91
+ return mp_obj_new_int (common_hal_vectorio_rectangle_get_height (self ));
92
+ }
93
+ MP_DEFINE_CONST_FUN_OBJ_1 (vectorio_rectangle_get_height_obj , vectorio_rectangle_obj_get_height );
94
+
95
+ STATIC mp_obj_t vectorio_rectangle_obj_set_height (mp_obj_t self_in , mp_obj_t height ) {
96
+ vectorio_rectangle_t * self = MP_OBJ_TO_PTR (self_in );
97
+ common_hal_vectorio_rectangle_set_height (self , mp_obj_get_int (height ));
98
+ return mp_const_none ;
99
+ }
100
+ MP_DEFINE_CONST_FUN_OBJ_2 (vectorio_rectangle_set_height_obj , vectorio_rectangle_obj_set_height );
101
+
102
+ const mp_obj_property_t vectorio_rectangle_height_obj = {
103
+ .base .type = & mp_type_property ,
104
+ .proxy = {(mp_obj_t )& vectorio_rectangle_get_height_obj ,
105
+ (mp_obj_t )& vectorio_rectangle_set_height_obj ,
106
+ MP_ROM_NONE },
107
+ };
63
108
64
109
// Documentation for properties inherited from VectorShape.
65
110
@@ -80,6 +125,8 @@ STATIC const mp_rom_map_elem_t vectorio_rectangle_locals_dict_table[] = {
80
125
// Properties
81
126
{ MP_ROM_QSTR (MP_QSTR_x ), MP_ROM_PTR (& vectorio_vector_shape_x_obj ) },
82
127
{ MP_ROM_QSTR (MP_QSTR_y ), MP_ROM_PTR (& vectorio_vector_shape_y_obj ) },
128
+ { MP_ROM_QSTR (MP_QSTR_width ), MP_ROM_PTR (& vectorio_rectangle_width_obj ) },
129
+ { MP_ROM_QSTR (MP_QSTR_height ), MP_ROM_PTR (& vectorio_rectangle_height_obj ) },
83
130
{ MP_ROM_QSTR (MP_QSTR_location ), MP_ROM_PTR (& vectorio_vector_shape_location_obj ) },
84
131
{ MP_ROM_QSTR (MP_QSTR_pixel_shader ), MP_ROM_PTR (& vectorio_vector_shape_pixel_shader_obj ) },
85
132
};
0 commit comments