Skip to content

Commit 4e646ee

Browse files
committed
Move vectorio to stubs
1 parent cde6651 commit 4e646ee

File tree

5 files changed

+34
-75
lines changed

5 files changed

+34
-75
lines changed

shared-bindings/vectorio/Circle.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,12 @@
99
#include "py/runtime.h"
1010
#include "supervisor/shared/translate.h"
1111

12-
13-
//| .. currentmodule:: vectorio
14-
//|
15-
//| :class:`Circle` -- Represents a circle by its radius
16-
//| ==========================================================================
12+
//| class Circle:
1713
//|
18-
//| .. class:: Circle(radius)
14+
//| def __init__(self, radius: int):
15+
//| """Circle is positioned on screen by its center point.
1916
//|
20-
//| Circle is positioned on screen by its center point.
21-
//|
22-
//| :param int radius: The radius of the circle in pixels
17+
//| :param radius: The radius of the circle in pixels"""
2318
//|
2419
static mp_obj_t vectorio_circle_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
2520
enum { ARG_radius };
@@ -42,9 +37,8 @@ static mp_obj_t vectorio_circle_make_new(const mp_obj_type_t *type, size_t n_arg
4237
}
4338

4439

45-
//| .. attribute:: radius
46-
//|
47-
//| The radius of the circle in pixels.
40+
//| radius : int = ...
41+
//| """The radius of the circle in pixels."""
4842
//|
4943
STATIC mp_obj_t vectorio_circle_obj_get_radius(mp_obj_t self_in) {
5044
vectorio_circle_t *self = MP_OBJ_TO_PTR(self_in);

shared-bindings/vectorio/Polygon.c

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,13 @@ static mp_obj_t _to_points_list(mp_obj_t points_tuple_list) {
4949
}
5050
return points_list;
5151
}
52-
53-
54-
55-
//| .. currentmodule:: vectorio
56-
//|
57-
//| :class:`Polygon` -- Represents a closed shape by ordered vertices
58-
//| ==========================================================================
52+
//| from typing import List, Tuple
5953
//|
60-
//| .. class:: Polygon( List[ Tuple[ x, y ], ... ] )
54+
//| class Polygon:
55+
//| def __init__(self, points: List[ Tuple[ x, y ], ... ] ):
56+
//| """Represents a closed shape by ordered vertices
6157
//|
62-
//| :param [Point] points_array: Vertices for the polygon
58+
//| :param points: Vertices for the polygon"""
6359
//|
6460
static mp_obj_t vectorio_polygon_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
6561
enum { ARG_points_list };
@@ -83,14 +79,13 @@ static mp_obj_t vectorio_polygon_make_new(const mp_obj_type_t *type, size_t n_ar
8379
}
8480

8581

86-
//| .. attribute:: points
87-
//|
88-
//| Set a new look and shape for this polygon
82+
//| points: List[ Tuple[ x, y ], ... ] = ...
83+
//| """Set a new look and shape for this polygon"""
8984
//|
9085
STATIC mp_obj_t vectorio_polygon_obj_get_points(mp_obj_t self_in) {
9186
vectorio_polygon_t *self = MP_OBJ_TO_PTR(self_in);
9287
mp_obj_t list = mp_obj_new_list(0, NULL);
93-
88+
9489
size_t len = 0;
9590
mp_obj_t *items;
9691
mp_obj_list_get(common_hal_vectorio_polygon_get_points(self), &len, &items);
@@ -123,8 +118,6 @@ const mp_obj_property_t vectorio_polygon_points_obj = {
123118
(mp_obj_t)&mp_const_none_obj},
124119
};
125120

126-
127-
128121
STATIC const mp_rom_map_elem_t vectorio_polygon_locals_dict_table[] = {
129122
{ MP_ROM_QSTR(MP_QSTR_points), MP_ROM_PTR(&vectorio_polygon_points_obj) },
130123
};

shared-bindings/vectorio/Rectangle.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,12 @@
77
#include "py/runtime.h"
88
#include "supervisor/shared/translate.h"
99

10-
11-
//| .. currentmodule:: vectorio
12-
//|
13-
//| :class:`Rectangle` -- Represents a rectangle by defining its bounds
14-
//| ==========================================================================
15-
//|
16-
//| .. class:: Rectangle(width, height)
10+
//| class Rectangle:
11+
//| def __init__(self, width: int, height: int):
12+
//| """Represents a rectangle by defining its bounds
1713
//|
18-
//| :param int width: The number of pixels wide
19-
//| :param int height: The number of pixels high
14+
//| :param width: The number of pixels wide
15+
//| :param height: The number of pixels high"""
2016
//|
2117
static mp_obj_t vectorio_rectangle_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
2218
enum { ARG_width, ARG_height };

