paintNote method
Implementation
void paintNote(Canvas canvas, Size size, Note note, Offset offset) {
const double minNoteRadius = 3;
const double maxNoteRadius = 20;
const double noteRadiusRangeDiff = maxNoteRadius - minNoteRadius;
const double minShadowElevation = 1;
const double maxShadowElevation = 5;
final double noteRadius = (min(size.width / 2, size.height) * .09)
.clamp(minNoteRadius, maxNoteRadius);
final shadowElevation =
((noteRadius - minNoteRadius) / noteRadiusRangeDiff) *
maxShadowElevation;
final path = Path()
..addOval(Rect.fromCircle(center: offset, radius: noteRadius));
canvas.drawShadow(path, tabContext.noteLabelColor,
max(minShadowElevation, shadowElevation), false);
canvas.drawPath(path, tabContext.noteShapePaint);
final textStyle =
TextStyle(color: tabContext.noteLabelColor, fontSize: noteRadius * 1.5);
final textSpan = TextSpan(text: note.fret.toString(), style: textStyle);
final textPainter = TextPainter(
text: textSpan,
textDirection: TextDirection.ltr,
);
textPainter.layout();
textPainter.paint(
canvas,
offset -
Offset(textPainter.size.width / 2, textPainter.size.height / 2));
if (note.melody) {
canvas.drawCircle(offset, noteRadius, tabContext.techniquePaint);
}
}