Merge pull request #5330 from lesamouraipourpre/vectorio-docs

Update the docs for vectorio
This commit is contained in:
microDev 2021-09-14 00:18:14 +05:30 committed by GitHub
commit 3cb2ab318d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 87 additions and 16 deletions

View File

@ -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 };
@ -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) },

View File

@ -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 };
@ -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);
@ -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) },

View File

@ -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 };
@ -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) },

View File

@ -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[] = {