The problem to fix is that the arrow drawn by draw_arrow1() in src/fl_symbols.cxx displays a faint clear line between the stem and head of the arrow with the Cairo graphics driver. This occurs because draw_arrow1() draws the arrow in 2 steps (a rectangle + a triangle) and the Cairo driver is configured to use antialiasing when filling polygons. The antialiasing produces the faint line between stem and head. Why does draw_arrow1() draw a rectangle + a triangle rather than a 7-vertex polygon? That's because the X11 graphics driver fails with its polygon- drawing function when the polygon is also rotated: the polygon is drawn empty. We want to keep using antialiasing under Cairo for polygons because the result is better with non horizontal/vertical polygon edges. This implementation changes function draw_arrow1() which draws the arrow as a 7-vertex filled polygon except when the graphics driver returns false for its virtual member function can_fill_non_convex_polygon(). In that situation, draw_arrow1() draws, as before, a rectangle + a triangle. The new, virtual member function can_fill_non_convex_polygon() returns true except for the X11 graphics driver. Therefore, draw_arrow1() is effectively unchanged under the X11 driver.
95 lines
2.4 KiB
C++
95 lines
2.4 KiB
C++
//
|
|
// Portable drawing routines for the Fast Light Tool Kit (FLTK).
|
|
//
|
|
// Copyright 1998-2022 by Bill Spitzak and others.
|
|
//
|
|
// This library is free software. Distribution and use rights are outlined in
|
|
// the file "COPYING" which should have been included with this file. If this
|
|
// file is missing or damaged, see the license at:
|
|
//
|
|
// https://www.fltk.org/COPYING.php
|
|
//
|
|
// Please see the following page on how to report bugs and issues:
|
|
//
|
|
// https://www.fltk.org/bugs.php
|
|
//
|
|
|
|
/**
|
|
\file Fl_Xlib_Graphics_Driver_vertex.cxx
|
|
\brief Portable drawing code for drawing arbitrary shapes with
|
|
simple 2D transformations, implemented for X11 Xlib.
|
|
*/
|
|
|
|
#include <config.h>
|
|
#include "Fl_Xlib_Graphics_Driver.H"
|
|
|
|
#include <FL/fl_draw.H>
|
|
#include <FL/platform.H>
|
|
#include <FL/math.h>
|
|
|
|
|
|
void Fl_Xlib_Graphics_Driver::end_points() {
|
|
if (n>1) XDrawPoints(fl_display, fl_window, gc_, short_point, n, 0);
|
|
}
|
|
|
|
void Fl_Xlib_Graphics_Driver::end_line() {
|
|
if (n < 2) {
|
|
end_points();
|
|
return;
|
|
}
|
|
if (n>1) XDrawLines(fl_display, fl_window, gc_, short_point, n, 0);
|
|
}
|
|
|
|
void Fl_Xlib_Graphics_Driver::end_loop() {
|
|
fixloop();
|
|
if (n>2) {
|
|
transformed_vertex0(short_point[0].x , short_point[0].y );
|
|
}
|
|
end_line();
|
|
}
|
|
|
|
void Fl_Xlib_Graphics_Driver::end_polygon() {
|
|
fixloop();
|
|
if (n < 3) {
|
|
end_line();
|
|
return;
|
|
}
|
|
if (n>2) XFillPolygon(fl_display, fl_window, gc_, short_point, n, Convex, 0);
|
|
}
|
|
|
|
void Fl_Xlib_Graphics_Driver::gap() {
|
|
while (n>gap_+2 && short_point[n-1].x == short_point[gap_].x && short_point[n-1].y == short_point[gap_].y) n--;
|
|
if (n > gap_+2) {
|
|
transformed_vertex0(short_point[gap_].x, short_point[gap_].y);
|
|
gap_ = n;
|
|
} else {
|
|
n = gap_;
|
|
}
|
|
}
|
|
|
|
void Fl_Xlib_Graphics_Driver::end_complex_polygon() {
|
|
gap();
|
|
if (n < 3) {
|
|
end_line();
|
|
return;
|
|
}
|
|
if (n>2) XFillPolygon(fl_display, fl_window, gc_, short_point, n, 0, 0);
|
|
}
|
|
|
|
bool Fl_Xlib_Graphics_Driver::can_fill_non_convex_polygon() {
|
|
return false;
|
|
}
|
|
|
|
// shortcut the closed circles so they use XDrawArc:
|
|
// warning: these do not draw rotated ellipses correctly!
|
|
// See fl_arc.c for portable version.
|
|
void Fl_Xlib_Graphics_Driver::ellipse_unscaled(double xt, double yt, double rx, double ry) {
|
|
int llx = (int)rint(xt-rx);
|
|
int w = (int)rint(xt+rx)-llx;
|
|
int lly = (int)rint(yt-ry);
|
|
int h = (int)rint(yt+ry)-lly;
|
|
|
|
(what == POLYGON ? XFillArc : XDrawArc)
|
|
(fl_display, fl_window, gc_, llx, lly, w, h, 0, 360*64);
|
|
}
|