noteAt method
Add a note, with a connecting line on the left if we have one
Implementation
void noteAt(Note note, GlyphCode glyph, {bool withLineTo = true}) {
note.setGlyph(ctxt, glyph);
final noteAlignsRight = note.glyphVisualizer!.align == 'right';
final needsLine =
withLineTo &&
lastNote != null &&
(lineIsHanging ||
(lastNote!.glyphVisualizer != null &&
lastNote!.glyphVisualizer!.align == 'right') ||
(lastNote!.staffPosition - note.staffPosition).abs() > 1);
if (needsLine) {
final line = NeumeLineVisualizer(ctxt, lastNote!, note, lineIsHanging);
neume.addVisualizer(line);
line.bounds = line.bounds.copyWith(
x: (minX > x - line.bounds.width) ? minX : x - line.bounds.width,
);
if (!noteAlignsRight) x = line.bounds.x;
}
double xOffset = 0;
if (hasFlag(note.shapeModifiers, NoteShapeModifiers.linea)) {
final linea = LineaVisualizer(ctxt, note);
neume.addVisualizer(linea);
note.origin = note.origin.copyWith(x: note.origin.x + linea.origin.x);
xOffset = linea.origin.x;
}
if (noteAlignsRight && lastNote != null) {
note.bounds = note.bounds.copyWith(x: x - note.bounds.width);
} else {
note.bounds = note.bounds.copyWith(x: x + xOffset);
x += note.bounds.width + xOffset;
}
neume.addVisualizer(note);
lastNote = note;
lineIsHanging = false;
}