Skip to content

Adjusted rendering of half note rhythm stem #605

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/rendering/TabBarRenderer.ts
Original file line number Diff line number Diff line change
@@ -293,9 +293,8 @@ export class TabBarRenderer extends BarRendererBase {
let y1: number = cy + this.y;
let y2: number = cy + this.y + this.height - this._tupletSize;
let startGlyph: TabBeatGlyph = this.getOnNotesGlyphForBeat(beat) as TabBeatGlyph;
if (!startGlyph.noteNumbers) {
y1 +=
this.height -
if (!startGlyph.noteNumbers || beat.duration === Duration.Half) {
y1 += this.height -
this.settings.notation.rhythmHeight * this.settings.display.scale -
this._tupletSize;
} else {
@@ -491,14 +490,14 @@ export class TabBarRenderer extends BarRendererBase {
canvas.moveTo(x, y);

let lineY = topY;
// draw until next hole
if (holes.length > 0) {
// draw until next hole (if hole reaches into line)
if (holes.length > 0 && holes[holes.length -1].bottomY > lineY) {
const bottomHole = holes.pop()!;
lineY = cy + bottomHole.bottomY;
canvas.lineTo(x, lineY);
y = cy + bottomHole.topY;
} else {
canvas.lineTo(x, topY);
canvas.lineTo(x, lineY);
break;
}
}
@@ -522,7 +521,7 @@ export class TabBarRenderer extends BarRendererBase {
let y1: number = cy + this.y;
let y2: number = cy + this.y + this.height - this._tupletSize;
let startGlyph: TabBeatGlyph = this.getOnNotesGlyphForBeat(beat) as TabBeatGlyph;
if (!startGlyph.noteNumbers) {
if (!startGlyph.noteNumbers || beat.duration === Duration.Half) {
y1 +=
this.height - this.settings.notation.rhythmHeight * this.settings.display.scale - this._tupletSize;
} else {
Binary file modified test-data/visual-tests/guitar-tabs/rhythm-with-beams.gp
Binary file not shown.
Binary file modified test-data/visual-tests/guitar-tabs/rhythm-with-beams.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test-data/visual-tests/guitar-tabs/rhythm.gp
Binary file not shown.
Binary file modified test-data/visual-tests/guitar-tabs/rhythm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 12 additions & 9 deletions test/visualTests/PixelMatch.ts
Original file line number Diff line number Diff line change
@@ -107,22 +107,25 @@ export class PixelMatch {

// check if images are identical
const len = width * height;
const a32 = new DataView(img1.buffer);
const b32 = new DataView(img2.buffer);
let identical = true;
let transparentPixels = 0;

for (let i = 0; i < len; i++) {
if (a32.getInt32(i, true) !== b32.getInt32(i, true)) {
const img1r = img1[(i * 4) + 0];
const img1g = img1[(i * 4) + 1];
const img1b = img1[(i * 4) + 2];
const img1a = img1[(i * 4) + 3];

const img2r = img2[(i * 4) + 0];
const img2g = img2[(i * 4) + 1];
const img2b = img2[(i * 4) + 2];
const img2a = img2[(i * 4) + 3];

if (img1r !== img2r || img1g !== img2g || img1b !== img2b || img1a !== img2a) {
identical = false;
break;
}
if (
a32.getUint8(i) === 0xff &&
a32.getUint8(i + 1) === 0 &&
a32.getUint8(i + 2) === 0 &&
a32.getUint8(i + 3) === 0
) {
if (img1a === 0) {
transparentPixels++;
}
}