Improve antialiased line drawing sharpness and respect of original width
Antialiased lines with a width of 2 pixels or more now use a smaller feather width of 1.25 instead of 2.0. This makes them look sharper and better preserves their original shape while still having good antialiasing quality. This also improves the appearance of thin antialiased lines by slightly increasing their feather size (from 1.0 to 1.25). It makes them appear a tad thicker, but the antialiasing quality is much improved by doing this.
This commit is contained in:
parent
73812c70f2
commit
cf1ce8494d
|
@ -594,9 +594,13 @@ void RendererCanvasCull::canvas_item_add_line(RID p_item, const Point2 &p_from,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_antialiased) {
|
if (p_antialiased) {
|
||||||
float border_size = 2.0;
|
// Use the same antialiasing feather size as StyleBoxFlat's default
|
||||||
if (p_width < border_size) {
|
// (but doubled, as it's specified for both sides here).
|
||||||
border_size = p_width;
|
// This value is empirically determined to provide good antialiasing quality
|
||||||
|
// while not making lines appear too soft.
|
||||||
|
float border_size = 1.25f;
|
||||||
|
if (p_width < 1.0f) {
|
||||||
|
border_size *= p_width;
|
||||||
}
|
}
|
||||||
Vector2 dir2 = diff.normalized();
|
Vector2 dir2 = diff.normalized();
|
||||||
|
|
||||||
|
@ -763,9 +767,13 @@ void RendererCanvasCull::canvas_item_add_polyline(RID p_item, const Vector<Point
|
||||||
Color *colors_ptr = colors.ptrw();
|
Color *colors_ptr = colors.ptrw();
|
||||||
|
|
||||||
if (p_antialiased) {
|
if (p_antialiased) {
|
||||||
float border_size = 2.0;
|
// Use the same antialiasing feather size as StyleBoxFlat's default
|
||||||
if (p_width < border_size) {
|
// (but doubled, as it's specified for both sides here).
|
||||||
border_size = p_width;
|
// This value is empirically determined to provide good antialiasing quality
|
||||||
|
// while not making lines appear too soft.
|
||||||
|
float border_size = 1.25f;
|
||||||
|
if (p_width < 1.0f) {
|
||||||
|
border_size *= p_width;
|
||||||
}
|
}
|
||||||
Color color2 = Color(1, 1, 1, 0);
|
Color color2 = Color(1, 1, 1, 0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue