From e834c4110af138f8fd4c485999a8294883dbcb0e Mon Sep 17 00:00:00 2001 From: pixel Date: Mon, 31 Mar 2003 16:08:24 +0000 Subject: Working (slowly) on shapes... --- lib/shape.cc | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) (limited to 'lib/shape.cc') 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; -- cgit v1.2.3