return new Polygon(_mass, _red, _green, _blue, _relative_x, _relative_y, _nb_vertices);
}
-void Polygon::print_fig(ostream &os) {
- os << "2 2 0 1 0 7 50 -1 20 0.000 0 0 -1 0 0 " << _nb_vertices + 1 << endl;
- os << " ";
- for(int n = 0; n < _nb_vertices; n++) os << " " << int(_x[n]*10) << " " << int(_y[n]*10);
- os << " " << int(_x[0]*10) << " " << int(_y[0]*10);
- os << endl;
+void Polygon::color_xfig(XFigTracer *tracer) {
+ tracer->add_color(int(255 * _red), int(255 * _green), int(255 * _blue));
+}
+
+void Polygon::print_xfig(XFigTracer *tracer) {
+ tracer->draw_polygon(int(255 * _red), int(255 * _green), int(255 * _blue),
+ _nb_vertices, _x, _y);
}
void Polygon::draw(SimpleWindow *window) {
y[n] = int(_y[n]);
}
window->color(0.0, 0.0, 0.0);
- for(int n = 0; n < _nb_vertices; n++)
+ for(int n = 0; n < _nb_vertices; n++) {
window->draw_line(x[n], y[n], x[(n+1)%_nb_vertices], y[(n+1)%_nb_vertices]);
+ }
+}
+
+#ifdef CAIRO_SUPPORT
+void Polygon::draw(cairo_t* context_resource) {
}
+void Polygon::draw_contours(cairo_t* context_resource) {
+ cairo_set_line_width(context_resource, 1.0);
+ cairo_set_source_rgb (context_resource, 0.0, 0.0, 0.0);
+ for(int n = 0; n < _nb_vertices; n++) {
+ cairo_move_to(context_resource, _x[n], _y[n]);
+ cairo_line_to(context_resource, _x[(n+1)%_nb_vertices], _y[(n+1)%_nb_vertices]);
+ }
+ cairo_stroke(context_resource);
+}
+#endif
+
void Polygon::set_vertex(int k, scalar_t x, scalar_t y) {
_relative_x[k] = x;
_relative_y[k] = y;
return false;
}
-