Add Quad drawing option

This commit is contained in:
Michal Moskal 2017-07-11 15:52:37 +02:00
parent cb88fd7c2b
commit b60775fa50
4 changed files with 11 additions and 4 deletions

View File

@ -12,6 +12,7 @@
Fill = 0x04, Fill = 0x04,
Transparent = 0x08, Transparent = 0x08,
Double = 0x10, Double = 0x10,
Quad = 0x20,
} }
// Auto-generated. Do not edit. Really. // Auto-generated. Do not edit. Really.

View File

@ -12,6 +12,7 @@ enum class Draw {
Fill = 0x04, Fill = 0x04,
Transparent = 0x08, Transparent = 0x08,
Double = 0x10, Double = 0x10,
Quad = 0x20,
}; };
inline bool operator&(Draw a, Draw b) { inline bool operator&(Draw a, Draw b) {
@ -22,7 +23,6 @@ inline Draw operator|(Draw a, Draw b) {
return (Draw)((int)a | (int)b); return (Draw)((int)a | (int)b);
} }
#define XX(v) ((uint32_t)(v)&0xffff) #define XX(v) ((uint32_t)(v)&0xffff)
#define YY(v) ((uint32_t)(v) >> 16) #define YY(v) ((uint32_t)(v) >> 16)
@ -171,8 +171,14 @@ Buffer doubleIcon(Buffer buf) {
void drawIcon(int x, int y, Buffer buf, Draw mode) { void drawIcon(int x, int y, Buffer buf, Draw mode) {
if (!isValidIcon(buf)) if (!isValidIcon(buf))
return; return;
if (mode & Draw::Double) if (mode & (Draw::Double | Draw::Quad)) {
buf = doubleIcon(buf); buf = doubleIcon(buf);
if (mode & Draw::Quad) {
auto pbuf = buf;
buf = doubleIcon(buf);
decrRC(pbuf);
}
}
int pixwidth = buf->data[1]; int pixwidth = buf->data[1];
int ptr = 2; int ptr = 2;

View File

@ -94,7 +94,7 @@ namespace screen {
let byteWidth = (currFont.charWidth + 7) >> 3 let byteWidth = (currFont.charWidth + 7) >> 3
let charSize = byteWidth * currFont.charHeight let charSize = byteWidth * currFont.charHeight
let iconBuf = output.createBuffer(2 + charSize) let iconBuf = output.createBuffer(2 + charSize)
let double = (mode & Draw.Double) ? 2 : 1 let double = (mode & Draw.Quad) ? 4 : (mode & Draw.Double) ? 2 : 1
iconBuf[0] = 0xf0 iconBuf[0] = 0xf0
iconBuf[1] = currFont.charWidth iconBuf[1] = currFont.charWidth
while (cp < text.length) { while (cp < text.length) {

View File

@ -1,5 +1,5 @@
screen.clear() screen.clear()
screen.drawText(10, 30, "Welcome PXT!", Draw.Double) screen.drawText(10, 30, "PXT!", Draw.Quad)
screen.drawRect(40, 40, 20, 10, Draw.Fill) screen.drawRect(40, 40, 20, 10, Draw.Fill)
output.setLights(LightsPattern.Orange) output.setLights(LightsPattern.Orange)