summaryrefslogtreecommitdiff
path: root/lib/shape.cc
diff options
context:
space:
mode:
authorpixel <pixel>2003-03-31 16:08:24 +0000
committerpixel <pixel>2003-03-31 16:08:24 +0000
commite834c4110af138f8fd4c485999a8294883dbcb0e (patch)
treeb2e35d038cefc27534b230a1dcaba55123dbfd12 /lib/shape.cc
parent823ad8ed4bd951265fc52d68f6879e83417ded92 (diff)
Working (slowly) on shapes...
Diffstat (limited to 'lib/shape.cc')
-rw-r--r--lib/shape.cc79
1 files changed, 79 insertions, 0 deletions
diff --git a/lib/shape.cc b/lib/shape.cc
index 972600c..b9bdd87 100644
--- a/lib/shape.cc
+++ b/lib/shape.cc
@@ -9,6 +9,85 @@
#define ENTER bool flag = Enter()
#define LEAVE Leave(flag)
+mogltk::fillwalker::fillwalker() {
+}
+
+mogltk::fillwalker::~fillwalker() {
+}
+
+mogltk::fill::fill() : header(0) {
+}
+
+mogltk::fill::~fill() {
+ if (header)
+ delete header;
+}
+
+void mogltk::fill::walk(fillwalker * w) {
+ header->walk(w);
+}
+
+void mogltk::fill::insert(int x, int y) {
+ if (!header)
+ new sline(y, this);
+ header->insert(x, y);
+}
+
+mogltk::fill::sline::sline(int _y, fill * _header) : y(_y), pheader(0), header(_header) {
+ if (!header->header) {
+ header->header = this;
+ } else {
+ if (header->header->y > y) {
+ next = header->header;
+ header->header = this;
+ } else {
+ sline * p;
+ for (p = header->header; p->next; p = p->next) {
+ if (p->next->y > y) {
+ next = p->next;
+ p->next = this;
+ return;
+ }
+ }
+ p->next = this;
+ next = 0;
+ }
+ }
+}
+
+mogltk::fill::sline::~sline() {
+ if (header)
+ delete header;
+ if (next)
+ delete next;
+}
+
+int mogltk::fill::sline::GetY() {
+ return y;
+}
+
+void mogltk::fill::sline::insert(int ax, int ay) {
+ sline * f;
+
+ if (ay == y) {
+ if (!pheader)
+ new point(ax, this);
+ else if (!pheader->look(ax))
+ new point(ax, this);
+ } else {
+ f = look(y);
+
+ if (!f)
+ f = new sline(y, header);
+
+ f->insert(ax, ay);
+ }
+}
+
+void mogltk::fill::sline::walk(fillwalker * w) {
+ w->step(GetX(), GetY());
+}
+
void mogltk::shape::box(int x1, int y1, int x2, int y2, ColorP c) {
ENTER;