summaryrefslogtreecommitdiff
path: root/shared-bindings/vectorio
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2020-05-12 18:40:02 -0700
committerScott Shawcroft <scott@tannewt.org>2020-05-12 18:40:02 -0700
commit4e646ee6e4473195df3eba4bd7e006e44bfd1cdc (patch)
treeee761568c43fc67e5fff01a54f6811bf2b82b0f6 /shared-bindings/vectorio
parentcde665172136b9be7720e22dbdc48c2bd224c483 (diff)
Move vectorio to stubs
Diffstat (limited to 'shared-bindings/vectorio')
-rw-r--r--shared-bindings/vectorio/Circle.c18
-rw-r--r--shared-bindings/vectorio/Polygon.c23
-rw-r--r--shared-bindings/vectorio/Rectangle.c14
-rw-r--r--shared-bindings/vectorio/VectorShape.c33
-rw-r--r--shared-bindings/vectorio/__init__.c21
5 files changed, 34 insertions, 75 deletions
diff --git a/shared-bindings/vectorio/Circle.c b/shared-bindings/vectorio/Circle.c
index 260e80d0f..6b5682e14 100644
--- a/shared-bindings/vectorio/Circle.c
+++ b/shared-bindings/vectorio/Circle.c
@@ -9,17 +9,12 @@
#include "py/runtime.h"
#include "supervisor/shared/translate.h"
-
-//| .. currentmodule:: vectorio
-//|
-//| :class:`Circle` -- Represents a circle by its radius
-//| ==========================================================================
+//| class Circle:
//|
-//| .. class:: Circle(radius)
+//| def __init__(self, radius: int):
+//| """Circle is positioned on screen by its center point.
//|
-//| Circle is positioned on screen by its center point.
-//|
-//| :param int radius: The radius of the circle in pixels
+//| :param radius: The radius of the circle in pixels"""
//|
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_radius };
@@ -42,9 +37,8 @@ static mp_obj_t vectorio_circle_make_new(const mp_obj_type_t *type, size_t n_arg
}
-//| .. attribute:: radius
-//|
-//| The radius of the circle in pixels.
+//| radius : int = ...
+//| """The radius of the circle in pixels."""
//|
STATIC mp_obj_t vectorio_circle_obj_get_radius(mp_obj_t self_in) {
vectorio_circle_t *self = MP_OBJ_TO_PTR(self_in);
diff --git a/shared-bindings/vectorio/Polygon.c b/shared-bindings/vectorio/Polygon.c
index b8bb377ac..5f4d85e21 100644
--- a/shared-bindings/vectorio/Polygon.c
+++ b/shared-bindings/vectorio/Polygon.c
@@ -49,17 +49,13 @@ static mp_obj_t _to_points_list(mp_obj_t points_tuple_list) {
}
return points_list;
}
-
-
-
-//| .. currentmodule:: vectorio
-//|
-//| :class:`Polygon` -- Represents a closed shape by ordered vertices
-//| ==========================================================================
+//| from typing import List, Tuple
//|
-//| .. class:: Polygon( List[ Tuple[ x, y ], ... ] )
+//| class Polygon:
+//| def __init__(self, points: List[ Tuple[ x, y ], ... ] ):
+//| """Represents a closed shape by ordered vertices
//|
-//| :param [Point] points_array: Vertices for the polygon
+//| :param points: Vertices for the polygon"""
//|
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_points_list };
@@ -83,14 +79,13 @@ static mp_obj_t vectorio_polygon_make_new(const mp_obj_type_t *type, size_t n_ar
}
-//| .. attribute:: points
-//|
-//| Set a new look and shape for this polygon
+//| points: List[ Tuple[ x, y ], ... ] = ...
+//| """Set a new look and shape for this 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);
mp_obj_t list = mp_obj_new_list(0, NULL);
-
+
size_t len = 0;
mp_obj_t *items;
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 = {
(mp_obj_t)&mp_const_none_obj},
};
-
-
STATIC const mp_rom_map_elem_t vectorio_polygon_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_points), MP_ROM_PTR(&vectorio_polygon_points_obj) },
};
diff --git a/shared-bindings/vectorio/Rectangle.c b/shared-bindings/vectorio/Rectangle.c
index ea468f788..f04a25c35 100644
--- a/shared-bindings/vectorio/Rectangle.c
+++ b/shared-bindings/vectorio/Rectangle.c
@@ -7,16 +7,12 @@
#include "py/runtime.h"
#include "supervisor/shared/translate.h"
-
-//| .. currentmodule:: vectorio
-//|
-//| :class:`Rectangle` -- Represents a rectangle by defining its bounds
-//| ==========================================================================
-//|
-//| .. class:: Rectangle(width, height)
+//| class Rectangle:
+//| def __init__(self, width: int, height: int):
+//| """Represents a rectangle by defining its bounds
//|
-//| :param int width: The number of pixels wide
-//| :param int height: The number of pixels high
+//| :param width: The number of pixels wide
+//| :param height: The number of pixels high"""
//|
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_width, ARG_height };
diff --git a/shared-bindings/vectorio/VectorShape.c b/shared-bindings/vectorio/VectorShape.c
index 4b39ec996..c512bcd54 100644
--- a/shared-bindings/vectorio/VectorShape.c
+++ b/shared-bindings/vectorio/VectorShape.c
@@ -19,17 +19,15 @@
#include "supervisor/shared/translate.h"
-//| .. currentmodule:: vectorio
+//| class VectorShape:
+//| def __init__(self, shape: vectorio.Polygon, pixel_shader: displayio.Palette, x: int=0, y: int=0):
+//| """Binds a vector shape to a location and pixel color
//|
-//| :class:`VectorShape` -- Binds a vector shape to a location and pixel color
-//| ==========================================================================
-//|
-//| .. class:: VectorShape( shape, pixel_shader, x=0, y=0)
-//|
-//| :param vectorio.Polygon shape: The shape to draw.
-//| :param displayio.Palette pixel_shader: The pixel shader that produces colors from values
-//| :param int x: Initial x position of the center axis of the shape within the parent.
-//| :param int y: Initial y position of the center axis of the shape within the parent.
+//| :param shape: The shape to draw.
+//| :param pixel_shader: The pixel shader that produces colors from values
+//| :param x: Initial x position of the center axis of the shape within the parent.
+//| :param y: Initial y position of the center axis of the shape within the parent."""
+//| ...
//|
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) {
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
}
-//| .. attribute:: x
-//|
-//| X position of the center point of the shape in the parent.
+//| x: int = ...
+//| """X position of the center point of the shape in the parent."""
//|
STATIC mp_obj_t vectorio_vector_shape_obj_get_x(mp_obj_t self_in) {
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 = {
};
-//| .. attribute:: y
-//|
-//| Y position of the center point of the shape in the parent.
+//| y: int = ...
+//| """Y position of the center point of the shape in the parent."""
//|
STATIC mp_obj_t vectorio_vector_shape_obj_get_y(mp_obj_t self_in) {
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 = {
};
-//| .. attribute:: pixel_shader
-//|
-//| The pixel shader of the shape.
+//| pixel_shader: displayio.Palette = ...
+//| """The pixel shader of the shape."""
//|
STATIC mp_obj_t vectorio_vector_shape_obj_get_pixel_shader(mp_obj_t self_in) {
vectorio_vector_shape_t *self = MP_OBJ_TO_PTR(self_in);
diff --git a/shared-bindings/vectorio/__init__.c b/shared-bindings/vectorio/__init__.c
index b9e3828bd..c74783426 100644
--- a/shared-bindings/vectorio/__init__.c
+++ b/shared-bindings/vectorio/__init__.c
@@ -8,27 +8,8 @@
#include "shared-bindings/vectorio/Rectangle.h"
#include "shared-bindings/vectorio/VectorShape.h"
-//| :mod:`vectorio` --- Lightweight 2d shapes for displays
-//| =========================================================================
+//| """Lightweight 2d shapes for displays"""
//|
-//| .. module:: vectorio
-//| :synopsis: Adds vector graphics to displayio
-//| :platform: SAMD21, SAMD51, nRF52
-//|
-//| The `vectorio` module contains classes to construct shapes
-//| by describing their points rather than providing them in bitmaps.
-//|
-//| Libraries
-//|
-//| .. toctree::
-//| :maxdepth: 3
-//|
-//| Circle
-//| Polygon
-//| Rectangle
-//| VectorShape
-//|
-
STATIC const mp_rom_map_elem_t vectorio_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_vectorio) },