[python] matplotlib port: draft version of arrow method

This commit is contained in:
Émilie Feral
2020-03-18 10:59:18 +01:00
parent bc8dc0c59c
commit 70335b7a47
4 changed files with 14 additions and 1 deletions

View File

@@ -74,6 +74,7 @@ Q(get_pixel)
Q(set_pixel)
// Matplotlib QSTRs
Q(arrow)
Q(axis)
Q(bar)
Q(grid)

View File

@@ -46,6 +46,16 @@ void modpyplot_gc_collect() {
);
}
mp_obj_t modpyplot_arrow(size_t n_args, const mp_obj_t *args) {
assert(n_args == 4);
assert(sPlotStore != nullptr);
KDColor color = Palette::DataColor[paletteIndex++]; // FIXME: Share overflow routine
sPlotStore->addSegment(args[0], args[1], mp_obj_new_float(mp_obj_get_float(args[0])+mp_obj_get_float(args[2])), mp_obj_new_float(mp_obj_get_float(args[1])+mp_obj_get_float(args[3])), color);
return mp_const_none;
}
/* axis(arg)
* - arg = [xmin, xmax, ymin, ymax]
* - arg = True, False

View File

@@ -3,6 +3,7 @@
mp_obj_t modpyplot___init__();
void modpyplot_gc_collect();
mp_obj_t modpyplot_arrow(size_t n_args, const mp_obj_t *args);
mp_obj_t modpyplot_axis(mp_obj_t arg);
mp_obj_t modpyplot_bar(mp_obj_t x, mp_obj_t height);
mp_obj_t modpyplot_grid(mp_obj_t b);
@@ -10,5 +11,4 @@ mp_obj_t modpyplot_hist(mp_obj_t x);
mp_obj_t modpyplot_plot(mp_obj_t x, mp_obj_t y);
mp_obj_t modpyplot_scatter(mp_obj_t x, mp_obj_t y);
mp_obj_t modpyplot_text(mp_obj_t x, mp_obj_t y, mp_obj_t s);
//mp_obj_t arrow();
mp_obj_t modpyplot_show();

View File

@@ -1,6 +1,7 @@
#include "modpyplot.h"
STATIC MP_DEFINE_CONST_FUN_OBJ_0(modpyplot___init___obj, modpyplot___init__);
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modpyplot_arrow_obj, 4, 4, modpyplot_arrow);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(modpyplot_axis_obj, modpyplot_axis);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(modpyplot_bar_obj, modpyplot_bar);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(modpyplot_grid_obj, modpyplot_grid);
@@ -13,6 +14,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(modpyplot_text_obj, modpyplot_text);
STATIC const mp_rom_map_elem_t modpyplot_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_pyplot) },
{ MP_ROM_QSTR(MP_QSTR___init__), MP_ROM_PTR(&modpyplot___init___obj) },
{ MP_ROM_QSTR(MP_QSTR_arrow), MP_ROM_PTR(&modpyplot_arrow_obj) },
{ MP_ROM_QSTR(MP_QSTR_axis), MP_ROM_PTR(&modpyplot_axis_obj) },
{ MP_ROM_QSTR(MP_QSTR_bar), MP_ROM_PTR(&modpyplot_bar_obj) },
{ MP_ROM_QSTR(MP_QSTR_grid), MP_ROM_PTR(&modpyplot_grid_obj) },