summaryrefslogtreecommitdiff
path: root/lib/shape.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/shape.cc')
-rw-r--r--lib/shape.cc154
1 files changed, 77 insertions, 77 deletions
diff --git a/lib/shape.cc b/lib/shape.cc
index 63b0920..d817895 100644
--- a/lib/shape.cc
+++ b/lib/shape.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: shape.cc,v 1.21 2006-02-02 17:29:05 pixel Exp $ */
+/* $Id: shape.cc,v 1.22 2006-10-28 16:50:46 pixel Exp $ */
#include <math.h>
#include <limits.h>
@@ -26,9 +26,9 @@
#include <generic.h>
#include "engine.h"
#include "base.h"
-#include "shape.h"
-#include "texture.h"
-#include "font.h"
+#include "Shape.h"
+#include "Texture.h"
+#include "Font.h"
#define ENTER bool flag = Enter()
#define LEAVE Leave(flag)
@@ -51,10 +51,10 @@ mogltk::segwalker::~segwalker() {
void mogltk::segwalker::step(int x1, int y1, int x2, int y2) {
}
-mogltk::fill::fill() : minX(INT_MAX), minY(INT_MAX), maxX(INT_MIN), maxY(INT_MIN), cached(0), scached(0), header(0) {
+mogltk::Fill::Fill() : minX(INT_MAX), minY(INT_MAX), maxX(INT_MIN), maxY(INT_MIN), cached(0), scached(0), header(0) {
}
-mogltk::fill::~fill() {
+mogltk::Fill::~Fill() {
if (header)
delete header;
@@ -65,12 +65,12 @@ mogltk::fill::~fill() {
delete scached;
}
-void mogltk::fill::walk(fillwalker * w) {
+void mogltk::Fill::walk(fillwalker * w) {
if (header)
header->walk(w);
}
-void mogltk::fill::swalk(segwalker * s) {
+void mogltk::Fill::swalk(segwalker * s) {
std::vector<struct segment>::iterator i;
for (i = segments.begin(); i != segments.end(); i++) {
@@ -78,7 +78,7 @@ void mogltk::fill::swalk(segwalker * s) {
}
}
-void mogltk::fill::insert(int x, int y) {
+void mogltk::Fill::insert(int x, int y) {
if (cached) {
delete cached;
cached = 0;
@@ -107,7 +107,7 @@ void mogltk::fill::insert(int x, int y) {
minY = y;
}
-void mogltk::fill::insert(int x1, int y1, int x2, int y2) {
+void mogltk::Fill::insert(int x1, int y1, int x2, int y2) {
int dx, dy, y;
double x, i, i2;
@@ -136,38 +136,38 @@ void mogltk::fill::insert(int x1, int y1, int x2, int y2) {
insert(x + i2, y);
}
-void mogltk::fill::insertfix(int x, int y) {
+void mogltk::Fill::insertfix(int x, int y) {
if (!header)
return;
header->insertfix(x, y);
}
-int mogltk::fill::GetMaxX() const {
+int mogltk::Fill::GetMaxX() const {
return maxX;
}
-int mogltk::fill::GetMaxY() const {
+int mogltk::Fill::GetMaxY() const {
return maxY;
}
-int mogltk::fill::GetMinX() const {
+int mogltk::Fill::GetMinX() const {
return minX;
}
-int mogltk::fill::GetMinY() const {
+int mogltk::Fill::GetMinY() const {
return minY;
}
-mogltk::texture * mogltk::fill::GetTexture() {
+mogltk::Texture * mogltk::Fill::GetTexture() {
return cached;
}
-mogltk::texture * mogltk::fill::GetSTexture() {
+mogltk::Texture * mogltk::Fill::GetSTexture() {
return scached;
}
-mogltk::texture * mogltk::fill::Talloc() {
+mogltk::Texture * mogltk::Fill::Talloc() {
if (cached)
return cached;
@@ -176,12 +176,12 @@ mogltk::texture * mogltk::fill::Talloc() {
for (x = 1; x <= (maxX - minX); x <<= 1);
for (y = 1; y <= (maxY - minY); y <<= 1);
- cached = new texture(x, y, true);
- cached->name = "Fill-texture - cached";
+ cached = new Texture(x, y, true);
+ cached->name = "Fill-Texture - cached";
return cached;
}
-mogltk::texture * mogltk::fill::STalloc() {
+mogltk::Texture * mogltk::Fill::STalloc() {
if (scached)
return scached;
@@ -190,12 +190,12 @@ mogltk::texture * mogltk::fill::STalloc() {
for (x = 1; x <= (maxX - minX); x <<= 1);
for (y = 1; y <= (maxY - minY); y <<= 1);
- scached = new texture(x, y, true);
- cached->name = "Fill-texture - scached";
+ scached = new Texture(x, y, true);
+ cached->name = "Fill-Texture - scached";
return scached;
}
-mogltk::fill::sline::sline(int _y, fill * _header) : y(_y), header(_header), pheader(0) {
+mogltk::Fill::sline::sline(int _y, Fill * _header) : y(_y), header(_header), pheader(0) {
if (!header->header) {
header->header = this;
} else {
@@ -217,18 +217,18 @@ mogltk::fill::sline::sline(int _y, fill * _header) : y(_y), header(_header), phe
}
}
-mogltk::fill::sline::~sline() {
+mogltk::Fill::sline::~sline() {
if (pheader)
delete pheader;
if (next)
delete next;
}
-int mogltk::fill::sline::GetY() const {
+int mogltk::Fill::sline::GetY() const {
return y;
}
-void mogltk::fill::sline::insert(int ax, int ay) {
+void mogltk::Fill::sline::insert(int ax, int ay) {
sline * f;
if (ay == y) {
@@ -247,7 +247,7 @@ void mogltk::fill::sline::insert(int ax, int ay) {
}
}
-void mogltk::fill::sline::insertfix(int ax, int ay) {
+void mogltk::Fill::sline::insertfix(int ax, int ay) {
sline * f;
if (ay == y) {
@@ -263,7 +263,7 @@ void mogltk::fill::sline::insertfix(int ax, int ay) {
}
}
-int mogltk::fill::sline::count() const {
+int mogltk::Fill::sline::count() const {
int r = 0;
if (next)
@@ -272,14 +272,14 @@ int mogltk::fill::sline::count() const {
return r + 1;
}
-void mogltk::fill::sline::walk(fillwalker * w) {
+void mogltk::Fill::sline::walk(fillwalker * w) {
if (pheader)
pheader->walk(w);
if (next)
next->walk(w);
}
-mogltk::fill::sline::point::point(int _x, sline * _header) : x(_x), header(_header) {
+mogltk::Fill::sline::point::point(int _x, sline * _header) : x(_x), header(_header) {
if (!header->pheader) {
header->pheader = this;
} else {
@@ -301,26 +301,26 @@ mogltk::fill::sline::point::point(int _x, sline * _header) : x(_x), header(_head
}
}
-mogltk::fill::sline::point::~point() {
+mogltk::Fill::sline::point::~point() {
if (next)
delete next;
}
-int mogltk::fill::sline::point::GetX() const {
+int mogltk::Fill::sline::point::GetX() const {
return x;
}
-int mogltk::fill::sline::point::GetY() const {
+int mogltk::Fill::sline::point::GetY() const {
return header->GetY();
}
-void mogltk::fill::sline::point::walk(fillwalker * w) {
+void mogltk::Fill::sline::point::walk(fillwalker * w) {
w->step(GetX(), GetY());
if (next)
next->walk(w);
}
-mogltk::fill::sline::point * mogltk::fill::sline::point::look(int _x) {
+mogltk::Fill::sline::point * mogltk::Fill::sline::point::look(int _x) {
if (x > _x)
return 0;
@@ -333,7 +333,7 @@ mogltk::fill::sline::point * mogltk::fill::sline::point::look(int _x) {
return next->look(_x);
}
-mogltk::fill::sline * mogltk::fill::sline::look(int _y) {
+mogltk::Fill::sline * mogltk::Fill::sline::look(int _y) {
if (y > _y)
return 0;
@@ -346,16 +346,16 @@ mogltk::fill::sline * mogltk::fill::sline::look(int _y) {
return next->look(_y);
}
-mogltk::shape::shape(SDL_Surface * _surf) : surf(_surf) {
+mogltk::Shape::Shape(SDL_Surface * _surf) : surf(_surf) {
if (!surf)
surf = mogltk::engine::base_o->getsurface();
}
-SDL_Surface * mogltk::shape::GetSurf() {
+SDL_Surface * mogltk::Shape::GetSurf() {
return surf;
}
-void mogltk::shape::box(int x1, int y1, int x2, int y2, ColorP c) {
+void mogltk::Shape::box(int x1, int y1, int x2, int y2, ColorP c) {
ENTER;
SDL_Rect rect;
@@ -366,13 +366,13 @@ void mogltk::shape::box(int x1, int y1, int x2, int y2, ColorP c) {
LEAVE;
}
-void mogltk::shape::hline(int x1, int x2, int y, ColorP c) {
+void mogltk::Shape::hline(int x1, int x2, int y, ColorP c) {
for (; x1 <= x2; x1++) {
pixel(x1, y, c);
}
}
-void mogltk::shape::hline3d(int x1, int x2, int y, ColorP shade1, ColorP shade2, bool bevel) {
+void mogltk::Shape::hline3d(int x1, int x2, int y, ColorP shade1, ColorP shade2, bool bevel) {
ENTER;
if (!bevel) {
@@ -386,13 +386,13 @@ void mogltk::shape::hline3d(int x1, int x2, int y, ColorP shade1, ColorP shade2,
LEAVE;
}
-void mogltk::shape::vline(int x, int y1, int y2, ColorP c) {
+void mogltk::Shape::vline(int x, int y1, int y2, ColorP c) {
for (; y1 <= y2; y1++) {
pixel(x, y1, c);
}
}
-void mogltk::shape::vline3d(int x, int y1, int y2, ColorP shade1, ColorP shade2, bool bevel) {
+void mogltk::Shape::vline3d(int x, int y1, int y2, ColorP shade1, ColorP shade2, bool bevel) {
ENTER;
if (!bevel) {
@@ -406,7 +406,7 @@ void mogltk::shape::vline3d(int x, int y1, int y2, ColorP shade1, ColorP shade2,
LEAVE;
}
-void mogltk::shape::bsubline_1(int x1, int y1, int x2, int y2, ColorP c) {
+void mogltk::Shape::bsubline_1(int x1, int y1, int x2, int y2, ColorP c) {
int x, y, ddx, ddy, e;
ddx = abs(x2 - x1);
ddy = abs(y2 - y1) << 1;
@@ -433,7 +433,7 @@ void mogltk::shape::bsubline_1(int x1, int y1, int x2, int y2, ColorP c) {
LEAVE;
}
-void mogltk::shape::bsubline_2(int x1, int y1, int x2, int y2, ColorP c) {
+void mogltk::Shape::bsubline_2(int x1, int y1, int x2, int y2, ColorP c) {
int x, y, ddx, ddy, e;
ddx = abs(x2 - x1) << 1;
ddy = abs(y2 - y1);
@@ -460,7 +460,7 @@ void mogltk::shape::bsubline_2(int x1, int y1, int x2, int y2, ColorP c) {
LEAVE;
}
-void mogltk::shape::bsubline_3(int x1, int y1, int x2, int y2, ColorP c) {
+void mogltk::Shape::bsubline_3(int x1, int y1, int x2, int y2, ColorP c) {
int x, y, ddx, ddy, e;
ddx = abs(x1 - x2) << 1;
ddy = abs(y2 - y1);
@@ -487,7 +487,7 @@ void mogltk::shape::bsubline_3(int x1, int y1, int x2, int y2, ColorP c) {
LEAVE;
}
-void mogltk::shape::bsubline_4(int x1, int y1, int x2, int y2, ColorP c) {
+void mogltk::Shape::bsubline_4(int x1, int y1, int x2, int y2, ColorP c) {
int x, y, ddx, ddy, e;
ddy = abs(y2 - y1) << 1;
ddx = abs(x1 - x2);
@@ -510,7 +510,7 @@ void mogltk::shape::bsubline_4(int x1, int y1, int x2, int y2, ColorP c) {
}
}
-void mogltk::shape::line(int x1, int y1, int x2, int y2, ColorP c) {
+void mogltk::Shape::line(int x1, int y1, int x2, int y2, ColorP c) {
if ((x1 == x2) && (y1 == y2)) {
printm(M_INFO, "Line is a pixel...\n");
pixel(x1, y1, c);
@@ -540,7 +540,7 @@ void mogltk::shape::line(int x1, int y1, int x2, int y2, ColorP c) {
}
}
-void mogltk::shape::pixel(int x, int y, ColorP c) {
+void mogltk::Shape::pixel(int x, int y, ColorP c) {
ENTER;
int bpp = surf->format->BytesPerPixel;
@@ -581,7 +581,7 @@ void mogltk::shape::pixel(int x, int y, ColorP c) {
LEAVE;
}
-void mogltk::shape::circle(int x0, int y0, int r, ColorP c) {
+void mogltk::Shape::circle(int x0, int y0, int r, ColorP c) {
ENTER;
int x = 0;
@@ -614,13 +614,13 @@ void mogltk::shape::circle(int x0, int y0, int r, ColorP c) {
LEAVE;
}
-mogltk::fill * mogltk::shape::fcircle(int x0, int y0, int r) {
+mogltk::Fill * mogltk::Shape::fcircle(int x0, int y0, int r) {
int x = 0;
int y = r - 1;
int d = 3 - 2 * r;
int dI = 10 - 4 * r;
int rI = 6;
- mogltk::fill * f = new fill();
+ mogltk::Fill * f = new Fill();
bool t = false;
int ox = 0, oy = 0;
@@ -664,13 +664,13 @@ mogltk::fill * mogltk::shape::fcircle(int x0, int y0, int r) {
return f;
}
-void mogltk::shape::pcircle(int x, int y, int r, ColorP c) {
- fill * f = fcircle(x, y, r);
+void mogltk::Shape::pcircle(int x, int y, int r, ColorP c) {
+ Fill * f = fcircle(x, y, r);
fdraw(f, c);
delete f;
}
-mogltk::filldrawer::filldrawer(fill * _f, texture * _t, ColorP _c) : f(_f), t(_t), c(_c), oldx(-1), oldy(-1) {
+mogltk::filldrawer::filldrawer(Fill * _f, Texture * _t, ColorP _c) : f(_f), t(_t), c(_c), oldx(-1), oldy(-1) {
}
mogltk::filldrawer::~filldrawer() {
@@ -706,7 +706,7 @@ void mogltk::filldrawer::step(int x, int y) {
oldy = y;
}
-void mogltk::shape::fdraw(fill * f, ColorP c, int sx, int sy) {
+void mogltk::Shape::fdraw(Fill * f, ColorP c, int sx, int sy) {
ENTER;
if (!f)
return;
@@ -734,7 +734,7 @@ void mogltk::shape::fdraw(fill * f, ColorP c, int sx, int sy) {
LEAVE;
}
-mogltk::segdrawer::segdrawer(fill * _f, texture * _t, ColorP _c) : f(_f), t(_t), c(_c), sh(new shape(_t->GetSurface())) {
+mogltk::segdrawer::segdrawer(Fill * _f, Texture * _t, ColorP _c) : f(_f), t(_t), c(_c), sh(new Shape(_t->GetSurface())) {
}
mogltk::segdrawer::~segdrawer() {
@@ -745,7 +745,7 @@ void mogltk::segdrawer::step(int x1, int y1, int x2, int y2) {
sh->line(x1 - f->GetMinX(), y1 - f->GetMinY(), x2 - f->GetMinX(), y2 - f->GetMinY(), c);
}
-void mogltk::shape::sdraw(fill * f, ColorP c, int sx, int sy) {
+void mogltk::Shape::sdraw(Fill * f, ColorP c, int sx, int sy) {
ENTER;
if (!f)
@@ -775,7 +775,7 @@ void mogltk::shape::sdraw(fill * f, ColorP c, int sx, int sy) {
LEAVE;
}
-void mogltk::shape::obox(int x1, int y1, int x2, int y2, ColorP c) {
+void mogltk::Shape::obox(int x1, int y1, int x2, int y2, ColorP c) {
ENTER;
hline(x1, x2, y1, c);
@@ -786,7 +786,7 @@ void mogltk::shape::obox(int x1, int y1, int x2, int y2, ColorP c) {
LEAVE;
}
-void mogltk::shape::box3d(int x1, int y1, int x2, int y2, ColorP face, ColorP shade1, ColorP shade2, int depth, bool bevel) {
+void mogltk::Shape::box3d(int x1, int y1, int x2, int y2, ColorP face, ColorP shade1, ColorP shade2, int depth, bool bevel) {
ENTER;
int i;
@@ -806,7 +806,7 @@ void mogltk::shape::box3d(int x1, int y1, int x2, int y2, ColorP face, ColorP sh
LEAVE;
}
-void mogltk::shape::obox3d(int x1, int y1, int x2, int y2, ColorP shade1, ColorP shade2, bool bevel) {
+void mogltk::Shape::obox3d(int x1, int y1, int x2, int y2, ColorP shade1, ColorP shade2, bool bevel) {
ENTER;
if (!bevel) {
@@ -820,7 +820,7 @@ void mogltk::shape::obox3d(int x1, int y1, int x2, int y2, ColorP shade1, ColorP
LEAVE;
}
-void mogltk::shape::window(int x1, int y1, int x2, int y2, const String & title,
+void mogltk::Shape::window(int x1, int y1, int x2, int y2, const String & title,
ColorP titlecolor, ColorP titlebackcolor,
ColorP front, ColorP shade1, ColorP shade2) {
ENTER;
@@ -833,7 +833,7 @@ void mogltk::shape::window(int x1, int y1, int x2, int y2, const String & title,
LEAVE;
}
-void mogltk::shape::text(int x, int y, const String & text, ColorP textcolor, align_t align, mogltk::font * _font) {
+void mogltk::Shape::text(int x, int y, const String & text, ColorP textcolor, align_t align, mogltk::Font * _font) {
int tsize = _font->singletextsize(text);
switch (align) {
case LEFT:
@@ -851,9 +851,9 @@ void mogltk::shape::text(int x, int y, const String & text, ColorP textcolor, al
_font->printf("%s", text.to_charp());
}
-void mogltk::shape::text3d(int x, int y, const String & atext, ColorP textcolor,
+void mogltk::Shape::text3d(int x, int y, const String & atext, ColorP textcolor,
ColorP shade1, ColorP shade2,
- align_t align, bool bevel, mogltk::font * _font) {
+ align_t align, bool bevel, mogltk::Font * _font) {
ENTER;
_font->setwspace(1);
@@ -870,7 +870,7 @@ void mogltk::shape::text3d(int x, int y, const String & atext, ColorP textcolor,
LEAVE;
}
-void mogltk::shape::button(int x1, int y1, int x2, int y2,
+void mogltk::Shape::button(int x1, int y1, int x2, int y2,
const String & atext, bool bevel,
ColorP front, ColorP shade1, ColorP shade2,
ColorP round, ColorP textcolor,
@@ -891,7 +891,7 @@ void mogltk::shape::button(int x1, int y1, int x2, int y2,
LEAVE;
}
-bool mogltk::shape::Enter() {
+bool mogltk::Shape::Enter() {
if (SDL_MUSTLOCK(surf)) {
SDL_LockSurface(surf);
return true;
@@ -900,31 +900,31 @@ bool mogltk::shape::Enter() {
}
}
-void mogltk::shape::Leave(bool locked) {
+void mogltk::Shape::Leave(bool locked) {
if (locked)
SDL_UnlockSurface(surf);
}
-void mogltk::shape::tbox(texture *, int x1, int y1, int x2, int y2, int tx, int ty, double f, ColorP c) {
+void mogltk::Shape::tbox(Texture *, int x1, int y1, int x2, int y2, int tx, int ty, double f, ColorP c) {
}
-void mogltk::shape::tbox(texture *, int x1, int y1, int x2, int y2, int tx1, int ty1, int tx2, int ty2, ColorP c) {
+void mogltk::Shape::tbox(Texture *, int x1, int y1, int x2, int y2, int tx1, int ty1, int tx2, int ty2, ColorP c) {
}
-void mogltk::shape::tbox(texture *, int x1, int y1, int x2, int y2, ColorP, ColorP, ColorP, ColorP, int tx, int ty, double f) {
+void mogltk::Shape::tbox(Texture *, int x1, int y1, int x2, int y2, ColorP, ColorP, ColorP, ColorP, int tx, int ty, double f) {
}
-void mogltk::shape::tbox(texture *, int x1, int y1, int x2, int y2, ColorP, ColorP, ColorP, ColorP, int tx1, int ty1, int tx2, int ty2) {
+void mogltk::Shape::tbox(Texture *, int x1, int y1, int x2, int y2, ColorP, ColorP, ColorP, ColorP, int tx1, int ty1, int tx2, int ty2) {
}
-void mogltk::shape::vline(int x, int y1, int y2, ColorP c1, ColorP c2) {
+void mogltk::Shape::vline(int x, int y1, int y2, ColorP c1, ColorP c2) {
}
-void mogltk::shape::hline(int x1, int x2, int y, ColorP c1, ColorP c2) {
+void mogltk::Shape::hline(int x1, int x2, int y, ColorP c1, ColorP c2) {
}
-void mogltk::shape::box(int x1, int y1, int x2, int y2, ColorP c1, ColorP c2, ColorP c3, ColorP c4) {
+void mogltk::Shape::box(int x1, int y1, int x2, int y2, ColorP c1, ColorP c2, ColorP c3, ColorP c4) {
}
-void mogltk::shape::obox(int x1, int y1, int x2, int y2, ColorP c1, ColorP c2, ColorP c3, ColorP c4) {
+void mogltk::Shape::obox(int x1, int y1, int x2, int y2, ColorP c1, ColorP c2, ColorP c3, ColorP c4) {
}