mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-28 18:20:14 +01:00
[code/python] Fixed the Kandinsky module in Python.
User can draw on the 320*220 drawing screen. Change-Id: I25034b05f21aacc35608358fdb7a4d9924dd22e8
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
extern "C" {
|
||||
#include "modkandinsky.h"
|
||||
}
|
||||
#include <escher/metric.h>
|
||||
#include <kandinsky.h>
|
||||
#include "port.h"
|
||||
|
||||
mp_obj_t kandinsky_color(mp_obj_t red, mp_obj_t green, mp_obj_t blue) {
|
||||
return
|
||||
@@ -16,22 +18,25 @@ mp_obj_t kandinsky_color(mp_obj_t red, mp_obj_t green, mp_obj_t blue) {
|
||||
|
||||
mp_obj_t kandinsky_get_pixel(mp_obj_t x, mp_obj_t y) {
|
||||
KDColor c = KDIonContext::sharedContext()->getPixel(
|
||||
KDPoint(mp_obj_get_int(x), mp_obj_get_int(y))
|
||||
KDPoint(mp_obj_get_int(x), mp_obj_get_int(y) + Metric::TitleBarHeight)
|
||||
);
|
||||
return MP_OBJ_NEW_SMALL_INT(c);
|
||||
}
|
||||
mp_obj_t kandinsky_set_pixel(mp_obj_t x, mp_obj_t y, mp_obj_t color) {
|
||||
KDIonContext::sharedContext()->setPixel(
|
||||
KDPoint(mp_obj_get_int(x), mp_obj_get_int(y)),
|
||||
KDPoint(mp_obj_get_int(x), mp_obj_get_int(y) + Metric::TitleBarHeight),
|
||||
KDColor::RGB16(mp_obj_get_int(color))
|
||||
);
|
||||
MicroPython::ExecutionEnvironment::currentExecutionEnvironment()->didModifyFramebuffer();
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
mp_obj_t kandinsky_draw_string(mp_obj_t text, mp_obj_t x, mp_obj_t y) {
|
||||
KDIonContext::sharedContext()->drawString(
|
||||
mp_obj_str_get_str(text),
|
||||
KDPoint(mp_obj_get_int(x), mp_obj_get_int(y))
|
||||
KDPoint(mp_obj_get_int(x), mp_obj_get_int(y) + Metric::TitleBarHeight)
|
||||
);
|
||||
MicroPython::ExecutionEnvironment::currentExecutionEnvironment()->didModifyFramebuffer();
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user