// C++ code Copyright (C) David R. Evans G4AMJ/NQ0I // surface class #include #include #include #include const char* PORTRAIT = "PORTRAIT", * LANDSCAPE = "LANDSCAPE"; surface::surface(void) { im_top = im_left = 0; font = "ROMAN"; font_height = 12; _dump_to_printer = &surface::_dump_to_none; } surface& surface::operator<<(box& rhs) { *this << LINE(rhs.x1(), rhs.y1(), rhs.x2(), rhs.y1(), rhs.clr()); *this << LINE(rhs.x2(), rhs.y1(), rhs.x2(), rhs.y2(), rhs.clr()); *this << LINE(rhs.x2(), rhs.y2(), rhs.x1(), rhs.y2(), rhs.clr()); *this << LINE(rhs.x1(), rhs.y2(), rhs.x1(), rhs.y1(), rhs.clr()); return *this; } surface& surface::operator<<(Circle& rhs) { const float delta_theta = 1.0; float theta = 0.0; while (theta <= 360.0) { const int x_1 = (int)(rhs.x() + rhs.r() * cos(theta * PI / 180)); const int y_1 = (int)(rhs.y() + rhs.r() * sin(theta * PI / 180)); theta += delta_theta; const int x_2 = (int)(rhs.x() + rhs.r() * cos(theta * PI / 180)); const int y_2 = (int)(rhs.y() + rhs.r() * sin(theta * PI / 180)); *this << LINE(x_1, y_1, x_2, y_2, rhs.clr()); } return *this; } surface& surface::resize_usable(int x0, int y0, int x1, int y1, int ofsx, int ofsy) { if (x0 != -1) then use_left = x0; if (y0 != -1) then use_top = y0; if (x1 != -1) then use_right = x1; if (y1 != -1) then use_bottom = y1; if (ofsx != -1) then x_ofs = ofsx; if (ofsy != -1) then y_ofs = ofsy; return *this; } void surface::set_image(const int blx, const int bly, const int urx, const int ury) { im_top = ury; im_bottom = bly; im_left = blx; im_right = urx; } void surface::surround(void) { *this << box(im_left - 1, im_top - 1, im_right + 1, im_bottom + 1); } Circle::Circle(const int a, const int b, const int c, const int d) { _x = a; _y = b; _r = c; _clr = d; } text::text(const int a, const int b, const int c, DREstring d, const int e) { _x = a; _y = b; _clr = e; _height = c; _words = d; } // ---------------------------- dot ---------------------------- // constructor dot::dot(const int a, const int b, const int s, const int c) { _x = a; _y = b; _clr = c; _size = s; } // copy constructor dot::dot(const dot& d) { *this = d; } void dot::operator=(const dot& d) { _x = d._x; _y = d._y; _clr = d._clr; _size = d._size; } boolean dot::operator==(const dot& d) const { return ((_x == d._x) && (_y == d._y) && (_clr == d._clr) && (_size == d._size)); } LINE::LINE(const int a, const int b, const int c, const int d, const int e) { _x1 = a; _y1 = b; _x2 = c; _y2 = d; _clr = e; } box::box(const int a, const int b, const int c, const int d, const int e) { _x1 = a; _y1 = b; _x2 = c; _y2 = d; _clr = e; }