[python] Add getters for turtle module

This commit is contained in:
Jean-Baptiste Boric
2018-10-30 18:26:13 +01:00
parent fcf7cc33cf
commit c89a369a08
4 changed files with 26 additions and 2 deletions

View File

@@ -161,6 +161,10 @@ mp_obj_t turtle_position() {
return mp_obj_new_tuple(2, mp_pos);
}
mp_obj_t turtle_heading() {
return mp_obj_new_float((t_heading - t_heading_offset) / t_heading_scale);
}
mp_obj_t turtle_pendown() {
t_penup = false;
return mp_const_none;
@@ -189,6 +193,10 @@ mp_obj_t turtle_pensize(size_t n_args, const mp_obj_t *args) {
return mp_const_none;
}
mp_obj_t turtle_isdown() {
return t_penup ? mp_const_false : mp_const_true;
}
mp_obj_t turtle_color(mp_obj_t r, mp_obj_t g, mp_obj_t b) {
t_color = KDColor::RGB888(mp_obj_get_int(r), mp_obj_get_int(g), mp_obj_get_int(b));
return mp_const_none;
@@ -206,6 +214,10 @@ mp_obj_t turtle_hideturtle() {
return mp_const_none;
}
mp_obj_t turtle_isvisible() {
return t_hidden ? mp_const_false : mp_const_true;
}
mp_obj_t turtle___init__() {
if (!t_underneath) {
t_underneath = new KDColor[t_size * t_size];