mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[mpy/kandinsky] Fix draw_string() on new line + good colors (#47)
* [mpy/kandinsky] Use good colors * [kandinsky/context_text] Avoid returning to pos x=0 on new line, use arg's x coordinate instead
This commit is contained in:
committed by
GitHub
parent
9cda9d9e59
commit
0906dc919b
@@ -29,7 +29,7 @@ KDPoint KDContext::pushOrPullString(const char * text, KDPoint p, const KDFont *
|
|||||||
codePointPointer = decoder.stringPosition();
|
codePointPointer = decoder.stringPosition();
|
||||||
if (codePoint == UCodePointLineFeed) {
|
if (codePoint == UCodePointLineFeed) {
|
||||||
assert(position.y() < KDCOORDINATE_MAX - glyphSize.height());
|
assert(position.y() < KDCOORDINATE_MAX - glyphSize.height());
|
||||||
position = KDPoint(0, position.y() + glyphSize.height());
|
position = KDPoint(p.x(), position.y() + glyphSize.height());
|
||||||
codePoint = decoder.nextCodePoint();
|
codePoint = decoder.nextCodePoint();
|
||||||
} else if (codePoint == UCodePointTabulation) {
|
} else if (codePoint == UCodePointTabulation) {
|
||||||
position = position.translatedBy(KDPoint(k_tabCharacterWidth * glyphSize.width(), 0));
|
position = position.translatedBy(KDPoint(k_tabCharacterWidth * glyphSize.width(), 0));
|
||||||
|
|||||||
@@ -57,12 +57,11 @@ mp_obj_t modkandinsky_set_pixel(mp_obj_t x, mp_obj_t y, mp_obj_t input) {
|
|||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO Use good colors
|
|
||||||
mp_obj_t modkandinsky_draw_string(size_t n_args, const mp_obj_t * args) {
|
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]);
|
const char * text = mp_obj_str_get_str(args[0]);
|
||||||
KDPoint point(mp_obj_get_int(args[1]), mp_obj_get_int(args[2]));
|
KDPoint point(mp_obj_get_int(args[1]), mp_obj_get_int(args[2]));
|
||||||
KDColor textColor = (n_args >= 4) ? MicroPython::Color::Parse(args[3]) : KDColorBlack;
|
KDColor textColor = (n_args >= 4) ? MicroPython::Color::Parse(args[3]) : Palette::PrimaryText;
|
||||||
KDColor backgroundColor = (n_args >= 5) ? MicroPython::Color::Parse(args[4]) : KDColorWhite;
|
KDColor backgroundColor = (n_args >= 5) ? MicroPython::Color::Parse(args[4]) : Palette::HomeBackground;
|
||||||
const KDFont * font = (n_args >= 6) ? ((mp_obj_is_true(args[5])) ? KDFont::SmallFont : KDFont::LargeFont) : KDFont::LargeFont;
|
const KDFont * font = (n_args >= 6) ? ((mp_obj_is_true(args[5])) ? KDFont::SmallFont : KDFont::LargeFont) : KDFont::LargeFont;
|
||||||
MicroPython::ExecutionEnvironment::currentExecutionEnvironment()->displaySandbox();
|
MicroPython::ExecutionEnvironment::currentExecutionEnvironment()->displaySandbox();
|
||||||
KDIonContext::sharedContext()->drawString(text, point, font, textColor, backgroundColor);
|
KDIonContext::sharedContext()->drawString(text, point, font, textColor, backgroundColor);
|
||||||
|
|||||||
Reference in New Issue
Block a user