[python/modkandinsky] fillRect accepts negative width and height

This commit is contained in:
Léa Saviot
2020-02-21 14:29:34 +01:00
committed by EmilieNumworks
parent 0a3ce4cade
commit 8fe41a8673

View File

@@ -85,13 +85,21 @@ 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) {
KDRect rect(
mp_obj_get_int(args[0]),
mp_obj_get_int(args[1]),
mp_obj_get_int(args[2]),
mp_obj_get_int(args[3])
);
mp_int_t x = mp_obj_get_int(args[0]);
mp_int_t y = mp_obj_get_int(args[1]);
mp_int_t width = mp_obj_get_int(args[2]);
mp_int_t height = mp_obj_get_int(args[3]);
if (width < 0) {
width = -width;
x = x - width;
}
if (height < 0) {
height = -height;
y = y - height;
}
KDRect rect(x, y, width, height);
KDColor color = ColorForTuple(args[4]);
MicroPython::ExecutionEnvironment::currentExecutionEnvironment()->displaySandbox();
KDIonContext::sharedContext()->fillRect(rect, color);
// Cf comment on modkandinsky_draw_string