shared-bindings/vectorio/VectorShape.c

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,15 @@
1919
#include "supervisor/shared/translate.h"
2020

2121

22-
//| .. currentmodule:: vectorio
22+
//| class VectorShape:
23+
//| def __init__(self, shape: vectorio.Polygon, pixel_shader: displayio.Palette, x: int=0, y: int=0):
24+
//| """Binds a vector shape to a location and pixel color
2325
//|
24-
//| :class:`VectorShape` -- Binds a vector shape to a location and pixel color
25-
//| ==========================================================================
26-
//|
27-
//| .. class:: VectorShape( shape, pixel_shader, x=0, y=0)
28-
//|
29-
//| :param vectorio.Polygon shape: The shape to draw.
30-
//| :param displayio.Palette pixel_shader: The pixel shader that produces colors from values
31-
//| :param int x: Initial x position of the center axis of the shape within the parent.
32-
//| :param int y: Initial y position of the center axis of the shape within the parent.
26+
//| :param shape: The shape to draw.
27+
//| :param pixel_shader: The pixel shader that produces colors from values
28+
//| :param x: Initial x position of the center axis of the shape within the parent.
29+
//| :param y: Initial y position of the center axis of the shape within the parent."""
30+
//| ...
3331
//|
3432
STATIC mp_obj_t vectorio_vector_shape_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
3533
enum { ARG_shape, ARG_pixel_shader, ARG_x, ARG_y };
@@ -95,9 +93,8 @@ STATIC mp_obj_t vectorio_vector_shape_make_new(const mp_obj_type_t *type, size_t
9593
}
9694

9795

98-
//| .. attribute:: x
99-
//|
100-
//| X position of the center point of the shape in the parent.
96+
//| x: int = ...
97+
//| """X position of the center point of the shape in the parent."""
10198
//|
10299
STATIC mp_obj_t vectorio_vector_shape_obj_get_x(mp_obj_t self_in) {
103100
vectorio_vector_shape_t *self = MP_OBJ_TO_PTR(self_in);
@@ -122,9 +119,8 @@ const mp_obj_property_t vectorio_vector_shape_x_obj = {
122119
};
123120

124121

125-
//| .. attribute:: y
126-
//|
127-
//| Y position of the center point of the shape in the parent.
122+
//| y: int = ...
123+
//| """Y position of the center point of the shape in the parent."""
128124
//|
129125
STATIC mp_obj_t vectorio_vector_shape_obj_get_y(mp_obj_t self_in) {
130126
vectorio_vector_shape_t *self = MP_OBJ_TO_PTR(self_in);
@@ -149,9 +145,8 @@ const mp_obj_property_t vectorio_vector_shape_y_obj = {
149145
};
150146

151147

152-
//| .. attribute:: pixel_shader
153-
//|
154-
//| The pixel shader of the shape.
148+
//| pixel_shader: displayio.Palette = ...
149+
//| """The pixel shader of the shape."""
155150
//|
156151
STATIC mp_obj_t vectorio_vector_shape_obj_get_pixel_shader(mp_obj_t self_in) {
157152
vectorio_vector_shape_t *self = MP_OBJ_TO_PTR(self_in);

shared-bindings/vectorio/__init__.c

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,8 @@
88
#include "shared-bindings/vectorio/Rectangle.h"
99
#include "shared-bindings/vectorio/VectorShape.h"
1010

11-
//| :mod:`vectorio` --- Lightweight 2d shapes for displays
12-
//| =========================================================================
11+
//| """Lightweight 2d shapes for displays"""
1312
//|
14-
//| .. module:: vectorio
15-
//| :synopsis: Adds vector graphics to displayio
16-
//| :platform: SAMD21, SAMD51, nRF52
17-
//|
18-
//| The `vectorio` module contains classes to construct shapes
19-
//| by describing their points rather than providing them in bitmaps.
20-
//|
21-
//| Libraries
22-
//|
23-
//| .. toctree::
24-
//| :maxdepth: 3
25-
//|
26-
//| Circle
27-
//| Polygon
28-
//| Rectangle
29-
//| VectorShape
30-
//|
31-
3213

3314
STATIC const mp_rom_map_elem_t vectorio_module_globals_table[] = {
3415
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_vectorio) },

0 commit comments

Comments
 (0)