diff --git a/apps/code/catalog.de.i18n b/apps/code/catalog.de.i18n index f1c208068..e1dbdf273 100644 --- a/apps/code/catalog.de.i18n +++ b/apps/code/catalog.de.i18n @@ -45,6 +45,7 @@ PythonCosh = "Hyperbolic cosine" PythonCount = "Zählt wie oft x vorkommt" PythonDegrees = "x von Radian zu Grad umwandeln" PythonDivMod = "Quotient und Rest" +PythonDrawLine = "Draw a line" PythonDrawString = "Schreibt Text bei (x,y)" PythonErf = "Fehlerfunktion" PythonErfc = "Complementary error function" diff --git a/apps/code/catalog.en.i18n b/apps/code/catalog.en.i18n index cd115b9aa..ced53e542 100644 --- a/apps/code/catalog.en.i18n +++ b/apps/code/catalog.en.i18n @@ -45,6 +45,7 @@ PythonCosh = "Hyperbolic cosine" PythonCount = "Count the occurrences of x" PythonDegrees = "Convert x from radians to degrees" PythonDivMod = "Quotient and remainder" +PythonDrawLine = "Draw a line" PythonDrawString = "Display a text from pixel (x,y)" PythonErf = "Error function" PythonErfc = "Complementary error function" diff --git a/apps/code/catalog.es.i18n b/apps/code/catalog.es.i18n index ee8b58f59..45c3a7f29 100644 --- a/apps/code/catalog.es.i18n +++ b/apps/code/catalog.es.i18n @@ -45,6 +45,7 @@ PythonCosh = "Hyperbolic cosine" PythonCount = "Count the occurrences of x" PythonDegrees = "Convert x from radians to degrees" PythonDivMod = "Quotient and remainder" +PythonDrawLine = "Draw a line" PythonDrawString = "Display a text from pixel (x,y)" PythonErf = "Error function" PythonErfc = "Complementary error function" diff --git a/apps/code/catalog.fr.i18n b/apps/code/catalog.fr.i18n index 558c09cdc..f2c686708 100644 --- a/apps/code/catalog.fr.i18n +++ b/apps/code/catalog.fr.i18n @@ -45,6 +45,7 @@ PythonCosh = "Cosinus hyperbolique" PythonCount = "Compte les occurrences de x" PythonDegrees = "Conversion de radians en degrés" PythonDivMod = "Quotient et reste" +PythonDrawLine = "Trace une ligne" PythonDrawString = "Affiche un texte au pixel (x,y)" PythonErf = "Fonction d'erreur" PythonErfc = "Fonction d'erreur complémentaire" diff --git a/apps/code/catalog.hu.i18n b/apps/code/catalog.hu.i18n index 6871a7dcf..4942f6c4f 100644 --- a/apps/code/catalog.hu.i18n +++ b/apps/code/catalog.hu.i18n @@ -45,6 +45,7 @@ PythonCosh = "Hiperbolikus koszinusz" PythonCount = "Számolja az x elöfordulását" PythonDegrees = "x konvertálása radiánokrol fokokra" PythonDivMod = "Hányados és maradék" +PythonDrawLine = "Húzzon egy vonalat " PythonDrawString = "Szöveg megjelenítése (x, y)-en" PythonErf = "Hiba funkció" PythonErfc = "Kiegészítö hiba funkció" diff --git a/apps/code/catalog.it.i18n b/apps/code/catalog.it.i18n index 27a7ea408..796c05851 100644 --- a/apps/code/catalog.it.i18n +++ b/apps/code/catalog.it.i18n @@ -45,6 +45,7 @@ PythonCosh = "Coseno iperbolico" PythonCount = "Conta le ricorrenze di x" PythonDegrees = "Conversione di radianti in gradi" PythonDivMod = "Quoziente e resto" +PythonDrawLine = "Disegna una linea" PythonDrawString = "Visualizza il testo dal pixel x,y" PythonErf = "Funzione d'errore" PythonErfc = "Funzione d'errore complementare" diff --git a/apps/code/catalog.nl.i18n b/apps/code/catalog.nl.i18n index b3ec42257..ab0fe2671 100644 --- a/apps/code/catalog.nl.i18n +++ b/apps/code/catalog.nl.i18n @@ -45,6 +45,7 @@ PythonCosh = "Cosinus hyperbolicus" PythonCount = "Tel voorkomen van x" PythonDegrees = "Zet x om van radialen naar graden" PythonDivMod = "Quotiënt en rest" +PythonDrawLine = "Teken een lijn" PythonDrawString = "Geef een tekst weer van pixel (x,y)" PythonErf = "Error functie" PythonErfc = "Complementaire error functie" diff --git a/apps/code/catalog.pt.i18n b/apps/code/catalog.pt.i18n index de29d19d4..72c9015f4 100644 --- a/apps/code/catalog.pt.i18n +++ b/apps/code/catalog.pt.i18n @@ -45,6 +45,7 @@ PythonCosh = "Cosseno hiperbólico" PythonCount = "Contar as ocorrências de x" PythonDegrees = "Converter x de radianos para graus" PythonDivMod = "Quociente e resto" +PythonDrawLine = "Desenhe uma linha" PythonDrawString = "Mostrar o texto do pixel (x,y)" PythonErf = "Função erro" PythonErfc = "Função erro complementar" diff --git a/apps/code/catalog.universal.i18n b/apps/code/catalog.universal.i18n index 001c58349..39d1ff3b4 100644 --- a/apps/code/catalog.universal.i18n +++ b/apps/code/catalog.universal.i18n @@ -50,6 +50,7 @@ PythonCommandCount = "list.count(x)" PythonCommandCountWithoutArg = ".count(\x11)" PythonCommandDegrees = "degrees(x)" PythonCommandDivMod = "divmod(a,b)" +PythonCommandDrawLine = "draw_line(x1,y1,x2,y2,color)" PythonCommandDrawString = "draw_string(\"text\",x,y)" PythonCommandConstantE = "e" PythonCommandErf = "erf(x)" diff --git a/apps/code/python_toolbox.cpp b/apps/code/python_toolbox.cpp index 2a0ba410d..ae363a1bf 100644 --- a/apps/code/python_toolbox.cpp +++ b/apps/code/python_toolbox.cpp @@ -192,6 +192,7 @@ const ToolboxMessageTree KandinskyModuleChildren[] = { ToolboxMessageTree::Leaf(I18n::Message::PythonCommandSetPixel, I18n::Message::PythonSetPixel), ToolboxMessageTree::Leaf(I18n::Message::PythonCommandColor, I18n::Message::PythonColor), ToolboxMessageTree::Leaf(I18n::Message::PythonCommandDrawString, I18n::Message::PythonDrawString), + ToolboxMessageTree::Leaf(I18n::Message::PythonCommandDrawLine, I18n::Message::PythonDrawLine), ToolboxMessageTree::Leaf(I18n::Message::PythonCommandFillRect, I18n::Message::PythonFillRect) }; @@ -315,6 +316,7 @@ const ToolboxMessageTree catalogChildren[] = { ToolboxMessageTree::Leaf(I18n::Message::PythonCommandCosh, I18n::Message::PythonCosh), ToolboxMessageTree::Leaf(I18n::Message::PythonCommandDegrees, I18n::Message::PythonDegrees), ToolboxMessageTree::Leaf(I18n::Message::PythonCommandDivMod, I18n::Message::PythonDivMod), + ToolboxMessageTree::Leaf(I18n::Message::PythonCommandDrawLine, I18n::Message::PythonDrawLine), ToolboxMessageTree::Leaf(I18n::Message::PythonCommandDrawString, I18n::Message::PythonDrawString), ToolboxMessageTree::Leaf(I18n::Message::PythonCommandConstantE, I18n::Message::PythonConstantE, false), ToolboxMessageTree::Leaf(I18n::Message::PythonCommandErf, I18n::Message::PythonErf), diff --git a/python/port/genhdr/qstrdefs.in.h b/python/port/genhdr/qstrdefs.in.h index 771b3b3a7..c580bcb8e 100644 --- a/python/port/genhdr/qstrdefs.in.h +++ b/python/port/genhdr/qstrdefs.in.h @@ -373,6 +373,7 @@ Q(KEY_EXE) // Kandinsky QSTRs Q(kandinsky) Q(color) +Q(draw_line) Q(draw_string) Q(fill_rect) Q(get_pixel) diff --git a/python/port/mod/kandinsky/modkandinsky.cpp b/python/port/mod/kandinsky/modkandinsky.cpp index c1d9da292..201b48235 100644 --- a/python/port/mod/kandinsky/modkandinsky.cpp +++ b/python/port/mod/kandinsky/modkandinsky.cpp @@ -67,6 +67,19 @@ mp_obj_t modkandinsky_draw_string(size_t n_args, const mp_obj_t * args) { return mp_const_none; } +mp_obj_t modkandinsky_draw_line(size_t n_args, const mp_obj_t * args) { + mp_int_t x1 = mp_obj_get_int(args[0]); + mp_int_t y1 = mp_obj_get_int(args[1]); + mp_int_t x2 = mp_obj_get_int(args[2]); + mp_int_t y2 = mp_obj_get_int(args[3]); + KDPoint p1 = KDPoint(x1, y1); + KDPoint p2 = KDPoint(x2, y2); + KDColor color = MicroPython::Color::Parse(args[4]); + MicroPython::ExecutionEnvironment::currentExecutionEnvironment()->displaySandbox(); + KDIonContext::sharedContext()->drawLine(p1, p2, color); + return mp_const_none; +} + mp_obj_t modkandinsky_fill_rect(size_t n_args, const mp_obj_t * args) { mp_int_t x = mp_obj_get_int(args[0]); mp_int_t y = mp_obj_get_int(args[1]); diff --git a/python/port/mod/kandinsky/modkandinsky.h b/python/port/mod/kandinsky/modkandinsky.h index 12fd2cbc1..acb47d6f8 100644 --- a/python/port/mod/kandinsky/modkandinsky.h +++ b/python/port/mod/kandinsky/modkandinsky.h @@ -4,6 +4,7 @@ mp_obj_t modkandinsky_color(size_t n_args, const mp_obj_t *args); mp_obj_t modkandinsky_get_pixel(mp_obj_t x, mp_obj_t y); mp_obj_t modkandinsky_set_pixel(mp_obj_t x, mp_obj_t y, mp_obj_t color); mp_obj_t modkandinsky_draw_string(size_t n_args, const mp_obj_t *args); +mp_obj_t modkandinsky_draw_line(size_t n_args, const mp_obj_t *args); mp_obj_t modkandinsky_fill_rect(size_t n_args, const mp_obj_t *args); mp_obj_t modkandinsky_wait_vblank(); mp_obj_t modkandinsky_get_keys(); diff --git a/python/port/mod/kandinsky/modkandinsky_table.c b/python/port/mod/kandinsky/modkandinsky_table.c index e3f4404f4..5bbb2e640 100644 --- a/python/port/mod/kandinsky/modkandinsky_table.c +++ b/python/port/mod/kandinsky/modkandinsky_table.c @@ -4,6 +4,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modkandinsky_color_obj, 1, 3, modkand STATIC MP_DEFINE_CONST_FUN_OBJ_2(modkandinsky_get_pixel_obj, modkandinsky_get_pixel); STATIC MP_DEFINE_CONST_FUN_OBJ_3(modkandinsky_set_pixel_obj, modkandinsky_set_pixel); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modkandinsky_draw_string_obj, 3, 6, modkandinsky_draw_string); +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modkandinsky_draw_line_obj, 5, 5, modkandinsky_draw_line); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modkandinsky_fill_rect_obj, 5, 5, modkandinsky_fill_rect); STATIC MP_DEFINE_CONST_FUN_OBJ_0(modkandinsky_wait_vblank_obj, modkandinsky_wait_vblank); STATIC MP_DEFINE_CONST_FUN_OBJ_0(modkandinsky_get_keys_obj, modkandinsky_get_keys); @@ -14,6 +15,7 @@ STATIC const mp_rom_map_elem_t modkandinsky_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_get_pixel), (mp_obj_t)&modkandinsky_get_pixel_obj }, { MP_ROM_QSTR(MP_QSTR_set_pixel), (mp_obj_t)&modkandinsky_set_pixel_obj }, { MP_ROM_QSTR(MP_QSTR_draw_string), (mp_obj_t)&modkandinsky_draw_string_obj }, + { MP_ROM_QSTR(MP_QSTR_draw_line), (mp_obj_t)&modkandinsky_draw_line_obj }, { MP_ROM_QSTR(MP_QSTR_fill_rect), (mp_obj_t)&modkandinsky_fill_rect_obj }, { MP_ROM_QSTR(MP_QSTR_large_font), mp_const_true }, { MP_ROM_QSTR(MP_QSTR_small_font), mp_const_false },