_nb_vertices, _x, _y);
}
+#ifdef X11_SUPPORT
void Polygon::draw(SimpleWindow *window) {
window->color(_red, _green, _blue);
int x[_nb_vertices], y[_nb_vertices];
y[n] = int(_y[n]);
}
window->color(0.0, 0.0, 0.0);
- for(int n = 0; n < _nb_vertices; n++)
+ // 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]);
+ }
+}
+#endif
+
+void Polygon::draw(Canvas *canvas) {
+ canvas->set_drawing_color(_red, _green, _blue);
+ canvas->draw_polygon(1, _nb_vertices, _x, _y);
+}
+
+void Polygon::draw_contours(Canvas *canvas) {
+ canvas->set_drawing_color(0.0, 0.0, 0.0);
+ canvas->draw_polygon(0, _nb_vertices, _x, _y);
}
void Polygon::set_vertex(int k, scalar_t x, scalar_t y) {
_nb_polygons = nb_polygons;
- a = _relative_x[_nb_vertices - 1] * _relative_y[0] - _relative_x[0] * _relative_y[_nb_vertices - 1];
+ a = _relative_x[_nb_vertices - 1] * _relative_y[0]
+ - _relative_x[0] * _relative_y[_nb_vertices - 1];
+
for(int n = 0; n < _nb_vertices - 1; n++)
a += _relative_x[n] * _relative_y[n+1] - _relative_x[n+1] * _relative_y[n];
a *= 0.5;
return false;
}
-