x[n] = int(_x[n]);
y[n] = int(_y[n]);
}
- window->color(0.0, 0.0, 0.0);
- for(int n = 0; n < _nb_vertices; n++)
+ // window->color(0.0, 0.0, 0.0);
+ window->color(1.0, 1.0, 1.0);
+ 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) {
+ cairo_set_line_width(context_resource, 1.0);
+ cairo_set_source_rgb (context_resource, _red, _green, _blue);
+ cairo_move_to(context_resource, _x[0], _y[0]);
+ for(int n = 0; n < _nb_vertices; n++) {
+ cairo_line_to(context_resource, _x[n], _y[n]);
+ }
+ cairo_close_path(context_resource);
+ cairo_stroke_preserve(context_resource);
+ cairo_fill(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);
+ cairo_set_source_rgb (context_resource, 1.0, 1.0, 1.0);
+ cairo_move_to(context_resource, _x[0], _y[0]);
+ for(int n = 0; n < _nb_vertices; n++) {
+ cairo_line_to(context_resource, _x[n], _y[n]);
+ }
+ cairo_close_path(context_resource);
+ 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;
}
-