summaryrefslogtreecommitdiff
path: root/src/Fl_Graphics_Driver.cxx
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2021-03-01 15:47:23 +0100
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2021-03-01 15:47:30 +0100
commitb771ee53b9e7c9a182764994ddd0852d91cc833f (patch)
tree2cb173cb097d4fcf07e0ccb15243332fe237cde1 /src/Fl_Graphics_Driver.cxx
parent0623a8d4b9e8a56cc435dc550c6b56fa1a9607e9 (diff)
Remove duplicated code between derived classes of Fl_Graphics_Driver - cont'd.
Diffstat (limited to 'src/Fl_Graphics_Driver.cxx')
-rw-r--r--src/Fl_Graphics_Driver.cxx25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/Fl_Graphics_Driver.cxx b/src/Fl_Graphics_Driver.cxx
index be8849dd4..f1164c19e 100644
--- a/src/Fl_Graphics_Driver.cxx
+++ b/src/Fl_Graphics_Driver.cxx
@@ -496,7 +496,10 @@ int Fl_Graphics_Driver::clip_box(int x, int y, int w, int h, int &X, int &Y, int
int Fl_Graphics_Driver::not_clipped(int x, int y, int w, int h) {return 1;}
/** see fl_begin_complex_polygon() */
-void Fl_Graphics_Driver::begin_complex_polygon() {}
+void Fl_Graphics_Driver::begin_complex_polygon() {
+ begin_polygon();
+ gap_ = 0;
+}
/** see fl_transformed_vertex() */
void Fl_Graphics_Driver::transformed_vertex(double xf, double yf) {
@@ -514,8 +517,16 @@ void Fl_Graphics_Driver::end_points() {}
/** see fl_end_line() */
void Fl_Graphics_Driver::end_line() {}
+void Fl_Graphics_Driver::fixloop() { // remove equal points from closed path
+ while (n>2 && p[n-1].x == p[0].x && p[n-1].y == p[0].y) n--;
+}
+
/** see fl_end_loop() */
-void Fl_Graphics_Driver::end_loop() {}
+void Fl_Graphics_Driver::end_loop() {
+ fixloop();
+ if (n>2) transformed_vertex((float)p[0].x, (float)p[0].y);
+ end_line();
+}
/** see fl_end_polygon() */
void Fl_Graphics_Driver::end_polygon() {}
@@ -524,7 +535,15 @@ void Fl_Graphics_Driver::end_polygon() {}
void Fl_Graphics_Driver::end_complex_polygon() {}
/** see fl_gap() */
-void Fl_Graphics_Driver::gap() {}
+void Fl_Graphics_Driver::gap() {
+ while (n>gap_+2 && p[n-1].x == p[gap_].x && p[n-1].y == p[gap_].y) n--;
+ if (n > gap_+2) {
+ transformed_vertex((float)p[gap_].x, (float)p[gap_].y);
+ gap_ = n;
+ } else {
+ n = gap_;
+ }
+}
/** see fl_circle() */
void Fl_Graphics_Driver::circle(double x, double y, double r) {}