8000 Update the docs for vectorio · urish/circuitpython@f35d157 · GitHub
[go: up one dir, main page]

Skip to content

Commit f35d157

Browse files
Update the docs for vectorio
1 parent cf5c32b commit f35d157

File tree

4 files changed

+87
-16
lines changed

4 files changed

+87
-16
lines changed

shared-bindings/vectorio/Circle.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
//| def __init__(self, pixel_shader: Union[displayio.ColorConverter, displayio.Palette], radius: int, x: int, y: int) -> None:
1616
//| """Circle is positioned on screen by its center point.
1717
//|
18-
//| :param pixel_shader: The pixel shader that produces colors from values
19-
//| :param radius: The radius of the circle in pixels
20-
//| :param x: Initial x position of the axis.
21-
//| :param y: Initial y position of the axis."""
18+
//| :param Union[~displayio.ColorConverter,~displayio.Palette] pixel_shader: The pixel shader that produces colors from values
19+
//| :param int radius: The radius of the circle in pixels
20+
//| :param int x: Initial x position of the axis.
21+
//| :param int y: Initial y position of the axis."""
2222
//|
2323
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) {
2424
enum { ARG_pixel_shader, ARG_radius, ARG_x, ARG_y };
@@ -81,6 +81,21 @@ const mp_obj_property_t vectorio_circle_radius_obj = {
8181
};
8282

8383

84+
// Documentation for properties inherited from VectorShape.
85+
86+
//| x : int
87+
//| """X position of the center point of the circle in the parent."""
88+
//|
89+
//| y : int
90+
//| """Y position of the center point of the circle in the parent."""
91+
//|
92+
//| location : Tuple[int,int]
93+
//| """(X,Y) position of the center point of the circle in the parent."""
94+
//|
95+
//| pixel_shader : Union[displayio.ColorConverter,displayio.Palette]
96+
//| """The pixel shader of the circle."""
97+
//|
98+
8499
STATIC const mp_rom_map_elem_t vectorio_circle_locals_dict_table[] = {
85100
// Properties
86101
{ MP_ROM_QSTR(MP_QSTR_radius), MP_ROM_PTR(&vectorio_circle_radius_obj) },

shared-bindings/vectorio/Polygon.c

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818

1919
//| class Polygon:
2020
//| def __init__(self, pixel_shader: Union[displayio.ColorConverter, displayio.Palette], points: List[Tuple[int, int]], x: int, y: int) -> None:
21-
//| """Represents a closed shape by ordered vertices
21+
//| """Represents a closed shape by ordered vertices. The path will be treated as
22+
//| 'closed', the last point will connect to the first point.
2223
//|
23-
//| :param pixel_shader: The pixel shader that produces colors from values
24-
//| :param points: Vertices for the polygon
25-
//| :param x: Initial screen x position of the 0,0 origin in the points list.
26-
//| :param y: Initial screen y position of the 0,0 origin in the points list."""
24+
//| :param Union[~displayio.ColorConverter,~displayio.Palette] pixel_shader: The pixel
25+
//| shader that produces colors from values
26+
//| :param List[Tuple[int,int]] points: Vertices for the polygon
27+
//| :param int x: Initial screen x position of the 0,0 origin in the points list.
28+
//| :param int y: Initial screen y position of the 0,0 origin in the points list."""
2729
//|
2830
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) {
2931
enum { ARG_pixel_shader, ARG_points_list, ARG_x, ARG_y };
@@ -63,7 +65,7 @@ STATIC const vectorio_draw_protocol_t polygon_draw_protocol = {
6365

6466

6567
//| points: List[Tuple[int, int]]
66-
//| """Set a new look and shape for this polygon"""
68+
//| """Vertices for the polygon."""
6769
//|
6870
STATIC mp_obj_t vectorio_polygon_obj_get_points(mp_obj_t self_in) {
6971
vectorio_polygon_t *self = MP_OBJ_TO_PTR(self_in);
@@ -86,6 +88,22 @@ const mp_obj_property_t vectorio_polygon_points_obj = {
8688
MP_ROM_NONE},
8789
};
8890

91+
92+
// Documentation for properties inherited from VectorShape.
93+
94+
//| x : int
95+
//| """Initial screen X position of the 0,0 origin in the points list."""
96+
//|
97+
//| y : int
98+
//| """Initial screen Y position of the 0,0 origin in the points list."""
99+
//|
100+
//| location : Tuple[int,int]
101+
//| """Initial screen (X,Y) position of the 0,0 origin in the points list."""
102+
//|
103+
//| pixel_shader : Union[displayio.ColorConverter,displayio.Palette]
104+
//| """The pixel shader of the polygon."""
105+
//|
106+
89107
STATIC const mp_rom_map_elem_t vectorio_polygon_locals_dict_table[] = {
90108
// Properties
91109
{ MP_ROM_QSTR(MP_QSTR_points), MP_ROM_PTR(&vectorio_polygon_points_obj) },

shared-bindings/vectorio/Rectangle.c

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
//| def __init__(self, pixel_shader: Union[displayio.ColorConverter, displayio.Palette], width: int, height: int, x: int, y: int) -> None:
1414
//| """Represents a rectangle by defining its bounds
1515
//|
16-
//| :param pixel_shader: The pixel shader that produces colors from values
17-
//| :param width: The number of pixels wide
18-
//| :param height: The number of pixels high
19-
//| :param x: Initial x position of the top left corner.
20-
//| :param y: Initial y position of the top left corner."""
16+
//| :param Union[~displayio.ColorConverter,~displayio.Palette] pixel_shader: The pixel shader that produces colors from values
17+
//| :param int width: The number of pixels wide
18+
//| :param int height: The number of pixels high
19+
//| :param int x: Initial x position of the top left corner.
20+
//| :param int y: Initial y position of the top left corner."""
2121
//|
2222
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) {
2323
enum { ARG_pixel_shader, ARG_width, ARG_height, ARG_x, ARG_y };
@@ -60,6 +60,22 @@ STATIC const vectorio_draw_protocol_t rectangle_draw_protocol = {
6060
.draw_protocol_impl = &vectorio_vector_shape_draw_protocol_impl
6161
};
6262

63+
64+
// Documentation for properties inherited from VectorShape.
65+
66+
//| x : int
67+
//| """X position of the top left corner of the rectangle in the parent."""
68+
//|
69+
//| y : int
70+
//| """Y position of the top left corner of the rectangle in the parent."""
71+
//|
72+
//| location : Tuple[int,int]
73+
//| """(X,Y) position of the top left corner of the rectangle in the parent."""
74+
//|
75+
//| pixel_shader : Union[displayio.ColorConverter,displayio.Palette]
76+
//| """The pixel shader of the rectangle."""
77+
//|
78+
6379
STATIC const mp_rom_map_elem_t vectorio_rectangle_locals_dict_table[] = {
6480
// Properties
6581
{ MP_ROM_QSTR(MP_QSTR_x), MP_ROM_PTR(&vectorio_vector_shape_x_obj) },

shared-bindings/vectorio/__init__.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,29 @@
77
#include "shared-bindings/vectorio/Polygon.h"
88
#include "shared-bindings/vectorio/Rectangle.h"
99

10-
//| """Lightweight 2d shapes for displays"""
10+
//| """Lightweight 2D shapes for displays
11+
//|
12+
//| The :py:attr:`vectorio` module provide simple filled drawing primitives for
13+
//| use with `displayio`.
14+
//|
15+
//| .. code-block:: python
16+
//|
17+
//| group = displayio.Group()
18+
//|
19+
//| palette = displayio.Palette(1)
20+
//| palette[0] = 0x125690
21+
//|
22+
//| circle = vectorio.Circle(pixel_shader=palette, radius=25, x=70, y=40)
23+
//| group.append(circle)
24+
//|
25+
//| rectangle = vectorio.Rectangle(pixel_shader=palette, width=40, height=30, x=55, y=45)
26+
//| group.append(rectangle)
27+
//|
28+
//| points=[(5, 5), (100, 20), (20, 20), (20, 100)]
29+
//| polygon = vectorio.Polygon(pixel_shader=palette, points=points, x=0, y=0)
30+
//| group.append(polygon)
31+
//|
32+
//| """
1133
//|
1234

1335
STATIC const mp_rom_map_elem_t vectorio_module_globals_table[] = {

0 commit comments

Comments
 (0)
0