mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[python/kandinsky] draw_string takes two optional colors (text/bg)
This commit is contained in:
committed by
EmilieNumworks
parent
ec50e75a3a
commit
42f72eee77
@@ -63,11 +63,13 @@ mp_obj_t modkandinsky_set_pixel(mp_obj_t x, mp_obj_t y, mp_obj_t color) {
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
mp_obj_t modkandinsky_draw_string(mp_obj_t text, mp_obj_t x, mp_obj_t y) {
|
||||
const char * kdText = mp_obj_str_get_str(text);
|
||||
KDPoint point(mp_obj_get_int(x), mp_obj_get_int(y));
|
||||
mp_obj_t modkandinsky_draw_string(size_t n_args, const mp_obj_t * args) {
|
||||
const char * text = mp_obj_str_get_str(args[0]);
|
||||
KDPoint point(mp_obj_get_int(args[1]), mp_obj_get_int(args[2]));
|
||||
KDColor textColor = (n_args >= 4) ? ColorForTuple(args[3]) : KDColorBlack;
|
||||
KDColor backgroundColor = (n_args >= 5) ? ColorForTuple(args[4]) : KDColorWhite;
|
||||
MicroPython::ExecutionEnvironment::currentExecutionEnvironment()->displaySandbox();
|
||||
KDIonContext::sharedContext()->drawString(kdText, point);
|
||||
KDIonContext::sharedContext()->drawString(text, point, KDFont::LargeFont, textColor, backgroundColor);
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
mp_obj_t modkandinsky_color(mp_obj_t red, mp_obj_t green, mp_obj_t blue);
|
||||
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(mp_obj_t text, mp_obj_t x, mp_obj_t y);
|
||||
mp_obj_t modkandinsky_draw_string(size_t n_args, const mp_obj_t *args);
|
||||
mp_obj_t modkandinsky_fill_rect(size_t n_args, const mp_obj_t *args);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_3(modkandinsky_color_obj, modkandinsky_color);
|
||||
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_3(modkandinsky_draw_string_obj, modkandinsky_draw_string);
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modkandinsky_draw_string_obj, 3, 5, modkandinsky_draw_string);
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modkandinsky_fill_rect_obj, 5, 5, modkandinsky_fill_rect);
|
||||
|
||||
STATIC const mp_rom_map_elem_t modkandinsky_module_globals_table[] = {
|
||||
|
||||
Reference in New Issue
Block a user