Skip to content

Update the docs for vectorio #5330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions shared-bindings/vectorio/Circle.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
//| def __init__(self, pixel_shader: Union[displayio.ColorConverter, displayio.Palette], radius: int, x: int, y: int) -> None:
//| """Circle is positioned on screen by its center point.
//|
//| :param pixel_shader: The pixel shader that produces colors from values
//| :param radius: The radius of the circle in pixels
//| :param x: Initial x position of the axis.
//| :param y: Initial y position of the axis."""
//| :param Union[~displayio.ColorConverter,~displayio.Palette] pixel_shader: The pixel shader that produces colors from values
//| :param int radius: The radius of the circle in pixels
//| :param int x: Initial x position of the axis.
//| :param int y: Initial y position of the axis."""
//|
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) {
enum { ARG_pixel_shader, ARG_radius, ARG_x, ARG_y };
Expand Down Expand Up @@ -81,6 +81,21 @@ const mp_obj_property_t vectorio_circle_radius_obj = {
};


// Documentation for properties inherited from VectorShape.

//| x : int
//| """X position of the center point of the circle in the parent."""
//|
//| y : int
//| """Y position of the center point of the circle in the parent."""
//|
//| location : Tuple[int,int]
//| """(X,Y) position of the center point of the circle in the parent."""
//|
//| pixel_shader : Union[displayio.ColorConverter,displayio.Palette]
//| """The pixel shader of the circle."""
//|

STATIC const mp_rom_map_elem_t vectorio_circle_locals_dict_table[] = {
// Properties
{ MP_ROM_QSTR(MP_QSTR_radius), MP_ROM_PTR(&vectorio_circle_radius_obj) },
Expand Down
30 changes: 24 additions & 6 deletions shared-bindings/vectorio/Polygon.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@

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


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


// Documentation for properties inherited from VectorShape.

//| x : int
//| """X position of the 0,0 origin in the points list."""
//|
//| y : int
//| """Y position of the 0,0 origin in the points list."""
//|
//| location : Tuple[int,int]
//| """(X,Y) position of the 0,0 origin in the points list."""
//|
//| pixel_shader : Union[displayio.ColorConverter,displayio.Palette]
//| """The pixel shader of the polygon."""
//|

STATIC const mp_rom_map_elem_t vectorio_polygon_locals_dict_table[] = {
// Properties
{ MP_ROM_QSTR(MP_QSTR_points), MP_ROM_PTR(&vectorio_polygon_points_obj) },
Expand Down
26 changes: 21 additions & 5 deletions shared-bindings/vectorio/Rectangle.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
//| def __init__(self, pixel_shader: Union[displayio.ColorConverter, displayio.Palette], width: int, height: int, x: int, y: int) -> None:
//| """Represents a rectangle by defining its bounds
//|
//| :param pixel_shader: The pixel shader that produces colors from values
//| :param width: The number of pixels wide
//| :param height: The number of pixels high
//| :param x: Initial x position of the top left corner.
//| :param y: Initial y position of the top left corner."""
//| :param Union[~displayio.ColorConverter,~displayio.Palette] pixel_shader: The pixel shader that produces colors from values
//| :param int width: The number of pixels wide
//| :param int height: The number of pixels high
//| :param int x: Initial x position of the top left corner.
//| :param int y: Initial y position of the top left corner."""
//|
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) {
enum { ARG_pixel_shader, ARG_width, ARG_height, ARG_x, ARG_y };
Expand Down Expand Up @@ -60,6 +60,22 @@ STATIC const vectorio_draw_protocol_t rectangle_draw_protocol = {
.draw_protocol_impl = &vectorio_vector_shape_draw_protocol_impl
};


// Documentation for properties inherited from VectorShape.

//| x : int
//| """X position of the top left corner of the rectangle in the parent."""
//|
//| y : int
//| """Y position of the top left corner of the rectangle in the parent."""
//|
//| location : Tuple[int,int]
//| """(X,Y) position of the top left corner of the rectangle in the parent."""
//|
//| pixel_shader : Union[displayio.ColorConverter,displayio.Palette]
//| """The pixel shader of the rectangle."""
//|

STATIC const mp_rom_map_elem_t vectorio_rectangle_locals_dict_table[] = {
// Properties
{ MP_ROM_QSTR(MP_QSTR_x), MP_ROM_PTR(&vectorio_vector_shape_x_obj) },
Expand Down
24 changes: 23 additions & 1 deletion shared-bindings/vectorio/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,29 @@
#include "shared-bindings/vectorio/Polygon.h"
#include "shared-bindings/vectorio/Rectangle.h"

//| """Lightweight 2d shapes for displays"""
//| """Lightweight 2D shapes for displays
//|
//| The :py:attr:`vectorio` module provide simple filled drawing primitives for
//| use with `displayio`.
//|
//| .. code-block:: python
//|
//| group = displayio.Group()
//|
//| palette = displayio.Palette(1)
//| palette[0] = 0x125690
//|
//| circle = vectorio.Circle(pixel_shader=palette, radius=25, x=70, y=40)
//| group.append(circle)
//|
//| rectangle = vectorio.Rectangle(pixel_shader=palette, width=40, height=30, x=55, y=45)
//| group.append(rectangle)
//|
//| points=[(5, 5), (100, 20), (20, 20), (20, 100)]
//| polygon = vectorio.Polygon(pixel_shader=palette, points=points, x=0, y=0)
//| group.append(polygon)
//|
//| """
//|

STATIC const mp_rom_map_elem_t vectorio_module_globals_table[] = {
Expand Down