summaryrefslogtreecommitdiff
path: root/plugingui
diff options
context:
space:
mode:
Diffstat (limited to 'plugingui')
-rw-r--r--plugingui/painter.cc13
-rw-r--r--plugingui/painter.h2
-rw-r--r--plugingui/pixelbuffer.cc6
3 files changed, 17 insertions, 4 deletions
diff --git a/plugingui/painter.cc b/plugingui/painter.cc
index b74952f..e5da246 100644
--- a/plugingui/painter.cc
+++ b/plugingui/painter.cc
@@ -191,9 +191,16 @@ void GUI::Painter::drawRectangle(int x1, int y1, int x2, int y2)
void GUI::Painter::drawFilledRectangle(int x1, int y1, int x2, int y2)
{
- for(int x = x1; x < x2; x++) {
- for(int y = y1; y < y2; y++) {
- drawPoint(x, y);
+ for(int y = y1; y < y2; y++) {
+ drawLine(x1, y, x2, y);
+ }
+}
+
+void GUI::Painter::clear()
+{
+ for(int x = 0; x < pixbuf->width; x++) {
+ for(int y = 0; y < pixbuf->height; y++) {
+ pixbuf->setPixel(x, y, 0, 0, 0, 0);
}
}
}
diff --git a/plugingui/painter.h b/plugingui/painter.h
index b45cf3a..f236369 100644
--- a/plugingui/painter.h
+++ b/plugingui/painter.h
@@ -68,6 +68,8 @@ public:
void drawFilledCircle(int x, int y, int r);
void drawImage(int x, int y, struct __img__ * img);
+ void clear();
+
private:
void plot(int x, int y, double c);
double ipart(double x);
diff --git a/plugingui/pixelbuffer.cc b/plugingui/pixelbuffer.cc
index e9e376a..c0dc2cc 100644
--- a/plugingui/pixelbuffer.cc
+++ b/plugingui/pixelbuffer.cc
@@ -114,7 +114,11 @@ void GUI::PixelBufferAlpha::addPixel(size_t x, size_t y,
buf[PX(2)] = (unsigned char)(blue * a + buf[PX(2)] * (1-a));
//buf[PX(3)] = (unsigned char)(alpha * a + buf[PX(3)] * (1-a));
- buf[PX(3)] = alpha>buf[PX(3)]?alpha:buf[PX(3)];
+ //buf[PX(3)] = alpha>buf[PX(3)]?alpha:buf[PX(3)];
+
+ float a1 = (float)buf[PX(3)] / 255.0;
+ float a2 = (float)alpha / 255.0;
+ buf[PX(3)] = (a1 + ((1 - a1) * a2)) * 255.0;
}
void GUI::PixelBufferAlpha::pixel(size_t x, size_t y,