From aed14aca2205e16aad86af0e7ba685c01fe96ac9 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Wed, 8 Mar 2023 12:08:47 +0000 Subject: [PATCH] PicoGraphics: Expose line thickness support. --- .../modules/picographics/picographics.c | 2 +- .../modules/picographics/picographics.cpp | 25 +++++++++++++------ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/micropython/modules/picographics/picographics.c b/micropython/modules/picographics/picographics.c index c896c210..c11dda68 100644 --- a/micropython/modules/picographics/picographics.c +++ b/micropython/modules/picographics/picographics.c @@ -37,7 +37,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(ModPicoGraphics_text_obj, 1, ModPicoGraphics_text); MP_DEFINE_CONST_FUN_OBJ_KW(ModPicoGraphics_measure_text_obj, 1, ModPicoGraphics_measure_text); MP_DEFINE_CONST_FUN_OBJ_KW(ModPicoGraphics_polygon_obj, 2, ModPicoGraphics_polygon); MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(ModPicoGraphics_triangle_obj, 7, 7, ModPicoGraphics_triangle); -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(ModPicoGraphics_line_obj, 5, 5, ModPicoGraphics_line); +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(ModPicoGraphics_line_obj, 5, 6, ModPicoGraphics_line); // Sprites MP_DEFINE_CONST_FUN_OBJ_2(ModPicoGraphics_set_spritesheet_obj, ModPicoGraphics_set_spritesheet); diff --git a/micropython/modules/picographics/picographics.cpp b/micropython/modules/picographics/picographics.cpp index 2b8b017d..0b3ad4fb 100644 --- a/micropython/modules/picographics/picographics.cpp +++ b/micropython/modules/picographics/picographics.cpp @@ -1046,16 +1046,27 @@ mp_obj_t ModPicoGraphics_triangle(size_t n_args, const mp_obj_t *args) { } mp_obj_t ModPicoGraphics_line(size_t n_args, const mp_obj_t *args) { - enum { ARG_self, ARG_x1, ARG_y1, ARG_x2, ARG_y2 }; + enum { ARG_self, ARG_x1, ARG_y1, ARG_x2, ARG_y2, ARG_thickness }; ModPicoGraphics_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self], ModPicoGraphics_obj_t); - self->graphics->line( - {mp_obj_get_int(args[ARG_x1]), - mp_obj_get_int(args[ARG_y1])}, - {mp_obj_get_int(args[ARG_x2]), - mp_obj_get_int(args[ARG_y2])} - ); + if(n_args == 5) { + self->graphics->line( + {mp_obj_get_int(args[ARG_x1]), + mp_obj_get_int(args[ARG_y1])}, + {mp_obj_get_int(args[ARG_x2]), + mp_obj_get_int(args[ARG_y2])} + ); + } + else if(n_args == 6) { + self->graphics->thick_line( + {mp_obj_get_int(args[ARG_x1]), + mp_obj_get_int(args[ARG_y1])}, + {mp_obj_get_int(args[ARG_x2]), + mp_obj_get_int(args[ARG_y2])}, + mp_obj_get_int(args[ARG_thickness]) + ); + } return mp_const_none; }