Fix lineset drawing for lines > 1px width
This is a follow up to 248e37ac0c
.
A line at 0 with 1px width should draw from 0.5 to 1.5
(cairo pixel offset). The same line with a width of 3px
is -0.5 to 2.5.
The self.intersection code calculates this correctly, subtracting
shift, the drawing code however incorrectly added it.
This fixes MIDI track grid/note offset as well as a bleed
below the track.
This commit is contained in:
parent
8a371bcaa2
commit
f08299ea1e
@ -101,7 +101,7 @@ LineSet::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
|
||||
for (auto const & l : _lines) {
|
||||
|
||||
Rect self;
|
||||
const double shift = l.width * 0.5;
|
||||
const double shift = l.width * 0.5 - 1;
|
||||
|
||||
if (_orientation == Horizontal) {
|
||||
self = Rect (0, l.pos - (l.width/2.0), _extent, l.pos + (l.width/2.0));
|
||||
@ -135,12 +135,12 @@ LineSet::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
|
||||
|
||||
if (_orientation == Horizontal) {
|
||||
const double y = item_to_window (Duple (0, l.pos)).y;
|
||||
context->move_to (intersection.x0, y + shift);
|
||||
context->line_to (intersection.x1, y + shift);
|
||||
context->move_to (intersection.x0, y - shift);
|
||||
context->line_to (intersection.x1, y - shift);
|
||||
} else {
|
||||
const double x = item_to_window (Duple (l.pos, 0)).x;
|
||||
context->move_to (x + shift, intersection.y0);
|
||||
context->line_to (x + shift, intersection.y1);
|
||||
context->move_to (x - shift, intersection.y0);
|
||||
context->line_to (x - shift, intersection.y1);
|
||||
}
|
||||
|
||||
context->stroke ();
|
||||
|
Loading…
Reference in New Issue
Block a user