use of com.xenoage.zong.musiclayout.stampings.LegerLineStamping in project Zong by Xenoage.
the class LegerLineRenderer method draw.
/**
* Draws the given {@link LegerLineStamping} on the given {@link Canvas},
* using the given {@link RendererArgs}.
*/
@Override
public void draw(Stamping stamping, Canvas canvas, RendererArgs args) {
LegerLineStamping legerLine = (LegerLineStamping) stamping;
StaffStamping parentStaff = legerLine.parentStaff;
float linePosition = legerLine.sp.lp;
float scaling = args.targetScaling;
float width = legerLine.widthIs * parentStaff.is;
float p1xMm = legerLine.sp.xMm - width / 2;
float p2xMm = p1xMm + width;
float lineWidthMm = parentStaff.getLineWidthMm();
Color color = Color.Companion.getBlack();
float yMm = 0;
if (canvas.getFormat() == CanvasFormat.Raster) {
// render on screen or print
BitmapLine screenLine = new BitmapLine(lineWidthMm, color, scaling);
BitmapStaff screenStaff = parentStaff.getBitmapInfo().getBitmapStaff(scaling);
yMm = parentStaff.positionMm.y + screenStaff.getYMm(linePosition);
lineWidthMm = screenLine.widthMm;
} else if (canvas.getFormat() == CanvasFormat.Vector) {
// render with high quality
yMm = parentStaff.computeYMm(linePosition);
}
canvas.drawLine(p(p1xMm, yMm), p(p2xMm, yMm), color, lineWidthMm);
}
use of com.xenoage.zong.musiclayout.stampings.LegerLineStamping in project Zong by Xenoage.
the class LegerLinesStamper method stamp.
public LegerLineStamping[] stamp(ChordNotation chordNotation, float chordXMm, StaffStamping staffStamping) {
NotesNotation notes = chordNotation.notes;
int bottomCount = getBottomCount(notes.getBottomNote().lp);
int topCount = getTopCount(notes.getTopNote().lp, staffStamping.linesCount);
if (bottomCount > 0 || topCount > 0) {
// horizontal position and width (may differ above and below staff, dependent on suspended notes)
NoteSuspension bottomSuspension = getBottomSuspension(notes.notes);
float xTopMm = getXMm(chordXMm, notes.noteheadWidthIs, bottomSuspension, staffStamping.is);
float widthBottomIs = getWidthIs(bottomSuspension != None);
NoteSuspension topSuspension = getTopSuspension(notes.notes, staffStamping.linesCount);
float xBottomMm = getXMm(chordXMm, notes.noteheadWidthIs, topSuspension, staffStamping.is);
float widthTopIs = getWidthIs(bottomSuspension != None);
// vertical positions
int[] bottomLps = getBottomLps(bottomCount);
int[] topLps = getTopLps(topCount, staffStamping.linesCount);
// create stampings
LegerLineStamping[] ret = new LegerLineStamping[bottomCount + topCount];
for (int i : range(bottomCount)) ret[i] = new LegerLineStamping(sp(xBottomMm, bottomLps[i]), widthBottomIs, staffStamping);
for (int i : range(topCount)) ret[bottomCount + i] = new LegerLineStamping(sp(xTopMm, topLps[i]), widthTopIs, staffStamping);
return ret;
} else {
return empty;
}
}
Aggregations